kivy:显示一些波斯语/阿拉伯语字母时出现问题

2024-05-18 13:57:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在设计一个基于Python和kivy平台的桌面软件,我在软件中使用波斯语/阿拉伯语。使用两个库arabic_Reformer和bidi。但问题是其中两个字母“ی”和“ی”没有正确显示。我对字体的健康状况很有信心,因为首先,它在Photoshop和Word等环境中运行良好,其次,这是这种语言中最著名的字体。但我不知道问题出在哪里,它们在kivy中没有正确显示。我的方法是将字体名称更改为roboto,并替换kivy font folder字体

这是我的代码:

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()

这就是结果:

enter image description here

有人知道问题出在哪里吗


Tags: fromimportget软件displaybuilder字体algorithm

热门问题