DearPyGui
DearPyGui copied to clipboard
Unicode Fonts have problem with RTL
hi i used persian or arabic font. dpg.add_font_range(0x0600, 0x06FF) worked perfectly but direction have a problem
my text is "سلام دنیا" but app showing like below image

how to fix this problem !?
I apologize for such a delayed response. I'm not 100% how to handle this issue yet but we will in the future (hopefully near). This is actually a duplicate of #320. So I will close the issue here.
سلام من یه ترفند پیدا کردم که فعلا مشکل نوشتههای لیبل ها رو حل کردم
1. نصب کتابخانه
pip install python-bidi arabic_reshaper
2. افزودن فونت
with dpg.font_registry():
with dpg.font(path_font_vazir, 20) as font_vazir:
# اضافه کردن محدوده کاراکترهای فارسی/عربی
dpg.add_font_range_hint(dpg.mvFontRangeHint_Default)
dpg.add_font_range(0x0600, 0x06FF) # حروف، اعداد، و علائم نگارشی عربی/فارسی
dpg.add_font_range(0xFB50, 0xFDFF) # شکلهای ارائه A (حروف فارسی/عربی)
dpg.add_font_range(0xFE70, 0xFEFF) # شکلهای ارائه B (حروف فارسی/عربی)
dpg.bind_font(font_vazir) # تخصیص فونت به عنوان پیش فرض
3. پاس دادن نویسه های پارسی به تابع اصلاح نویسه
def faFix(text):
# اصلاح متن فارسی با استفاده از arabic_reshaper
reshaped_text = arabic_reshaper.reshape(text)
# جهتدهی متن به صورت راستبهچپ با استفاده از bidi
bidi_text = get_display(reshaped_text)
return bidi_text
dpg.add_text(faFix("سلام دنیا"))