-
I'm using a custom font and it isn't a system font, therefore it can't be imported by its name. Is there a way to import a font from an TTF or OTF file ? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
It is possible, however it is not integrated into tkinter or customtkinter, and is only possible by doing some hacks. Due to this, your font won't be platform independent. Here is the sample code to use external fonts on windows: # Note : You'd still have to download the font in your system
import pyglet
import customtkinter
pyglet.font.add_file('file.ttf')
root = customtkinter.CTk()
MyLabel = customtkinter.CTkLabel(root,text="test",font=('font name',25))
MyLabel.pack()
root.mainloop()
# This is not going to work on linux |
Beta Was this translation helpful? Give feedback.
-
There is a module called |
Beta Was this translation helpful? Give feedback.
-
@RVFET No need to use any other package/module like pyglet, it's inbuilt in customtkinter. customtkinter.FontManager.load_font("my_font.ttf")
# then simply use that font
button = customtkinter.CTkButton(app, font=("my_font",20)) Make sure that the name of the font is properly described. |
Beta Was this translation helpful? Give feedback.
-
I would like to share with u guys that the font name and name of the font file is different, so if anyone tries to import the font file and it dosent load the font style, then try using the font name. For eg. in the image below u can see the font name, i had imported the file but it was not loading the font so when i used the font name then only it loaded the font |
Beta Was this translation helpful? Give feedback.
@RVFET No need to use any other package/module like pyglet, it's inbuilt in customtkinter.
Make sure that the name of the font is properly described.