Naming a Font

There are two basic ways to name a font. You can use predefined font names (e.g., system), or you can specify a set of font attributes with a platform-independent name:

label .foo -text "Hello" -font {times 12 bold}

In this form, the font is specified with a three element list. The first element is the font family, the second is the size, in points, and the third is a list of style parameters. The family determines the basic look, such as courier or helvetica.

The complete set of style parameters are normal, bold, roman, italic, underline, and overstrike. For example, to specify both bold and italic:

label .foo -text "Hello" -font {times 12 {bold italic}}

The font size is points, which are 1/72 inch. Tk maintains a scale factor ...

Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.