:github_url: hide .. Generated automatically by doc/tools/make_rst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the BitmapFont.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_BitmapFont: BitmapFont ========== **Inherits:** :ref:`Font` **<** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`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 :ref:`DynamicFont`. Properties ---------- +-------------------------------------+-----------------------------------------------------------------+-----------+ | :ref:`float` | :ref:`ascent` | ``0.0`` | +-------------------------------------+-----------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`distance_field` | ``false`` | +-------------------------------------+-----------------------------------------------------------------+-----------+ | :ref:`BitmapFont` | :ref:`fallback` | | +-------------------------------------+-----------------------------------------------------------------+-----------+ | :ref:`float` | :ref:`height` | ``1.0`` | +-------------------------------------+-----------------------------------------------------------------+-----------+ Methods ------- +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_char` **(** :ref:`int` character, :ref:`int` texture, :ref:`Rect2` rect, :ref:`Vector2` align=Vector2( 0, 0 ), :ref:`float` advance=-1 **)** | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_kerning_pair` **(** :ref:`int` char_a, :ref:`int` char_b, :ref:`int` kerning **)** | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_texture` **(** :ref:`Texture` texture **)** | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`create_from_fnt` **(** :ref:`String` path **)** | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_kerning_pair` **(** :ref:`int` char_a, :ref:`int` char_b **)** |const| | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Texture` | :ref:`get_texture` **(** :ref:`int` idx **)** |const| | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_texture_count` **(** **)** |const| | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Property Descriptions --------------------- .. _class_BitmapFont_property_ascent: - :ref:`float` **ascent** +-----------+-------------------+ | *Default* | ``0.0`` | +-----------+-------------------+ | *Setter* | set_ascent(value) | +-----------+-------------------+ | *Getter* | get_ascent() | +-----------+-------------------+ Ascent (number of pixels above the baseline). ---- .. _class_BitmapFont_property_distance_field: - :ref:`bool` **distance_field** +-----------+--------------------------------+ | *Default* | ``false`` | +-----------+--------------------------------+ | *Setter* | set_distance_field_hint(value) | +-----------+--------------------------------+ | *Getter* | is_distance_field_hint() | +-----------+--------------------------------+ If ``true``, distance field hint is enabled. ---- .. _class_BitmapFont_property_fallback: - :ref:`BitmapFont` **fallback** +----------+---------------------+ | *Setter* | set_fallback(value) | +----------+---------------------+ | *Getter* | get_fallback() | +----------+---------------------+ The fallback font. ---- .. _class_BitmapFont_property_height: - :ref:`float` **height** +-----------+-------------------+ | *Default* | ``1.0`` | +-----------+-------------------+ | *Setter* | set_height(value) | +-----------+-------------------+ | *Getter* | get_height() | +-----------+-------------------+ Total font height (ascent plus descent) in pixels. Method Descriptions ------------------- .. _class_BitmapFont_method_add_char: - void **add_char** **(** :ref:`int` character, :ref:`int` texture, :ref:`Rect2` rect, :ref:`Vector2` align=Vector2( 0, 0 ), :ref:`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. ---- .. _class_BitmapFont_method_add_kerning_pair: - void **add_kerning_pair** **(** :ref:`int` char_a, :ref:`int` char_b, :ref:`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. ---- .. _class_BitmapFont_method_add_texture: - void **add_texture** **(** :ref:`Texture` texture **)** Adds a texture to the ``BitmapFont``. ---- .. _class_BitmapFont_method_clear: - void **clear** **(** **)** Clears all the font data and settings. ---- .. _class_BitmapFont_method_create_from_fnt: - :ref:`Error` **create_from_fnt** **(** :ref:`String` path **)** Creates a BitmapFont from the ``*.fnt`` file at ``path``. ---- .. _class_BitmapFont_method_get_kerning_pair: - :ref:`int` **get_kerning_pair** **(** :ref:`int` char_a, :ref:`int` char_b **)** |const| Returns a kerning pair as a difference. ---- .. _class_BitmapFont_method_get_texture: - :ref:`Texture` **get_texture** **(** :ref:`int` idx **)** |const| Returns the font atlas texture at index ``idx``. ---- .. _class_BitmapFont_method_get_texture_count: - :ref:`int` **get_texture_count** **(** **)** |const| Returns the number of textures in the BitmapFont atlas. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`