Class FontFamily
The faces of one family in a FontCollection, matched by style.
public sealed class FontFamily
- Inheritance
-
FontFamily
- Inherited Members
Examples
// Installed fonts, found without native calls and indexed on first use; a style is matched by the CSS rules.
FontMatch? match = FontCollection.System.Match(GenericFamily.SansSerif, FontStyle.Bold);
// Your own fonts work the same way; System is read-only, so add the installed fonts to your collection to have both.
var fonts = new FontCollection();
fonts.AddFile(FontFile);
fonts.AddSystemFonts();
FontMatch noto = fonts.Match("Noto Sans", FontStyle.BoldItalic)!.Value;
Font font = noto.ToFont(16);
Properties
Faces
Gets the faces, loading every one that is not loaded yet.
public IReadOnlyList<Typeface> Faces { get; }
Property Value
Name
Gets the family's English name.
public string Name { get; }
Property Value
Styles
Gets the styles of the family's faces, without loading them.
public IReadOnlyList<FontStyle> Styles { get; }
Property Value
Methods
Match(FontStyle)
Returns the face that best matches a style by the CSS Fonts Level 4 steps (nearest width, then slant, then weight), and the bold or italic it lacks. Only the matched face is loaded. A variable face whose weight, width and slant or italic axes cover the request matches it exactly and comes back at that position; its named instances are matched as faces of their own.
public FontMatch Match(FontStyle style)
Parameters
styleFontStyleThe style wanted.
Returns
- FontMatch
The face and its synthesis, wanted only when no face or axis range reaches the request.
ToString()
Returns the family's name.
public override string ToString()
Returns
- string
The name.