Velaptor.Content.Fonts.IFont
Velaptor
Velaptor.Content.Fonts
IFont Interface
The font to use when rendering 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
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
FamilyName
Gets the name of the font family.
string FamilyName { get; }
Property Value
HasKerning
Gets a value indicating whether the font has kerning for text rendering layout.
bool HasKerning { get; }
Property Value
IsDefaultFont
Gets a value indicating whether the font is a default font.
bool IsDefaultFont { get; }
Property Value
LineSpacing
Gets the spacing between lines of text in pixels.
float LineSpacing { get; }
Property Value
MaxCacheSize
Gets or sets the maximum number of measurements to cache.
int MaxCacheSize { get; set; }
Property Value
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 or sets the size of the font in points.
uint Size { get; set; }
Property Value
Source
Gets the source of where the font was loaded.
Velaptor.Content.Fonts.FontSource Source { get; }
Property Value
Style
Gets or sets the style of the font.
Velaptor.Content.Fonts.FontStyle Style { get; set; }
Property Value
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.