Skip to main content
Version: 1.0.0-preview.47

Velaptor.Content.Fonts.IFont

Velaptor​

Velaptor.Content.Fonts​

IFont Interface​

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

public interface IFont : Velaptor.Content.IContent

Derived
↳ Font

Implements IContent

Properties​

Atlas​

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

Velaptor.Content.ITexture Atlas { get; }

Property Value​

ITexture

AvailableStylesForFamily​

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

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

Property Value​

System.Collections.Generic.IEnumerable<FontStyle>

CacheEnabled​

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

bool CacheEnabled { get; set; }

Property Value​

System.Boolean

CurrentMeasureCacheSize​

Gets the total number of text size measurements that are cached.

int CurrentMeasureCacheSize { get; }

Property Value​

System.Int32

FamilyName​

Gets the name of the font family.

string FamilyName { get; }

Property Value​

System.String

HasKerning​

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

bool HasKerning { get; }

Property Value​

System.Boolean

IsDefaultFont​

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

bool IsDefaultFont { get; }

Property Value​

System.Boolean

LineSpacing​

Gets the spacing between lines of text in pixels.

float LineSpacing { get; }

Property Value​

System.Single

MaxMeasureCacheSize​

Gets or sets the maximum number of text measurements to cache.

int MaxMeasureCacheSize { get; set; }

Property Value​

System.Int32

Metrics​

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

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

Property Value​

System.Collections.Generic.IReadOnlyCollection<GlyphMetrics>

Size​

Gets the size of the font in points.

uint Size { get; }

Property Value​

System.UInt32

Source​

Gets the source of where the font was loaded.

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

Property Value​

FontSource

Style​

Gets the style of the font.

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

Property Value​

FontStyle

Methods​

GetCharacterBounds(string, Vector2)​

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

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.

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.

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.

Returns​

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

GetKerning(uint, uint)​

Gets the kerning between two glyphs using the given leftGlyphIndex and rightGlyphIndex.

float GetKerning(uint leftGlyphIndex, uint rightGlyphIndex);

Parameters​

leftGlyphIndex System.UInt32

The index of the left glyph.

rightGlyphIndex System.UInt32

The index of the right glyph.

Returns​

System.Single
The kerning result between the glyphs.

Remarks​

Refer to https://freetype\.org/freetype2/docs/glyphs/glyphs\-4\.html for more info.

Measure(string)​

Measures the width and height bounds of the given text.

System.Drawing.SizeF Measure(string text);

Parameters​

text System.String

The text to measure.

Returns​

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

ToGlyphMetrics(string)​

Gets the glyph metrics using the given text.

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

Parameters​

text System.String

The text to get the metrics for.

Returns​

GlyphMetrics[]
The metrics of each individual glyph/character.