Text Is Just Shapes

Learn about the basics of the texts that are used in Pycairo.

We'll cover the following...

What is text?

At its most basic level, text is just a collection of shapes. Take a look at the huge text below:

Each letter is just a shape, created from straight lines and Bezier curves. Ultimately, Pycairo will draw each letter simply as a shape with no understanding of its meaning.

How Pycairo handles text

Of course, text isn’t really just shapes. Those shapes have meaning. They are letters that combine to make words and sentences.

Trying to add text to our file by drawing the shape of each character would be ridiculously difficult and tedious. Pycairo handles text at a higher level. Normally, we specify the text as a text string, and then set the size and font that is required.

We select a font to control the typeface that is used to display or print text. But, what exactly is a font? In simple terms, it is a file that defines the shapes of each letter, number, and symbol, in some defined character set and for a particular typeface.

When we add text in Pycairo, we use a Python string of characters. The font file contains information about the size of each ...