skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

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

    Thank you all


  2. 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()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search