Closed RPINerd closed 1 month ago
@RPINerd
1) The import name for that font is different, try to find the correct font name
2) You should try passing the ctk,CTkFont("palm-pilot-small", 36)
A font import example program for your reference:
# Author: Akash Bora
import customtkinter
from tkinter import filedialog
import os
def load_font():
global font
if file := filedialog.askopenfilename(
filetypes=[("Font files", ["*.ttf", "*.otf"]),("All Files", "*.*")]):
customtkinter.FontManager.load_font(file) # load font
font_name = os.path.basename(file).split(".")[0] # get font_name, can be different in some case
font = customtkinter.CTkFont(font_name,int(slider.get()))
label.configure(font=font)
button.configure(text=font_name)
root = customtkinter.CTk()
root.geometry("500x150")
font = customtkinter.CTkFont(customtkinter.ThemeManager.theme["CTkFont"])
font.configure(size=30)
button = customtkinter.CTkButton(root, text="Import Font", command=load_font)
button.pack(padx=10, pady=10, fill="x", expand=True)
slider = customtkinter.CTkSlider(root, from_=10, to=100, command=lambda e:font.configure(size=int(e)))
slider.pack(padx=10, pady=0, fill="x", expand=True)
label = customtkinter.CTkEntry(root, border_width=0, fg_color="transparent", font=font)
label.insert(0, "This is default text")
label.pack(padx=10, pady=10, fill="both", expand=True)
slider.set(30)
root.mainloop()
Thanks for getting back to me! Sadly it looks like the result is the same, the computer itself can preview the font, but when loaded into ctk it doesn't render correctly..
I can provide the font file if that would help, it's also available on it's own repo in my account: https://github.com/RPINerd/PalmOS-Fonts/tree/main/Fonts
@RPINerd Can be a problem with the name of the font. The import name is different I guess.
try palm-pilot
or palm_pilot
I'll try out a few different combos after lunch and get back to you, did a print of the ctkfont name property and it was returning 'font1' so maybe the TTF files don't have a proper name associated with the font..
@Akascape You were right! The actual names were camel-cased with spaces, which I did not expect, it looks like they are rendering as expected now, thank you!
So I have this font as a .ttf file, here is the 'preview' of what it looks like:
I am fairly certain that I've used the code correctly but as you can see in the window, the rendered font looks like just the system default: