Name
ccontext:SelectFontFace -- select font face
Synopsis
ccontext:SelectFontFace(family$, slant, weight)
Function
Note: The ccontext:SelectFontFace() function call is part of what the Cairo designers call the "toy" text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications.

Selects a family and style of font from a simplified description as a family name, slant and weight. Cairo provides no operation to list available family names on the system (this is a "toy", remember), but the standard CSS2 generic family names, ("serif", "sans-serif", "cursive", "fantasy", "monospace"), are likely to work as expected.

If family$ starts with the string "cairo:", or if no native font backends are compiled in, Cairo will use an internal font family. The internal font family recognizes many modifiers in the family$ string, most notably, it recognizes the string "monospace". That is, the family name "cairo:monospace" will use the monospace version of the internal font family.

For "real" font selection, see the font-backend-specific font face creation functions for the font backend you are using, e.g. cairo.FontFace(). The resulting font face could then be used with cairo.ScaledFont() and ccontext:SetScaledFont().

Similarly, when using the "real" font support, you can call directly into the underlying font system, such as fontconfig or freetype, for operations such as listing available fonts, etc.

It is expected that most applications will need to use a more comprehensive font handling and text layout library, for example, pango), in conjunction with Cairo.

If text is drawn without a call to ccontext:SelectFontFace(), nor ccontext:SetFontFace() nor ccontext:SetScaledFont(), the default family is platform-specific, but is essentially "sans-serif".

The slant parameter can be one of the following constants:

 
#CAIRO_FONT_SLANT_NORMAL
#CAIRO_FONT_SLANT_ITALIC
#CAIRO_FONT_SLANT_OBLIQUE

The weight parameter can be one of the following constants:

 
#CAIRO_FONT_WEIGHT_NORMAL
#CAIRO_FONT_WEIGHT_BOLD

Default slant is #CAIRO_FONT_SLANT_NORMAL, and default weight is #CAIRO_FONT_WEIGHT_NORMAL.

This function is equivalent to a call to cairo.ToyFontFace() followed by ccontext:SetFontFace().

Inputs
family$
a font family name
slant
the slant for the font (see above)
weight
the weight for the font (see above)

Show TOC