• Articles
  • API Documentation
Search Results for

    Show / Hide Table of Contents
    • SixLabors.Fonts
      • ColorFontSupport
      • Font
      • FontCollection
      • FontCollectionExtensions
      • FontDescription
      • FontException
      • FontFamily
      • FontFamilyNotFoundException
      • FontMetrics
      • FontRectangle
      • FontStyle
      • Glyph
      • GlyphBounds
      • GlyphColor
      • GlyphLayoutMode
      • GlyphMetrics
      • GlyphMissingException
      • GlyphRendererParameters
      • GlyphType
      • HintingMode
      • HorizontalAlignment
      • HorizontalMetrics
      • IColorGlyphRenderer
      • IFontCollection
      • IGlyphRenderer
      • IGlyphRendererExtensions
      • IMetricsHeader
      • IReadOnlyFontCollection
      • IReadOnlySystemFontCollection
      • InvalidFontFileException
      • InvalidFontTableException
      • KerningMode
      • LayoutMode
      • LayoutModeExtensions
      • MissingFontTableException
      • SystemFonts
      • TextAlignment
      • TextAttributes
      • TextDecorations
      • TextDirection
      • TextJustification
      • TextMeasurer
      • TextOptions
      • TextRenderer
      • TextRun
      • VerticalAlignment
      • VerticalMetrics
      • WordBreaking
    • SixLabors.Fonts.Tables.AdvancedTypographic
      • FeatureTags
      • GlyphClassDef
      • Tag
    • SixLabors.Fonts.Tables.TrueType
      • TrueTypeGlyphMetrics
    • SixLabors.Fonts.Unicode
      • ArabicJoiningClass
      • ArabicJoiningGroup
      • ArabicJoiningType
      • BidiCharacterType
      • BidiClass
      • BidiPairedBracketType
      • CodePoint
      • GraphemeClusterClass
      • IndicPositionalCategory
      • IndicSyllabicCategory
      • LineBreakClass
      • MemoryExtensions
      • ScriptClass
      • SpanCodePointEnumerator
      • SpanGraphemeEnumerator
      • VerticalOrientationType
    • SixLabors.Fonts.WellKnownIds
      • KnownNameIds

    Class Font

    Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.

    Inheritance
    object
    Font
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: SixLabors.Fonts
    Assembly: SixLabors.Fonts.dll
    Syntax
    public sealed class Font

    Constructors

    | Edit this page View Source

    Font(Font, FontStyle)

    Initializes a new instance of the Font class.

    Declaration
    public Font(Font prototype, FontStyle style)
    Parameters
    Type Name Description
    Font prototype

    The prototype.

    FontStyle style

    The font style.

    | Edit this page View Source

    Font(Font, float)

    Initializes a new instance of the Font class.

    Declaration
    public Font(Font prototype, float size)
    Parameters
    Type Name Description
    Font prototype

    The prototype.

    float size

    The size of the font in PT units.

    | Edit this page View Source

    Font(Font, float, FontStyle)

    Initializes a new instance of the Font class.

    Declaration
    public Font(Font prototype, float size, FontStyle style)
    Parameters
    Type Name Description
    Font prototype

    The prototype.

    float size

    The size of the font in PT units.

    FontStyle style

    The font style.

    | Edit this page View Source

    Font(FontFamily, float)

    Initializes a new instance of the Font class.

    Declaration
    public Font(FontFamily family, float size)
    Parameters
    Type Name Description
    FontFamily family

    The font family.

    float size

    The size of the font in PT units.

    | Edit this page View Source

    Font(FontFamily, float, FontStyle)

    Initializes a new instance of the Font class.

    Declaration
    public Font(FontFamily family, float size, FontStyle style)
    Parameters
    Type Name Description
    FontFamily family

    The font family.

    float size

    The size of the font in PT units.

    FontStyle style

    The font style.

    Properties

    | Edit this page View Source

    Family

    Gets the family.

    Declaration
    public FontFamily Family { get; }
    Property Value
    Type Description
    FontFamily
    | Edit this page View Source

    FontMetrics

    Gets the font metrics.

    Declaration
    public FontMetrics FontMetrics { get; }
    Property Value
    Type Description
    FontMetrics
    Exceptions
    Type Condition
    FontException

    Font instance not found.

    | Edit this page View Source

    IsBold

    Gets a value indicating whether this Font is bold.

    Declaration
    public bool IsBold { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsItalic

    Gets a value indicating whether this Font is italic.

    Declaration
    public bool IsItalic { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Name

    Gets the name.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    Size

    Gets the size of the font in PT units.

    Declaration
    public float Size { get; }
    Property Value
    Type Description
    float

    Methods

    | Edit this page View Source

    TryGetGlyphs(CodePoint, ColorFontSupport, out IReadOnlyList<Glyph>?)

    Gets the glyphs for the given codepoint.

    Declaration
    public bool TryGetGlyphs(CodePoint codePoint, ColorFontSupport support, out IReadOnlyList<Glyph>? glyphs)
    Parameters
    Type Name Description
    CodePoint codePoint

    The code point of the character.

    ColorFontSupport support

    Options for enabling color font support during layout and rendering.

    IReadOnlyList<Glyph> glyphs

    When this method returns, contains the glyphs for the given codepoint and color support if the glyphs are found; otherwise the default value. This parameter is passed uninitialized.

    Returns
    Type Description
    bool

    true if the face contains glyphs for the specified codepoint; otherwise, false.

    | Edit this page View Source

    TryGetGlyphs(CodePoint, TextAttributes, ColorFontSupport, out IReadOnlyList<Glyph>?)

    Gets the glyphs for the given codepoint.

    Declaration
    public bool TryGetGlyphs(CodePoint codePoint, TextAttributes textAttributes, ColorFontSupport support, out IReadOnlyList<Glyph>? glyphs)
    Parameters
    Type Name Description
    CodePoint codePoint

    The code point of the character.

    TextAttributes textAttributes

    The text attributes to apply to the glyphs.

    ColorFontSupport support

    Options for enabling color font support during layout and rendering.

    IReadOnlyList<Glyph> glyphs

    When this method returns, contains the glyphs for the given codepoint, attributes, and color support if the glyphs are found; otherwise the default value. This parameter is passed uninitialized.

    Returns
    Type Description
    bool

    true if the face contains glyphs for the specified codepoint; otherwise, false.

    | Edit this page View Source

    TryGetGlyphs(CodePoint, TextAttributes, LayoutMode, ColorFontSupport, out IReadOnlyList<Glyph>?)

    Gets the glyphs for the given codepoint.

    Declaration
    public bool TryGetGlyphs(CodePoint codePoint, TextAttributes textAttributes, LayoutMode layoutMode, ColorFontSupport support, out IReadOnlyList<Glyph>? glyphs)
    Parameters
    Type Name Description
    CodePoint codePoint

    The code point of the character.

    TextAttributes textAttributes

    The text attributes to apply to the glyphs.

    LayoutMode layoutMode

    The layout mode to apply to the glyphs.

    ColorFontSupport support

    Options for enabling color font support during layout and rendering.

    IReadOnlyList<Glyph> glyphs

    When this method returns, contains the glyphs for the given codepoint, attributes, and color support if the glyphs are found; otherwise the default value. This parameter is passed uninitialized.

    Returns
    Type Description
    bool

    true if the face contains glyphs for the specified codepoint; otherwise, false.

    | Edit this page View Source

    TryGetGlyphs(CodePoint, TextAttributes, TextDecorations, LayoutMode, ColorFontSupport, out IReadOnlyList<Glyph>?)

    Gets the glyphs for the given codepoint.

    Declaration
    public bool TryGetGlyphs(CodePoint codePoint, TextAttributes textAttributes, TextDecorations textDecorations, LayoutMode layoutMode, ColorFontSupport support, out IReadOnlyList<Glyph>? glyphs)
    Parameters
    Type Name Description
    CodePoint codePoint

    The code point of the character.

    TextAttributes textAttributes

    The text attributes to apply to the glyphs.

    TextDecorations textDecorations

    The text decorations to apply to the glyphs.

    LayoutMode layoutMode

    The layout mode to apply to the glyphs.

    ColorFontSupport support

    Options for enabling color font support during layout and rendering.

    IReadOnlyList<Glyph> glyphs

    When this method returns, contains the glyphs for the given codepoint, attributes, and color support if the glyphs are found; otherwise the default value. This parameter is passed uninitialized.

    Returns
    Type Description
    bool

    true if the face contains glyphs for the specified codepoint; otherwise, false.

    | Edit this page View Source

    TryGetGlyphs(CodePoint, out IReadOnlyList<Glyph>?)

    Gets the glyphs for the given codepoint.

    Declaration
    public bool TryGetGlyphs(CodePoint codePoint, out IReadOnlyList<Glyph>? glyphs)
    Parameters
    Type Name Description
    CodePoint codePoint

    The code point of the character.

    IReadOnlyList<Glyph> glyphs

    When this method returns, contains the glyphs for the given codepoint if the glyphs are found; otherwise the default value. This parameter is passed uninitialized.

    Returns
    Type Description
    bool

    true if the face contains glyphs for the specified codepoint; otherwise, false.

    | Edit this page View Source

    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.

    Declaration
    public bool TryGetKerningOffset(Glyph current, Glyph next, float dpi, out Vector2 vector)
    Parameters
    Type Name Description
    Glyph current

    The current glyph.

    Glyph next

    The next glyph.

    float dpi

    The DPI (Dots Per Inch) to render/measure the kerning offset at.

    Vector2 vector

    When this method returns, contains the offset, in font units, that should be applied to the current glyph, if the offset is found; otherwise the default vector value. This parameter is passed uninitialized.

    Returns
    Type Description
    bool

    true if the face contains and offset for the glyph combination; otherwise, false.

    | Edit this page View Source

    TryGetPath(out string?)

    Gets the filesystem path to the font family source.

    Declaration
    public bool TryGetPath(out string? path)
    Parameters
    Type Name Description
    string path

    When 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.

    Returns
    Type Description
    bool

    true if the Font was created via a filesystem path; otherwise, false.

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX