CairoFontMatch
searches for fonts based on a fontconfig pattern.CairoFontMatch(fontpattern="Helvetica",sort=FALSE,verbose=FALSE)
1. family: "Bitstream Vera Sans", style: "Roman", file: "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf"
verbose='FALSE' displays the font properties 'family', 'style', and 'file', while verbose='TRUE' will display the canonical font pattern, displaying all properties known for the font (output of CairoFontMatch(":",verbose=TRUE)):
1. family: "Bitstream Vera Sans", style: "Roman", file: "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf" "Bitstream Vera Sans-12:familylang=en:style=Roman:stylelang=en:slant=0:weight=80:width=100:pixelsize=12.5:foundry=bitstream:hintstyle=3:hinting=True:verticallayout=False:autohint=False:globaladvance=True:index=0:outline=True:scalable=True:dpi=75:rgba=1:scale=1:fontversion=131072:fontformat=TrueType:embeddedbitmap=True:decorative=False"
A simple approach to selecting a font starts with calling CairoFontMatch(":",sort=TRUE) to list all available fonts. Next, the user will choose a font from the list and call CairoFontMatch("FamilyName:style=PreferredStyle",sort=TRUE) substituting "FamilyName" and "PreferredStyle" with the desired values. If only one font is found, then the user has found the fontconfig pattern that will select the desired font. Otherwise, the user will call CairoFontMatch with verbose=TRUE to determine other properties to add to the pattern to attain the desired font, for instance the fontformat.
The following excerpt is from the fontconfig user's manual (http://fontconfig.org/) and better describes the fontconfig pattern definition:
"Fontconfig provides a textual representation for patterns that the library can both accept and generate. The representation is in three parts, first a list of family names, second a list of point sizes and finally a list of additional properties:
Font Pattern Meaning ---------------------------------------------------------- Times-12 12 point Times Roman Times-12:bold 12 point Times Bold Courier:italic Courier Italic in the default size Monospace:matrix=1 .1 0 1 The users preferred monospace font with artificial obliquing
The '', '-', ':' and ',' characters in family names must be preceeded by a '' character to avoid having them misinterpreted. Similarly, values containing '', '=', '_', ':' and ',' must also have them preceeded by a '' character. The '' characters are stripped out of the family name and values as the font name is read."
CairoFonts
,
Cairo