Struct FontMatch
A matched face and the styling it lacks, from Match(FontStyle).
public readonly record struct FontMatch : IEquatable<FontMatch>
- Implements
- 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);
Constructors
FontMatch(Typeface, FontSynthesis)
A matched face and the styling it lacks, from Match(FontStyle).
public FontMatch(Typeface Typeface, FontSynthesis Synthesis)
Parameters
TypefaceTypefaceThe face.
SynthesisFontSynthesisThe bold or italic the face lacks compared with the style asked for.
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
Synthesis
The bold or italic the face lacks compared with the style asked for.
public FontSynthesis Synthesis { get; init; }
Property Value
Typeface
The face.
public Typeface Typeface { get; init; }
Property Value
Methods
ToFont(float)
Returns the matched face at a size, carrying the synthesis.
public Font ToFont(float size)
Parameters
sizefloatThe em size in canvas units.
Returns
- Font
The font.