0

I just wanted to ask whether there's a way to use the Nastalik fonts in Kivy. (IranNastaliq, Urdu Typesetting or Noto Nastaliq Urdu). if you know how to make a button with a text written in these fonts please answer.

I was trying IranNastaliq font nevertheless the thing that happened was that some letters weren't written (instead there were boxes) and the bounds between some Arabic letters weren't formed correctly. the two other fonts ended in this error:

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \UXXXXXXXX escape

My code:

from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
import arabic_reshaper
from bidi.algorithm import get_display
from kivy.core.text import LabelBase
from kivy.lang import Builder


#IranNastaliq:           'C:\WINDOWS\FONTS\FAR_NASTALIQ.TTF'
#Urdu Typesetting:       'C:\WINDOWS\FONTS\URDTYPE.TTF'
#Noto Nastaliq Urdu:     'C:\WINDOWS\FONTS\NOTONASTALIQURDU-VARIABLEFONT_WGHT.TTF'



class MyApp(App):
    def build(self):
        layout = BoxLayout(orientation='vertical')
        bidi_text = get_display(arabic_reshaper.reshape("Ůž"))
        LabelBase.register(name='Nastaliq',
                   fn_regular='C:\WINDOWS\FONTS\FAR_NASTALIQ.TTF'
                   )
        button = Button(text=bidi_text, font_name='Nastaliq', font_size=30)
        layout.add_widget(button)
        return layout


if __name__ == '__main__':
    MyApp().run()

0 Answers0