Renders text using *.fnt fonts.
    public class BitmapFont : Font

Renders text using *.fnt fonts containing texture atlases. Supports distance fields. For using vector font files like TTF directly, see DynamicFont.

Inheritance Chain


    public BitmapFont()


    public float Ascent { get; set; }

Ascent (number of pixels above the baseline).

    public int[] Chars { get; set; }

    public bool DistanceField { get; set; }

If true, distance field hint is enabled.

    public  Fallback { get; set; }

The fallback font.

    public float Height { get; set; }

Total font height (ascent plus descent) in pixels.

    public int[] Kernings { get; set; }

    public Collections.Array Textures { get; set; }


    public void AddChar(int character, int texture, Rect2 rect, Vector2? align = default(Vector2?), float advance = -1f)

Adds a character to the font, where character is the Unicode value, texture is the texture index, rect is the region in the texture (in pixels!), align is the (optional) alignment for the character and advance is the (optional) advance.

    public void AddKerningPair(int charA, int charB, int kerning)

Adds a kerning pair to the BitmapFont as a difference. Kerning pairs are special cases where a typeface advance is determined by the next character.

    public void AddTexture(Texture texture)

Adds a texture to the BitmapFont.

    public void Clear()

Clears all the font data and settings.

    public Error CreateFromFnt(string path)

Creates a BitmapFont from the *.fnt file at path.

    public Vector2 GetCharSize(int @char, int next = 0)

Returns the size of a character, optionally taking kerning into account if the next character is provided.

    [Obsolete("GetFallback is deprecated. Use the Fallback property instead.")]
    public BitmapFont GetFallback()

Getter for Fallback

    public int GetKerningPair(int charA, int charB)

Returns a kerning pair as a difference.

    public Texture GetTexture(int idx)

Returns the font atlas texture at index idx.

    public int GetTextureCount()

Returns the number of textures in the BitmapFont atlas.

    [Obsolete("SetAscent is deprecated. Use the Ascent property instead.")]
    public void SetAscent(float px)

Setter for Ascent

    [Obsolete("SetDistanceFieldHint is deprecated. Use the DistanceField property instead.")]
    public void SetDistanceFieldHint(bool enable)

Setter for DistanceField

    [Obsolete("SetFallback is deprecated. Use the Fallback property instead.")]
    public void SetFallback(BitmapFont fallback)

Setter for Fallback

    [Obsolete("SetHeight is deprecated. Use the Height property instead.")]
    public void SetHeight(float px)

Setter for Height