Name
cairo.FontFace -- create font face
Synopsis
font = cairo.FontFace(pattern)
Function
Creates a new font face for the FreeType font backend based on a Fontconfig pattern. This font can then be used with ccontext:SetFontFace() or cairo.ScaledFont().

The pattern argument can be either a string in the format used by Fontconfig, e.g. "Ubuntu:style=italic:weight=200" or it can be a table that can contain the following tags, each describing a single element of a Fontconfig pattern:

Family
The font family name.

Style
Font style (passed as a string). Overrides weight and slant.

Slant
Font slant. This can be one of the following constants:

 
#FC_SLANT_ROMAN
#FC_SLANT_ITALIC
#FC_SLANT_OBLIQUE

Weight
Font weight. This can be one of the following constants:

 
#FC_WEIGHT_THIN
#FC_WEIGHT_EXTRALIGHT
#FC_WEIGHT_ULTRALIGHT
#FC_WEIGHT_LIGHT
#FC_WEIGHT_DEMILIGHT
#FC_WEIGHT_SEMILIGHT
#FC_WEIGHT_BOOK
#FC_WEIGHT_REGULAR
#FC_WEIGHT_NORMAL
#FC_WEIGHT_MEDIUM
#FC_WEIGHT_DEMIBOLD
#FC_WEIGHT_SEMIBOLD
#FC_WEIGHT_BOLD
#FC_WEIGHT_EXTRABOLD
#FC_WEIGHT_ULTRABOLD
#FC_WEIGHT_BLACK
#FC_WEIGHT_HEAVY
#FC_WEIGHT_EXTRABLACK
#FC_WEIGHT_ULTRABLACK

Size
Font size in points.

Aspect
Stretches glyphs horizontally before hinting.

PixelSize
Font size in pixels.

Spacing
Font spacing. This can be one of the following constants:

 
#FC_PROPORTIONAL
#FC_DUAL
#FC_MONO
#FC_CHARCELL

Width
Font width. This can be one of the following constants:

 
#FC_WIDTH_ULTRACONDENSED
#FC_WIDTH_EXTRACONDENSED
#FC_WIDTH_CONDENSED
#FC_WIDTH_SEMICONDENSED
#FC_WIDTH_NORMAL
#FC_WIDTH_SEMIEXPANDED
#FC_WIDTH_EXPANDED
#FC_WIDTH_EXTRAEXPANDED
#FC_WIDTH_ULTRAEXPANDED

File
The filename holding the font.

Index
The index of the font within the file.

This function returns a newly created Cairo font face. Free with cfontface:Free() when you are done using it.

Inputs
pattern
a Fontconfig pattern, passed either as a string or table
Results
font
a newly created Cairo font face

Show TOC