Skip to content

Instantly share code, notes, and snippets.

@StefRe
Created January 25, 2022 11:33
Show Gist options
  • Save StefRe/3ec99394f90def431e19e06534c7e60e to your computer and use it in GitHub Desktop.
Save StefRe/3ec99394f90def431e19e06534c7e60e to your computer and use it in GitHub Desktop.
Tkinter Standard Fonts and How to Scale them
import tkinter as tk
import tkinter.font
root = tk.Tk()
print('Standard fonts:')
for name in sorted(tk.font.names()):
config = tk.font.Font(name=name, exists=True).config()
print(f"{name:20.20}: {config['family']} {config['size']} {config['weight']}")
# increase all fonts by given factor
factor = 2.5
for name in sorted(tk.font.names()):
font = tk.font.Font(name=name, exists=True)
font.configure(size=round(font.cget('size') * factor))
print(f'\nStandard fonts scaled by factor {factor}:')
for name in sorted(tk.font.names()):
config = tk.font.Font(name=name, exists=True).config()
print(f"{name:20.20}: {config['family']} {config['size']} {config['weight']}")
@StefRe
Copy link
Author

StefRe commented Jan 25, 2022

Standard fonts on Windows 10 tk.TkVersion 8.6 (Python 3.8.2):

TkCaptionFont       : Segoe UI 9 normal
TkDefaultFont       : Segoe UI 9 normal
TkFixedFont         : Courier New 10 normal
TkHeadingFont       : Segoe UI 9 normal
TkIconFont          : Segoe UI 9 normal
TkMenuFont          : Segoe UI 9 normal
TkSmallCaptionFont  : Segoe UI 9 normal
TkTextFont          : Segoe UI 9 normal
TkTooltipFont       : Segoe UI 9 normal
ansi                : MS Sans Serif 8 normal
ansifixed           : Courier 10 normal
defaultgui          : MS Shell Dlg 8 normal
device              : System 10 bold
fixed               : Courier 10 normal
oemfixed            : Terminal 9 normal
system              : System 10 bold
systemfixed         : Fixedsys 9 normal

Font documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment