Is There A Way To Write Persian In Python Kivy
i try to write Persian in python kivy but it is not working. from kivy.app import App from kivy.uix.screenmanager import ScreenManager,Screen from kivy.lang import Builder from kiv
Solution 1:
You need to use some Persian font. I have done it with Arabic text
You can download the font from here
Then use arabic_reshaper library to get it in shape.
pip install arabic-reshaper
You will also need python-bidi as well to flip the letters
pip install python-bidi
Refer to this https://github.com/mpcabd/python-arabic-reshaper
Code
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager,Screen
from kivy.lang import Builder
from kivy import Config
from kivy.uix.label import Label
from kivy.uix.widget import Widget
import arabic_reshaper
from bidi.algorithm import get_display
class MainApp(App):
def build(self):
reshaped_text = arabic_reshaper.reshape("فارسی")
bidi_text = get_display(reshaped_text)
return Label(text= bidi_text, font_name='Amiri-Regular.ttf', font_size=30)
if __name__ == "__main__":
MainApp().run()
Output
Post a Comment for "Is There A Way To Write Persian In Python Kivy"