class_bitmapfont.rst 12 KB

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