Search⌘ K
AI Features

Font Size

Explore how to set and interpret font size using Pycairo’s set_font_size function. Understand the measurement in user units, the meaning of point sizes for print, and the em square concept for various character sets. This lesson helps you accurately control text appearance in vector graphics.

We'll cover the following...

Font size

The set_font_size function sets the size of the font and, therefore, the size of any text we create with that font. But, what exactly does the size value mean?

Font size is measured in user units —the same units we use when setting the line width. The font size indicates the height of the text, from the top of the tallest alphabetic character, such as a capital “A”, right down to the bottom of the tail of an alphabetic character, such as “g”. Here is an example of this:

As we can see in the example, the size includes a small extra margin above and below. Most fonts tend to do this.

If this seems vague, it is for a good reason. There are no fixed rules about how a particular font interprets the size value. It is, largely, down to the font designer to decide what they ...