Class StaticSpriteFont
Represents a static sprite font.
public class StaticSpriteFont : SpriteFont, ISpanDrawableFont, IFont
- Inheritance
-
StaticSpriteFont
- Implements
- Inherited Members
- Extension Methods
Constructors
StaticSpriteFont(FontInfo, ITexture[], IReadOnlyDictionary<CodepointsPair, int>, IEnumerable<FontGlyph>, IFallbackFontResolver?, float)
Initializes a new instance of the StaticSpriteFont class.
public StaticSpriteFont(FontInfo info, ITexture[] atlas, IReadOnlyDictionary<StaticSpriteFont.CodepointsPair, int> kernings, IEnumerable<FontGlyph> glyphs, IFallbackFontResolver? resolver = null, float lineGap = 0)
Parameters
infoFontInfoInfo about created font.
atlasITexture[]Array of images for the glyph atlases.
kerningsIReadOnlyDictionary<StaticSpriteFont.CodepointsPair, int>Map of kernings for all the defined pairs.
glyphsIEnumerable<FontGlyph>List of all the glyphs used in the font.
resolverIFallbackFontResolverAn instance of the service that helps with getting glyphs that are not presented in this font.
lineGapfloatRecommended spacing between two lines of text.
Properties
EnableKernings
Gets or sets a value indicating whether to use kernings in measuring.
public bool EnableKernings { get; set; }
Property Value
Methods
GetGlyph(int)
Gets the glyph for the specified character codepoint.
public override FontGlyph GetGlyph(int codepoint)
Parameters
codepointintCodepoint to get glyph for.
Returns
- FontGlyph
Glyph info to use with this font.
Remarks
If the requested codepoint is not found in the font, this method will attempt to return the glyph for DefaultCodepoint. If that also fails, it returns None.
GetKerning(FontGlyph, FontGlyph)
Gets the kerning between two glyphs.
protected override float GetKerning(FontGlyph current, FontGlyph previous)
Parameters
Returns
- float
Kerning value in pixels.
Remarks
Kerning adjusts the spacing between specific pairs of glyphs to improve visual appearance. For example, in "VA", the 'A' might be moved slightly left to tuck under the 'V'.
SupportsCharacter(int)
Checks if a font supports specified codepoint instance.
public override bool SupportsCharacter(int codepoint)
Parameters
codepointintThe Unicode codepoint for the character to use.