def __init__(self, **kwargs): LabelBase.register(name='SukhumvitSet', fn_regular=APP_FOLDER_NAME + '\\lib\\resources\\SukhumvitSet-Medium.ttf', fn_italic=APP_FOLDER_NAME + '\\lib\\resources\\SukhumvitSet-Medium.ttf', fn_bold=APP_FOLDER_NAME + '\\lib\\resources\\SukhumvitSet-Bold.ttf', fn_bolditalic=APP_FOLDER_NAME + '\\lib\\resources\\SukhumvitSet-Bold.ttf') theme_font_styles.append('SukhumvitSet') self.theme_cls.font_styles['SukhumvitSet'] = [ 'SukhumvitSet', 16, False, 0.15, ] self.theme_cls.primary_palette = 'Blue' super().__init__(**kwargs) #self.dialog_change_theme = None #self.toolbar = None self.snackbar = None
def sync_theme_styles(self, *args): # Syncs the values from self.font_styles to theme_font_styles # this will ensure continuity when someone registers a new font_style. for num, style in enumerate(theme_font_styles): if style not in self.font_styles: theme_font_styles.pop(num) for style in self.font_styles.keys(): theme_font_styles.append(style)
def build(self): LabelBase.register(name="JetBrainsMono", fn_regular="GreatVibes-Regular.ttf") theme_font_styles.append('JetBrainsMono') self.theme_cls.font_styles["JetBrainsMono"] = [ "JetBrainsMono", 60, False, 0.15, ] return Builder.load_string(KV)
def build(self): self.theme_cls.theme_style = 'Light' self.theme_cls.primary_palette = "Red" LabelBase.register(name="JetBrainsMono", fn_regular="JetBrainsMono-Regular.ttf") theme_font_styles.append('JetBrainsMono') self.theme_cls.font_styles["JetBrainsMono"] = [ "JetBrainsMono", 16, False, 0.15, ] return Controller()
def get_fontstyle(): fontname = get_font() filename = resource_find(fontname) if not filename and not fontname.endswith('.ttf'): fontname = '{}.ttf'.format(fontname) filename = resource_find(fontname) try: LabelBase.register(name=fontname, fn_regular=filename) theme_font_styles.append(fontname) get_app().theme_cls.font_styles[fontname] = [ fontname, int(get_app().settings_controller.screen.fontsize.text), False, 0.15 ] return fontname except: return "Body1"
# -*- encoding: utf-8 -*- """ @文件:main.py @说明: 主程序 """ # 字体初始化---------------------------------------- from kivy.core.text import LabelBase, DEFAULT_FONT from kivymd.font_definitions import theme_font_styles # 注册字体 font_file = __file__[: __file__.rfind("\\") + 1] + "siyuan.ttf" LabelBase.register(name="SiYuan", fn_regular=font_file) theme_font_styles.append("SiYuan") LabelBase.register(DEFAULT_FONT, "./siyuan.ttf") # -------------------------------------------------------------------------------- # 设置窗口大小---------------------------------------- from kivy.utils import platform from kivy.core.window import Window if platform == "win" or platform == "linux": Window.size = (335, 600) # -------------------------------------------------------------------------------- from kivymd.app import MDApp from kivy.lang import Builder from kivy.uix.screenmanager import ScreenManager from kivymd.uix.snackbar import Snackbar from Config import config, config_dict