SpriteFont

class SpriteFont : System.Object
readonly Texture2D Texture

Gets the texture that this SpriteFont draws from.

readonly System.Collections.ObjectModel.ReadOnlyCollection<Char> Characters

Gets a collection of the characters in the font.

System.Nullable<Char> DefaultCharacter

Gets or sets the character that will be substituted when a given character is not included in the font.

int LineSpacing

Gets or sets the line spacing (the distance from baseline to baseline) of the font.

float Spacing

Gets or sets the spacing (tracking) between characters in the font.

System.Collections.Generic.Dictionary<Char, Glyph> get_Glyphs()
public System.Collections.Generic.Dictionary<Char, Glyph> GetGlyphs()

Returns a copy of the dictionary containing the glyphs in this SpriteFont.

Returns:A new Dictionary containing all of the glyphs inthis SpriteFont
public Vector2 MeasureString(string text)

Returns the size of a string when rendered in this font.

Parameters:
  • text (string) – The text to measure.
Returns:
The size, in pixels, of ‘text’ when rendered in

this font.

public Vector2 MeasureString(System.Text.StringBuilder text)

Returns the size of the contents of a StringBuilder when rendered in this font.

Parameters:
  • text (System.Text.StringBuilder) – The text to measure.
Returns:
The size, in pixels, of ‘text’ when rendered in

this font.

void MeasureString(ref Microsoft.Xna.Framework.Graphics.CharacterSource text, ref Vector2 size)
Parameters:
  • (ref) text (Microsoft.Xna.Framework.Graphics.CharacterSource) –
  • (ref) size (Microsoft.Xna.Framework.Vector2) –