fontskivykivymdmddialog

font_name in MDDialog


I want change mddialog font in kivymd library. This code does't work when I add font_name. I would greatly appreciate it if you help me.

from kivy.lang import Builder
from kivy.animation import Animation
from kivymd.app import MDApp
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
KV = '''
FloatLayout:
    MDFlatButton:
        text: "ALERT DIALOG"
        pos_hint: {'center_x': .5, 'center_y': .5}
        on_release: app.show_alert_dialog()
'''

class Example(MDApp):
    dialog = None
    def build(self):
        return Builder.load_string(KV)
    def show_alert_dialog(self):
        if not self.dialog:
            self.dialog = MDDialog(
                text="Hello",font_name='calibrib.ttf',
                buttons=[
                    MDFlatButton(
                        text="CANCEL"
                    ),
                    MDFlatButton(
                        text="DISCARD"
                    ),
                ],
            )
        self.dialog.open()

Example().run()

Solution

  • self.dialog = MDDialog(text="[font=calibrib.ttf]Hello[/font]")