Skip to content

Font

Represent a text font with a name, style, and size.

Use a Font to change how text looks on a Label, TextField, TextArea, Button, CheckBox, or DropDownList, or in text drawn with a Display's drawLabel().

A font's size is in pixels, so a given size looks the same on every kind of object and on every computer. Text you do not give a font to uses Arial at size 13.

Creating a Font

You can create a Font using the following functions:

Font(name)
Font(name, style, size)
Parameter Type Default Description
name str required The font name, for example "Serif", "Dialog", or "TimesRoman".
style tuple PLAIN The text style, one of Font.PLAIN, Font.BOLD, Font.ITALIC, or Font.BOLDITALIC.
size int -1 The size, in pixels. If left as the default, size 13 is used.

For example,

font = Font("Arial", Font.ITALIC, 16)

Once created, you can use it with the setFont() function from a Label, TextField, TextArea, Button, CheckBox, or DropDownList object.

Functions

Once a Font has been created, the following functions are available:

Function Description
getName() Return the font's name.
setName(name) Set the font's name.
getStyle() Return the font's style.
setStyle(style) Set the font's style.
getSize() Return the font's size.
setSize(size) Set the font's size.