CustomTkinter
CustomTkinter copied to clipboard
how can use persian fonts in FontManager
import customtkinter
app = customtkinter.CTk()
customtkinter.FontManager.load_font("B Traffic Bold_0.ttf") # Import the .ttf file by this method label = customtkinter.CTkLabel(app, text="سلام!", font=("B Traffic Bold_0",30)) label.grid(padx=70, pady=50)
app.mainloop()
font not changed in persian text.is there any way?
Mind posting your version of font. I assume the unicode chars in the font you are trying to use are different than the one you have specified as text.
Mind posting your version of font. I assume the unicode chars in the font you are trying to use are different than the one you have specified as text.
So when i install this font in my windows,this is work. I want to be able to show it in the program without installing the font. Because you cannot manage the Windows fonts of the user that you use the applications.
custom_font = tkinter.font.Font(family="your_font_name", size=14, file=path_font) now, you can use custom_font as required without installing the font.
This code worked for me:
from PIL import ImageFont
font_path = "assets/fonts/myfont.ttf"
font = ImageFont.truetype(font_path, size=20)
font_info = font.getname()
font_family = font_info[0]
ctk_font = customtkinter.CTkFont(family=font_family, size=20, weight="bold")
label = customtkinter.CTkLabel(frame, text=text, font=ctk_font)