class_bitmapfont.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the BitmapFont.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_BitmapFont:
  6. BitmapFont
  7. ==========
  8. **Inherits:** :ref:`Font<class_Font>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. Renders text using fonts under the `BMFont <https://www.angelcode.com/products/bmfont/>`__ format.
  10. Handles files with the ``.fnt`` extension.
  11. Description
  12. -----------
  13. Renders text using ``*.fnt`` fonts containing texture atlases. Supports distance fields. For using vector font files like TTF directly, see :ref:`DynamicFont<class_DynamicFont>`.
  14. Properties
  15. ----------
  16. +-------------------------------------+-----------------------------------------------------------------+-----------+
  17. | :ref:`float<class_float>` | :ref:`ascent<class_BitmapFont_property_ascent>` | ``0.0`` |
  18. +-------------------------------------+-----------------------------------------------------------------+-----------+
  19. | :ref:`bool<class_bool>` | :ref:`distance_field<class_BitmapFont_property_distance_field>` | ``false`` |
  20. +-------------------------------------+-----------------------------------------------------------------+-----------+
  21. | :ref:`BitmapFont<class_BitmapFont>` | :ref:`fallback<class_BitmapFont_property_fallback>` | |
  22. +-------------------------------------+-----------------------------------------------------------------+-----------+
  23. | :ref:`float<class_float>` | :ref:`height<class_BitmapFont_property_height>` | ``1.0`` |
  24. +-------------------------------------+-----------------------------------------------------------------+-----------+
  25. Methods
  26. -------
  27. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | 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 **)** |
  29. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | 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 **)** |
  31. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`add_texture<class_BitmapFont_method_add_texture>` **(** :ref:`Texture<class_Texture>` texture **)** |
  33. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`clear<class_BitmapFont_method_clear>` **(** **)** |
  35. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_from_fnt<class_BitmapFont_method_create_from_fnt>` **(** :ref:`String<class_String>` path **)** |
  37. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :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| |
  39. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Texture<class_Texture>` | :ref:`get_texture<class_BitmapFont_method_get_texture>` **(** :ref:`int<class_int>` idx **)** |const| |
  41. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_texture_count<class_BitmapFont_method_get_texture_count>` **(** **)** |const| |
  43. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. Property Descriptions
  45. ---------------------
  46. .. _class_BitmapFont_property_ascent:
  47. - :ref:`float<class_float>` **ascent**
  48. +-----------+-------------------+
  49. | *Default* | ``0.0`` |
  50. +-----------+-------------------+
  51. | *Setter* | set_ascent(value) |
  52. +-----------+-------------------+
  53. | *Getter* | get_ascent() |
  54. +-----------+-------------------+
  55. Ascent (number of pixels above the baseline).
  56. ----
  57. .. _class_BitmapFont_property_distance_field:
  58. - :ref:`bool<class_bool>` **distance_field**
  59. +-----------+--------------------------------+
  60. | *Default* | ``false`` |
  61. +-----------+--------------------------------+
  62. | *Setter* | set_distance_field_hint(value) |
  63. +-----------+--------------------------------+
  64. | *Getter* | is_distance_field_hint() |
  65. +-----------+--------------------------------+
  66. If ``true``, distance field hint is enabled.
  67. ----
  68. .. _class_BitmapFont_property_fallback:
  69. - :ref:`BitmapFont<class_BitmapFont>` **fallback**
  70. +----------+---------------------+
  71. | *Setter* | set_fallback(value) |
  72. +----------+---------------------+
  73. | *Getter* | get_fallback() |
  74. +----------+---------------------+
  75. The fallback font.
  76. ----
  77. .. _class_BitmapFont_property_height:
  78. - :ref:`float<class_float>` **height**
  79. +-----------+-------------------+
  80. | *Default* | ``1.0`` |
  81. +-----------+-------------------+
  82. | *Setter* | set_height(value) |
  83. +-----------+-------------------+
  84. | *Getter* | get_height() |
  85. +-----------+-------------------+
  86. Total font height (ascent plus descent) in pixels.
  87. Method Descriptions
  88. -------------------
  89. .. _class_BitmapFont_method_add_char:
  90. - 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 **)**
  91. 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.
  92. ----
  93. .. _class_BitmapFont_method_add_kerning_pair:
  94. - void **add_kerning_pair** **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b, :ref:`int<class_int>` kerning **)**
  95. 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.
  96. ----
  97. .. _class_BitmapFont_method_add_texture:
  98. - void **add_texture** **(** :ref:`Texture<class_Texture>` texture **)**
  99. Adds a texture to the ``BitmapFont``.
  100. ----
  101. .. _class_BitmapFont_method_clear:
  102. - void **clear** **(** **)**
  103. Clears all the font data and settings.
  104. ----
  105. .. _class_BitmapFont_method_create_from_fnt:
  106. - :ref:`Error<enum_@GlobalScope_Error>` **create_from_fnt** **(** :ref:`String<class_String>` path **)**
  107. Creates a BitmapFont from the ``*.fnt`` file at ``path``.
  108. ----
  109. .. _class_BitmapFont_method_get_kerning_pair:
  110. - :ref:`int<class_int>` **get_kerning_pair** **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b **)** |const|
  111. Returns a kerning pair as a difference.
  112. ----
  113. .. _class_BitmapFont_method_get_texture:
  114. - :ref:`Texture<class_Texture>` **get_texture** **(** :ref:`int<class_int>` idx **)** |const|
  115. Returns the font atlas texture at index ``idx``.
  116. ----
  117. .. _class_BitmapFont_method_get_texture_count:
  118. - :ref:`int<class_int>` **get_texture_count** **(** **)** |const|
  119. Returns the number of textures in the BitmapFont atlas.
  120. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  121. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  122. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`