Class Font
Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.
public sealed class Font
- Inheritance
-
Font
- Inherited Members
Constructors
Font(Font, FontStyle)
Initializes a new instance of the Font class.
public Font(Font prototype, FontStyle style)
Parameters
Font(Font, params FontVariation[])
Initializes a new instance of the Font class with the specified variation axis settings.
public Font(Font prototype, params FontVariation[] variations)
Parameters
prototypeFontThe prototype font providing family, size, and style.
variationsFontVariation[]The variation axis settings to apply.
Font(Font, float)
Initializes a new instance of the Font class.
public Font(Font prototype, float size)
Parameters
Font(Font, float, FontStyle)
Initializes a new instance of the Font class.
public Font(Font prototype, float size, FontStyle style)
Parameters
prototypeFontThe prototype.
sizefloatThe size of the font in PT units.
styleFontStyleThe font style.
Font(FontFamily, float)
Initializes a new instance of the Font class.
public Font(FontFamily family, float size)
Parameters
familyFontFamilyThe font family.
sizefloatThe size of the font in PT units.
Font(FontFamily, float, FontStyle)
Initializes a new instance of the Font class.
public Font(FontFamily family, float size, FontStyle style)
Parameters
familyFontFamilyThe font family.
sizefloatThe size of the font in PT units.
styleFontStyleThe font style.
Properties
Family
Gets the family.
public FontFamily Family { get; }
Property Value
FontMetrics
Gets the font metrics.
public FontMetrics FontMetrics { get; }
Property Value
Exceptions
- FontException
Font instance not found.
IsBold
Gets a value indicating whether this Font is bold.
public bool IsBold { get; }
Property Value
IsItalic
Gets a value indicating whether this Font is italic.
public bool IsItalic { get; }
Property Value
Name
Gets the name.
public string Name { get; }
Property Value
Size
Gets the size of the font in PT units.
public float Size { get; }
Property Value
Variations
Gets the variation axis settings applied to this font.
public ReadOnlySpan<FontVariation> Variations { get; }
Property Value
Methods
TryGetGlyph(CodePoint, TextAttributes, LayoutMode, ColorFontSupport, out Glyph?)
Gets the glyph for the given codepoint.
public bool TryGetGlyph(CodePoint codePoint, TextAttributes textAttributes, LayoutMode layoutMode, ColorFontSupport support, out Glyph? glyph)
Parameters
codePointCodePointThe code point of the character.
textAttributesTextAttributesThe text attributes to apply to the glyphs.
layoutModeLayoutModeThe layout mode to apply to the glyphs.
supportColorFontSupportOptions for enabling color font support during layout and rendering.
glyphGlyph?When this method returns, contains the glyph for the given codepoint, attributes, and color support if the glyph is found; otherwise the default value. This parameter is passed uninitialized.
Returns
TryGetGlyph(CodePoint, TextAttributes, TextDecorations, LayoutMode, ColorFontSupport, out Glyph?)
Gets the glyph for the given codepoint.
public bool TryGetGlyph(CodePoint codePoint, TextAttributes textAttributes, TextDecorations textDecorations, LayoutMode layoutMode, ColorFontSupport support, out Glyph? glyph)
Parameters
codePointCodePointThe code point of the character.
textAttributesTextAttributesThe text attributes to apply to the glyphs.
textDecorationsTextDecorationsThe text decorations to apply to the glyphs.
layoutModeLayoutModeThe layout mode to apply to the glyphs.
supportColorFontSupportOptions for enabling color font support during layout and rendering.
glyphGlyph?When this method returns, contains the glyph for the given codepoint, attributes, and color support if the glyph is found; otherwise the default value. This parameter is passed uninitialized.
Returns
TryGetGlyphs(CodePoint, ColorFontSupport, out Glyph?)
Gets the glyph for the given codepoint.
public bool TryGetGlyphs(CodePoint codePoint, ColorFontSupport support, out Glyph? glyph)
Parameters
codePointCodePointThe code point of the character.
supportColorFontSupportOptions for enabling color font support during layout and rendering.
glyphGlyph?When this method returns, contains the glyphs for the given codepoint and color support if the glyph is found; otherwise the default value. This parameter is passed uninitialized.
Returns
TryGetGlyphs(CodePoint, TextAttributes, ColorFontSupport, out Glyph?)
Gets the glyph for the given codepoint.
public bool TryGetGlyphs(CodePoint codePoint, TextAttributes textAttributes, ColorFontSupport support, out Glyph? glyph)
Parameters
codePointCodePointThe code point of the character.
textAttributesTextAttributesThe text attributes to apply to the glyphs.
supportColorFontSupportOptions for enabling color font support during layout and rendering.
glyphGlyph?When this method returns, contains the glyph for the given codepoint, attributes, and color support if the glyph is found; otherwise the default value. This parameter is passed uninitialized.
Returns
TryGetGlyphs(CodePoint, out Glyph?)
Gets the glyph for the given codepoint.
public bool TryGetGlyphs(CodePoint codePoint, out Glyph? glyph)
Parameters
codePointCodePointThe code point of the character.
glyphGlyph?When this method returns, contains the glyph for the given codepoint if the glyph is found; otherwise the default value. This parameter is passed uninitialized.
Returns
TryGetKerningOffset(Glyph, Glyph, float, out Vector2)
Gets the amount, in px units, the current glyph should be offset if it is followed by
the next glyph.
public bool TryGetKerningOffset(Glyph current, Glyph next, float dpi, out Vector2 vector)
Parameters
currentGlyphThe current glyph.
nextGlyphThe next glyph.
dpifloatThe DPI (Dots Per Inch) to render/measure the kerning offset at.
vectorVector2When this method returns, contains the offset, in font units, that should be applied to the
currentglyph, if the offset is found; otherwise the default vector value. This parameter is passed uninitialized.
Returns
TryGetPath(out string?)
Gets the filesystem path to the font family source.
public bool TryGetPath(out string? path)
Parameters
pathstringWhen this method returns, contains the filesystem path to the font family source, if the path exists; otherwise, the default value for the type of the path parameter. This parameter is passed uninitialized.