Skip to main content
The CTkFont class provides a font object with pixel-based sizing that remains independent of UI scaling. It extends tkinter’s Font class with additional CustomTkinter-specific features.

Usage

import customtkinter as ctk

# Create a custom font
font = ctk.CTkFont(family="Arial", size=14, weight="bold")

# Use it with a widget
label = ctk.CTkLabel(root, text="Hello World", font=font)

Constructor

CTkFont(
    family=None,
    size=None,
    weight=None,
    slant="roman",
    underline=False,
    overstrike=False
)

Parameters

family
str
default:"theme default"
The font family name as a string (e.g., “Arial”, “Helvetica”, “Times New Roman”). If not specified, uses the default family from the theme.
size
int
default:"theme default"
The font height in pixels as an integer. If not specified, uses the default size from the theme.
weight
Literal['normal', 'bold']
default:"theme default"
Font weight. Options:
  • "normal" - Regular weight
  • "bold" - Boldface
If not specified, uses the default weight from the theme.
slant
Literal['roman', 'italic']
default:"roman"
Font slant style. Options:
  • "roman" - Normal, unslanted text
  • "italic" - Italic text
underline
bool
default:false
Whether the text should be underlined. Set to True for underlined text, False for normal.
overstrike
bool
default:false
Whether the text should have a line through it. Set to True for overstruck text, False for normal.

Methods

configure()

Update font properties after creation.
font = ctk.CTkFont(size=12)
font.configure(size=16, weight="bold")
Parameters:
  • family (str, optional) - Change the font family
  • size (int, optional) - Change the font size
  • weight (str, optional) - Change the font weight
  • slant (str, optional) - Change the font slant
  • underline (bool, optional) - Change underline setting
  • overstrike (bool, optional) - Change overstrike setting

cget()

Retrieve current font property values.
current_size = font.cget("size")
current_family = font.cget("family")
Parameters:
  • attribute_name (str) - Name of the attribute to retrieve (e.g., “size”, “family”, “weight”)
Returns: The current value of the specified attribute

copy()

Create a deep copy of the font object.
font_copy = font.copy()
Returns: A new CTkFont instance with identical properties

Notes

  • CTkFont uses pixel-based sizing that remains consistent regardless of DPI scaling
  • The config() method is not available for CTkFont. Always use configure() instead
  • Font objects can be shared across multiple widgets and will update all widgets when configured
  • For more information on tkinter fonts, see the tkinter font documentation

Build docs developers (and LLMs) love