I want to use a download font in Tkinter for my Python project, I read a few answers on another post but my pyglet module won't work, is there an alternative way to use my font
Asked
Active
Viewed 238 times
0
-
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Aug 06 '22 at 23:18
-
1tkinter has no support for installing additional fonts. – Bryan Oakley Aug 07 '22 at 03:37
1 Answers
0
This worked for me (with Pycharm's pyglet library) and can be used to add downloaded fonts to Tkinter (but once again your platform must support the pyglet module):
import tkinter as tk
import pyglet
# replace 'font.ttf' with your ttf file
pyglet.font.add_file('font.ttf')
root = tk.Tk()
# replace 'font' with your font name
MyLabel = tk.Label(root, text="font test", font=('font', 15))
MyLabel.pack()
root.mainloop()

Jai Amin
- 16
- 4