Skip to main content
Version: 1.0.0-preview.34

Velaptor.Content.Fonts.Font

Velaptor

Velaptor.Content.Fonts

Font Class

Represents a font with a set size and style that can be used to render text to the screen.

public sealed class Font :
Velaptor.Content.Fonts.IFont,
Velaptor.Content.IContent

Inheritance System.Object → Font

Implements IFont, IContent

Properties

Atlas

Gets the font atlas texture that contains all of the bitmap data for all available glyphs for the font.

public Velaptor.Content.ITexture Atlas { get; set; }

Implements Atlas

Property Value

ITexture

AvailableStylesForFamily

Gets a list of all the available font styles for the current font FamilyName.

public System.Collections.Generic.IEnumerable<Velaptor.Content.Fonts.FontStyle> AvailableStylesForFamily { get; }

Implements AvailableStylesForFamily

Property Value

System.Collections.Generic.IEnumerable<FontStyle>

CacheEnabled

Gets or sets a value indicating whether or not to cache the measurements of the text.

public bool CacheEnabled { get; set; }

Implements CacheEnabled

Property Value

System.Boolean

FamilyName

Gets the name of the font family.

public string FamilyName { get; }

Implements FamilyName

Property Value

System.String

FilePath

Gets the path to the content.

public string FilePath { get; }

Implements FilePath

Property Value

System.String

HasKerning

Gets a value indicating whether or not the font has kerning for text rendering layout.

public bool HasKerning { get; }

Implements HasKerning

Property Value

System.Boolean

IsDefaultFont

Gets a value indicating whether or not the font is a default font.

public bool IsDefaultFont { get; }

Implements IsDefaultFont

Property Value

System.Boolean

LineSpacing

Gets the spacing between lines of text in pixels.

public float LineSpacing { get; set; }

Implements LineSpacing

Property Value

System.Single

MaxCacheSize

Gets or sets the maximum number of measurements to cache.

public int MaxCacheSize { get; set; }

Implements MaxCacheSize

Property Value

System.Int32

Metrics

Gets the list of metrics for all of the glyphs supported by the font.

public System.Collections.Generic.IReadOnlyCollection<Velaptor.Graphics.GlyphMetrics> Metrics { get; }

Implements Metrics

Property Value

System.Collections.Generic.IReadOnlyCollection<GlyphMetrics>

Name

Gets the name of the content.

public string Name { get; }

Implements Name

Property Value

System.String

Size

Gets or sets the size of the font in points.

public uint Size { get; set; }

Implements Size

Property Value

System.UInt32

Source

Gets the source of where the font was loaded.

public Velaptor.Content.Fonts.FontSource Source { get; }

Implements Source

Property Value

FontSource

Style

Gets or sets the style of the font.

public Velaptor.Content.Fonts.FontStyle Style { get; set; }

Implements Style

Property Value

FontStyle

Methods

GetCharacterBounds(string, Vector2)

Returns the bounds of each character in the given text based on the
given textPos.

public System.Collections.Generic.IEnumerable<(char character,System.Drawing.RectangleF bounds)> GetCharacterBounds(string text, System.Numerics.Vector2 textPos);

Parameters

text System.String

The text to get the bounds data.

textPos System.Numerics.Vector2

The position of the text as a whole.

Implements GetCharacterBounds(string, Vector2)

Returns

System.Collections.Generic.IEnumerable<<System.Char,System.Drawing.RectangleF>>
The bounds for each character.

GetCharacterBounds(StringBuilder, Vector2)

Returns the bounds of each character in the given text based on the
given textPos.

public System.Collections.Generic.IEnumerable<(char character,System.Drawing.RectangleF bounds)> GetCharacterBounds(System.Text.StringBuilder text, System.Numerics.Vector2 textPos);

Parameters

text System.Text.StringBuilder

The text to get the bounds data.

textPos System.Numerics.Vector2

The position of the text as a whole.

Implements GetCharacterBounds(StringBuilder, Vector2)

Returns

System.Collections.Generic.IEnumerable<<System.Char,System.Drawing.RectangleF>>
The bounds for each character.

GetKerning(uint, uint)

Gets the kerning value between two glyphs.

public float GetKerning(uint leftGlyphIndex, uint rightGlyphIndex);

Parameters

leftGlyphIndex System.UInt32

The character index of the glyph to the left of the right glyph.

rightGlyphIndex System.UInt32

The character index of the glyph to the right of the left glyph.

Implements GetKerning(uint, uint)

Returns

System.Single
The kerning (horizontal spacing) between the glyphs.

Remarks

Refer to the URL below for more info.

https://freetype.org/freetype2/docs/glyphs/glyphs-4.html#section-1.

Measure(string)

Measures the width and height bounds of the given text.

public System.Drawing.SizeF Measure(string text);

Parameters

text System.String

The text to measure.

Implements Measure(string)

Returns

System.Drawing.SizeF
The width and height of the text in pixels.

ToGlyphMetrics(string)

Returns all of the glyph metrics for the given text.

public Velaptor.Graphics.GlyphMetrics[] ToGlyphMetrics(string text);

Parameters

text System.String

The text to convert to glyph metrics.

Implements ToGlyphMetrics(string)

Returns

GlyphMetrics[]
The list of glyph metrics of the given text.