Last active
January 6, 2025 10:47
-
-
Save vijinho/5e658aea0d823aaf6270 to your computer and use it in GitHub Desktop.
Code Snippet: Python Kivy - Set fonts from files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.core.text import LabelBase | |
KIVY_FONTS = [ | |
{ | |
"name": "Ubuntu", | |
"fn_regular": "assets/fonts/ubuntu/Ubuntu-L.ttf", | |
"fn_bold": "assets/fonts/ubuntu/Ubuntu-M.ttf", | |
"fn_italic": "assets/fonts/ubuntu/Ubuntu-LI.ttf", | |
"fn_bolditalic": "assets/fonts/ubuntu/Ubuntu-MI.ttf" | |
} | |
] | |
for font in KIVY_FONTS: | |
LabelBase.register(**font) | |
# in .kv | |
<Label>: | |
font_name: 'Ubuntu' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment