# import kivy
import os
from kivy.app import App
from kivy.core.text import LabelBase
from kivy.resources import resource_add_path
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
# https://source.typekit.com/source-han-serif/tw/
# https://github.com/adobe-fonts/source-han-sans
# https://github.com/googlefonts/noto-cjk
# 引用字體檔案
resource_add_path(os.path.abspath('NotoSerifCJK-Light.ttc'))
# 將kivy預設的字體替換成指定的中文字體
LabelBase.register('Roboto', 'NotoSerifCJK-Light.ttc')
class MyApp(App):
def build(self):
return Label(text="你好!中文測試。\nHello World", font_size=72)
# return Button(text="按鈕", font_size=36)
# return TextInput()
if __name__ == "__main__":
MyApp().run()
沒有留言:
張貼留言