BitmapFont

    Category: Core

    Renders text using fonts.

    Properties

    void ( int character, texture, Rect2 rect, align=Vector2( 0, 0 ), float advance=-1 )
    void ( int char_a, char_b, int kerning )
    void ( Texture texture )
    void ( )
    Error ( String path )
    get_char_size ( char, int next=0 ) const
    get_kerning_pair ( char_a, int char_b ) const
    get_texture ( idx ) const
    int ( ) const

    Description

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

    • ascent

    Ascent (number of pixels above the baseline).


    • bool distance_field
    Setterset_distance_field_hint(value)
    Getteris_distance_field_hint()

    • fallback

    The fallback font.


    Setterset_height(value)
    Getterget_height()

    Total font height (ascent plus descent) in pixels.

    Method Descriptions

    • void add_char ( character, int texture, rect, Vector2 align=Vector2( 0, 0 ), advance=-1 )

    Adds a character to the font, where character is the unicode value, 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.


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


    • void add_texture ( Texture texture )

    • void clear ( )

    Clears all the font data and settings.


    • create_from_fnt ( String path )

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


    • get_char_size ( int char, next=0 ) const

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


    • int get_kerning_pair ( char_a, int char_b ) const

    Returns a kerning pair as a difference.



    • get_texture_count ( ) const

    Returns the number of textures in the BitmapFont atlas.