Skip to content

How to use custom font with Python Tkinter Canvas?

twitter logo github logo ・1 min read  

RuntDeale (5 Part Series)

1) My Undertale fan-game (RuntDeale)'s logo 2) How to stop image stretching/smoothing (anti-aliasing) in Chrome canvas 3) (RuntDeale website setup) -- RuntDeale talk 4) How to (up || down)scale a tkinter PhotoImage? 5) How to use custom font with Python Tkinter Canvas?

How can I set I custom font, currently I know how to set a font,
let's say I have a Canvas element (ctx).

Now, I to switch the font I do:

fontName = "Arial"
fontSize = 10


but let's say I have a .ttf file, how would I go about importing a font from a .ttf file, in the same, or child folder, in python?

twitter logo DISCUSS
Classic DEV Post from Sep 17 '19

SOLID PRINCIPLES: To start with Object-oriented programming

PDS OWNER CALIN (Calin Baenen) profile image
I am a 13 (as of Oct 30 of 2019) yr/o developer (I have been developing mini-projects for 4, years now, since I was 9), who makes projects in languages like: Java, HTML, Python 3, JS, CSS, and C#.