Class GenericStashFont
Represents a font with additional abilities. GenericSpriteFont
public class GenericStashFont : GenericFont, IGenericDataHolder
- Inheritance
-
GenericStashFont
- Implements
- Inherited Members
Constructors
GenericStashFont(SpriteFontBase, SpriteFontBase, SpriteFontBase)
Creates a new generic font using FontStashSharp.SpriteFontBase. Optionally, a bold and italic version of the font can be supplied.
public GenericStashFont(SpriteFontBase font, SpriteFontBase bold = null, SpriteFontBase italic = null)
Parameters
fontSpriteFontBaseThe font to wrap
boldSpriteFontBaseA bold version of the font
italicSpriteFontBaseAn italic version of the font
Fields
Font
The FontStashSharp.SpriteFontBase that is being wrapped by this generic font
public readonly SpriteFontBase Font
Field Value
- SpriteFontBase
Properties
Bold
The bold version of this font.
public override GenericFont Bold { get; }
Property Value
CharacterSpacing
The character spacing that will be passed to the underlying Font.
public float CharacterSpacing { get; set; }
Property Value
Italic
The italic version of this font.
public override GenericFont Italic { get; }
Property Value
LineHeight
The height of each line of text of this font. This is the value that the text's draw position is offset by every time a newline character is reached.
public override float LineHeight { get; }
Property Value
LineSpacing
The line spacing that will be passed to the underlying Font.
public float LineSpacing { get; set; }
Property Value
Methods
DrawCharacter(SpriteBatch, int, string, Vector2, Color, float, Vector2, SpriteEffects, float)
Draws the given code point with the given data for use in DrawString(SpriteBatch, StringBuilder, Vector2, Color, float, Vector2, Vector2, SpriteEffects, float). Note that this method should only be called internally for rendering of more complex strings, like in TextFormatter Code implementations.
public override void DrawCharacter(SpriteBatch batch, int codePoint, string character, Vector2 position, Color color, float rotation, Vector2 scale, SpriteEffects effects, float layerDepth)
Parameters
batchSpriteBatchThe sprite batch to draw with.
codePointintThe code point which will be drawn.
characterstringA string representation of the character which will be drawn.
positionVector2The drawing location on screen.
colorColorA color mask.
rotationfloatA rotation of this character.
scaleVector2A scaling of this character.
effectsSpriteEffectsModificators for drawing. Can be combined.
layerDepthfloatA depth of the layer of this character.
MeasureCharacter(int)
Measures the width of the given code point with the default scale for use in MeasureString(string, bool). Note that this method does not support Nbsp, Zwsp and Emsp for most generic fonts, which is why MeasureString(string, bool) should be used even for single characters.
protected override float MeasureCharacter(int codePoint)
Parameters
codePointintThe code point whose width to calculate
Returns
- float
The width of the given character with the default scale