Class SystemFontCatalog
The fonts in a font directory (TrueType outlines, and OpenType fonts with CFF outlines), found by PostScript name or by family and style, with a fallback chain for characters the chosen font lacks. Only fonts whose licence allows embedding are used. Faces with CFF outlines are embedded as CIDFontType0 (FontFile3); where a TrueType face can stand in, it is preferred (see Fallbacks(bool, bool)).
public sealed class SystemFontCatalog
- Inheritance
-
SystemFontCatalog
- Inherited Members
Properties
AndroidFamilyAliases
The families substitution asks for (the Windows families of Match(string?, bool, bool, bool, bool, bool), Fallbacks(bool, bool) and the renderers' Unicode fallbacks) and the Android families that stand in for them. The names are those in the fonts' name tables on Android 7 to 15; a family a device lacks is skipped.
public static IReadOnlyDictionary<string, string[]> AndroidFamilyAliases { get; }
Property Value
Faces
public IReadOnlyList<SystemFontFace> Faces { get; }
Property Value
Installed
The installed fonts, read once: on Windows those installed for everyone (Windows\Fonts) and
those the user installed for themselves (%LOCALAPPDATA%\Microsoft\Windows\Fonts). On Android,
/system/fonts with AndroidFamilyAliases (ForAndroid(string)). Empty
in a browser, which has no font folder: a web host passes its own catalog (ForDirectory(string)).
public static SystemFontCatalog Installed { get; }
Property Value
LiberationFamilyAliases
The families substitution asks for and the Liberation family that stands in for each: Sans for Arial and Helvetica (and the other sans-serif families), Serif for Times New Roman and Times, Mono for Courier New and Courier. Liberation Sans, Serif and Mono have the metrics of Arial, Times New Roman and Courier New, so text keeps its widths. Symbol, Wingdings and the other symbol, math and script families have no Liberation equivalent and are not mapped.
public static IReadOnlyDictionary<string, string[]> LiberationFamilyAliases { get; }
Property Value
Methods
Fallbacks(bool, bool)
Faces tried, in order, for characters the chosen font does not have. TrueType faces come first (for each family, a TrueType stand-in before a CFF one: "Droid Sans Fallback" before "Noto Sans CJK"); faces with CFF outlines follow, for the characters only they have: first those of the families above, then one face of every other family with CFF outlines (fonts the user installed, such as Source Han Sans or Adobe fonts), by family name. Those last ones draw only what MayHaveAsFallback(SystemFontFace, int) allows (no Private Use Area characters, no empty glyphs).
public IEnumerable<SystemFontFace> Fallbacks(bool bold, bool italic)
Parameters
Returns
FindAliasedFamily(string, int, bool)
The face that stands in for family by this catalog's family aliases (Android:
Roboto for Arial), nearest to the weight and slant asked for; null when the catalog has no alias
for the family or none of its stand-ins is there.
public SystemFontFace? FindAliasedFamily(string family, int weight, bool italic)
Parameters
Returns
FindFamily(string, bool, bool)
The face of family nearest to the weight and slant asked for.
public SystemFontFace? FindFamily(string family, bool bold, bool italic)
Parameters
Returns
FindFamily(string, int, bool)
The face of family nearest to weight (100–900) and the slant asked for.
public SystemFontFace? FindFamily(string family, int weight, bool italic)
Parameters
Returns
ForAndroid(string)
The fonts of an Android font folder (/system/fonts), where the families that
substitution asks for by their Windows names stand in by AndroidFamilyAliases:
Arial and Helvetica are drawn with Roboto, Times with Noto Serif, Courier with Droid Sans Mono,
each glyph still placed by the document's widths. Fonts with CFF outlines (.otf, and
the CFF faces of .ttc collections such as Noto Sans CJK) are catalogued too: the Skia
backend, the only renderer on Android, loads them itself.
public static SystemFontCatalog ForAndroid(string directory = "/system/fonts")
Parameters
directorystring
Returns
ForDirectories(params string[])
The fonts of several folders, in the order given (a tie in matching goes to the earlier folder), read once per list.
public static SystemFontCatalog ForDirectories(params string[] directories)
Parameters
directoriesstring[]
Returns
ForDirectory(string)
The fonts (.ttf, .ttc, .otf) of a folder, read once per folder. Faces with
CFF outlines are flagged (OpenTypeCff): the renderers load them
as they are, and new text embeds them as CFF.
public static SystemFontCatalog ForDirectory(string directory)
Parameters
directorystring
Returns
FromFaces(IEnumerable<SystemFontFace>, IReadOnlyDictionary<string, string[]>?)
A catalog of faces a host describes itself (fonts it bundles and loads on demand, so that there is no folder to scan yet), with optional family aliases as in WithFamilyAliases(IReadOnlyDictionary<string, string[]>).
public static SystemFontCatalog FromFaces(IEnumerable<SystemFontFace> faces, IReadOnlyDictionary<string, string[]>? aliases = null)
Parameters
facesIEnumerable<SystemFontFace>aliasesIReadOnlyDictionary<string, string[]>
Returns
Match(string?, bool, bool, bool, bool, bool)
The installed font that best stands in for a document font, as a viewer that renders with system fonts chooses it: the same font when it is installed (by PostScript name, then by family with subset prefix, MT/PS suffixes and style words removed, in the style the name and the flags ask for), then the design Windows ships under another name (Helvetica → Arial, Palatino → Palatino Linotype …), otherwise a face of the same kind (monospaced, script, serif or sans-serif, from the descriptor flags and the name) and style.
public SystemFontFace? Match(string? baseFont, bool bold, bool italic, bool serif, bool fixedPitch, bool script = false)
Parameters
Returns
WithFamilyAliases(IReadOnlyDictionary<string, string[]>)
This catalog's faces, where a missing family is looked up as the families aliases maps it to, in order.
public SystemFontCatalog WithFamilyAliases(IReadOnlyDictionary<string, string[]> aliases)
Parameters
aliasesIReadOnlyDictionary<string, string[]>