```{index} single: Cairo::Font ``` # Cairo::Font ```{pperl-module-badges} Cairo::Font ``` The `Cairo::Font` family: font faces, scaled fonts and font options. This is the font half of the Cairo API. `Cairo::ToyFontFace` picks a font by family name, slant and weight; `Cairo::ScaledFont` is that face fixed at a particular size and transform, and is what answers questions about measurements - font extents, text extents, glyph extents, and turning a string into glyphs. `Cairo::FontOptions` carries the rendering settings (antialiasing, subpixel order, hinting, and on cairo 1.18 the color-font controls) that a context or a scaled font uses. `Cairo::FontFace` is the base class the face classes share, and `Cairo::FtFontFace` is the FreeType face - see its `create` for why it cannot be built here. ## Font faces come back as subclasses Anything returning a font face - `ScaledFont::get_font_face`, `Context::get_font_face` - blesses it into the class matching the font backend cairo reports: a toy face into `Cairo::ToyFontFace`, a FreeType face into `Cairo::FtFontFace`, anything else into the base `Cairo::FontFace`. All of them answer `status`, `get_type` and `DESTROY`, which the subclasses inherit. ## Object lifetime Font faces, scaled fonts and font options are reference-counted by cairo. An object you create owns its reference, and a getter that hands back an object its parent also holds - `ScaledFont::get_font_face` - takes a reference of its own, so what you get stays valid for as long as you hold it. Every object releases its reference when Perl destroys it; nothing has to be freed by hand. ## Methods report their cairo version at call time Each method looks up its cairo entry point in the installed libcairo the first time it is used. A method that libcairo does not provide croaks then and there, naming the version it needs (for instance `Cairo: text_extents requires libcairo >= 1.2`), rather than failing when the module is loaded.