BitmapFont

Inherits: Font < Resource < Reference < Object

Renders text using fonts under the BMFont format.

Handles files with the .fnt extension.

Description

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

Properties

float ascent 0.0
bool distance_field false
BitmapFont fallback
float height 1.0

Methods

void add_char ( int character, int texture, Rect2 rect, Vector2 align=Vector2( 0, 0 ), float advance=-1 )
void add_kerning_pair ( int char_a, int char_b, int kerning )
void add_texture ( Texture texture )
void clear ( )
Error create_from_fnt ( String path )
int get_kerning_pair ( int char_a, int char_b ) const
Texture get_texture ( int idx ) const
int get_texture_count ( ) const

Property Descriptions

float ascent

Default 0.0
Setter set_ascent(value)
Getter get_ascent()

Ascent (number of pixels above the baseline).

bool distance_field

Default false
Setter set_distance_field_hint(value)
Getter is_distance_field_hint()

If true, distance field hint is enabled.

BitmapFont fallback

Setter set_fallback(value)
Getter get_fallback()

The fallback font.

float height

Default 1.0
Setter set_height(value)
Getter get_height()

Total font height (ascent plus descent) in pixels.

Method Descriptions

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

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.

void add_kerning_pair ( int char_a, int char_b, 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.

void add_texture ( Texture texture )

Adds a texture to the BitmapFont.

void clear ( )

Clears all the font data and settings.

Error create_from_fnt ( String path )

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

int get_kerning_pair ( int char_a, int char_b ) const

Returns a kerning pair as a difference.

Texture get_texture ( int idx ) const

Returns the font atlas texture at index idx.

int get_texture_count ( ) const

Returns the number of textures in the BitmapFont atlas.

© 2014–2020 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
https://docs.godotengine.org/en/3.2/classes/class_bitmapfont.html