kivy: Problem displaying some Persian / Arabic letters

Question:

I am designing a desktop software based on Python and the kivy platform and I use Persian / Arabic language in the software. Using two libraries arabic_reshaper and bidi. But the problem is that two of the letters, the letters "ی" and "ر", are not displayed correctly. I am sure about the health of the font because, firstly, it works perfectly well in environments such as Photoshop and Word, and secondly, it is the most famous font of this language.But I dont know where the problem is that they are not displayed properly in kivy.My method is to change the font name to roboto and replace the kivy font folder fonts.

this is my code:

from kivy.lang import Builder
import arabic_reshaper
from bidi.algorithm import get_display
from kivymd.app import MDApp

KV = '''
#:import arabic_reshaper arabic_reshaper
#:import get_display bidi.algorithm.get_display

Screen:

    BoxLayout:
        orientation: "vertical"

        MDToolbar:
            title: get_display(arabic_reshaper.reshape("ایران سنس"))

        MDLabel:
            halign: "center"
            text_language: "ar"
            base_direction: "rtl"
            shorten_from: "left"
            strip: True
            text:get_display(arabic_reshaper.reshape("این یک متن نمونه برای تست می باشد"))
'''


class Test(MDApp):
    def build(self):
        return Builder.load_string(KV)


Test().run()

and this is result:

enter image description here

Does anyone know where the problem comes from?

Asked By: vahidkoohkan

||

Answers:

Try This:

from kivy.app import App 
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.lang import Builder
import arabic_reshaper
from bidi.algorithm import get_display

Builder.load_string("""
<First>:
    Label:  
        text : root.bidi_text
        font_name : "iransans.ttf"

        
""")



class First(Screen):
    reshaped_text = arabic_reshaper.reshape("رضى")
    bidi_text = get_display(reshaped_text)


class Second(Screen):
    pass

class ArabApp(App):
    def build(self):
        sm = ScreenManager()
        sm.add_widget(First(name="First"))
        return sm



ArabApp().run()
Answered By: Reda Louriki

By communicating with the font support, the problem was finally solved by providing several updates (the problem was with the font).

Thank you all

Answered By: vahidkoohkan
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.