Files
godot-docs/classes/class_bitmapfont.rst
2019-01-07 10:14:12 +01:00

168 lines
10 KiB
ReStructuredText

.. Generated automatically by doc/tools/makerst.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/<name>/doc_classes.
.. _class_BitmapFont:
BitmapFont
==========
**Inherits:** :ref:`Font<class_Font>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
**Category:** Core
Brief Description
-----------------
Renders text using ``*.fnt`` fonts.
Properties
----------
+-------------------------------------+-----------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`ascent<class_BitmapFont_property_ascent>` |
+-------------------------------------+-----------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`distance_field<class_BitmapFont_property_distance_field>` |
+-------------------------------------+-----------------------------------------------------------------+
| :ref:`BitmapFont<class_BitmapFont>` | :ref:`fallback<class_BitmapFont_property_fallback>` |
+-------------------------------------+-----------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`height<class_BitmapFont_property_height>` |
+-------------------------------------+-----------------------------------------------------------------+
Methods
-------
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_char<class_BitmapFont_method_add_char>` **(** :ref:`int<class_int>` character, :ref:`int<class_int>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`Vector2<class_Vector2>` align=Vector2( 0, 0 ), :ref:`float<class_float>` advance=-1 **)** |
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_kerning_pair<class_BitmapFont_method_add_kerning_pair>` **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b, :ref:`int<class_int>` kerning **)** |
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_texture<class_BitmapFont_method_add_texture>` **(** :ref:`Texture<class_Texture>` texture **)** |
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_BitmapFont_method_clear>` **(** **)** |
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_from_fnt<class_BitmapFont_method_create_from_fnt>` **(** :ref:`String<class_String>` path **)** |
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`get_char_size<class_BitmapFont_method_get_char_size>` **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0 **)** const |
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_kerning_pair<class_BitmapFont_method_get_kerning_pair>` **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b **)** const |
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Texture<class_Texture>` | :ref:`get_texture<class_BitmapFont_method_get_texture>` **(** :ref:`int<class_int>` idx **)** const |
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_texture_count<class_BitmapFont_method_get_texture_count>` **(** **)** const |
+---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Description
-----------
Renders text using ``*.fnt`` fonts containing texture atlases. Supports distance fields. For using vector font files like TTF directly, see :ref:`DynamicFont<class_DynamicFont>`.
Property Descriptions
---------------------
.. _class_BitmapFont_property_ascent:
- :ref:`float<class_float>` **ascent**
+----------+-------------------+
| *Setter* | set_ascent(value) |
+----------+-------------------+
| *Getter* | get_ascent() |
+----------+-------------------+
Ascent (number of pixels above the baseline).
.. _class_BitmapFont_property_distance_field:
- :ref:`bool<class_bool>` **distance_field**
+----------+--------------------------------+
| *Setter* | set_distance_field_hint(value) |
+----------+--------------------------------+
| *Getter* | is_distance_field_hint() |
+----------+--------------------------------+
If ``true``, distance field hint is enabled.
.. _class_BitmapFont_property_fallback:
- :ref:`BitmapFont<class_BitmapFont>` **fallback**
+----------+---------------------+
| *Setter* | set_fallback(value) |
+----------+---------------------+
| *Getter* | get_fallback() |
+----------+---------------------+
The fallback font.
.. _class_BitmapFont_property_height:
- :ref:`float<class_float>` **height**
+----------+-------------------+
| *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<class_int>` character, :ref:`int<class_int>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`Vector2<class_Vector2>` align=Vector2( 0, 0 ), :ref:`float<class_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<class_int>` char_a, :ref:`int<class_int>` char_b, :ref:`int<class_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<class_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<enum_@GlobalScope_Error>` **create_from_fnt** **(** :ref:`String<class_String>` path **)**
Creates a BitmapFont from the ``*.fnt`` file at ``path``.
.. _class_BitmapFont_method_get_char_size:
- :ref:`Vector2<class_Vector2>` **get_char_size** **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0 **)** const
Returns the size of a character, optionally taking kerning into account if the next character is provided.
.. _class_BitmapFont_method_get_kerning_pair:
- :ref:`int<class_int>` **get_kerning_pair** **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b **)** const
Returns a kerning pair as a difference.
.. _class_BitmapFont_method_get_texture:
- :ref:`Texture<class_Texture>` **get_texture** **(** :ref:`int<class_int>` idx **)** const
Returns the font atlas texture at index ``idx``.
.. _class_BitmapFont_method_get_texture_count:
- :ref:`int<class_int>` **get_texture_count** **(** **)** const
Returns the number of textures in the BitmapFont atlas.