class_bitmapfont.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the BitmapFont.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_BitmapFont:
  5. BitmapFont
  6. ==========
  7. **Inherits:** :ref:`Font<class_Font>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Renders text using ``*.fnt`` fonts.
  12. Properties
  13. ----------
  14. +-------------------------------------+--------------------------------------------------------+
  15. | :ref:`float<class_float>` | :ref:`ascent<class_BitmapFont_ascent>` |
  16. +-------------------------------------+--------------------------------------------------------+
  17. | :ref:`bool<class_bool>` | :ref:`distance_field<class_BitmapFont_distance_field>` |
  18. +-------------------------------------+--------------------------------------------------------+
  19. | :ref:`BitmapFont<class_BitmapFont>` | :ref:`fallback<class_BitmapFont_fallback>` |
  20. +-------------------------------------+--------------------------------------------------------+
  21. | :ref:`float<class_float>` | :ref:`height<class_BitmapFont_height>` |
  22. +-------------------------------------+--------------------------------------------------------+
  23. Methods
  24. -------
  25. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`add_char<class_BitmapFont_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 **)** |
  27. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`add_kerning_pair<class_BitmapFont_add_kerning_pair>` **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b, :ref:`int<class_int>` kerning **)** |
  29. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`add_texture<class_BitmapFont_add_texture>` **(** :ref:`Texture<class_Texture>` texture **)** |
  31. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`clear<class_BitmapFont_clear>` **(** **)** |
  33. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_from_fnt<class_BitmapFont_create_from_fnt>` **(** :ref:`String<class_String>` path **)** |
  35. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Vector2<class_Vector2>` | :ref:`get_char_size<class_BitmapFont_get_char_size>` **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0 **)** const |
  37. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_kerning_pair<class_BitmapFont_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_get_texture>` **(** :ref:`int<class_int>` idx **)** const |
  41. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_texture_count<class_BitmapFont_get_texture_count>` **(** **)** const |
  43. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. Description
  45. -----------
  46. Renders text using ``*.fnt`` fonts containing texture atlases. Supports distance fields. For using vector font files like TTF directly, see :ref:`DynamicFont<class_DynamicFont>`.
  47. Property Descriptions
  48. ---------------------
  49. .. _class_BitmapFont_ascent:
  50. - :ref:`float<class_float>` **ascent**
  51. +----------+-------------------+
  52. | *Setter* | set_ascent(value) |
  53. +----------+-------------------+
  54. | *Getter* | get_ascent() |
  55. +----------+-------------------+
  56. Ascent (number of pixels above the baseline).
  57. .. _class_BitmapFont_distance_field:
  58. - :ref:`bool<class_bool>` **distance_field**
  59. +----------+--------------------------------+
  60. | *Setter* | set_distance_field_hint(value) |
  61. +----------+--------------------------------+
  62. | *Getter* | is_distance_field_hint() |
  63. +----------+--------------------------------+
  64. If ``true`` distance field hint is enabled.
  65. .. _class_BitmapFont_fallback:
  66. - :ref:`BitmapFont<class_BitmapFont>` **fallback**
  67. +----------+---------------------+
  68. | *Setter* | set_fallback(value) |
  69. +----------+---------------------+
  70. | *Getter* | get_fallback() |
  71. +----------+---------------------+
  72. The fallback font.
  73. .. _class_BitmapFont_height:
  74. - :ref:`float<class_float>` **height**
  75. +----------+-------------------+
  76. | *Setter* | set_height(value) |
  77. +----------+-------------------+
  78. | *Getter* | get_height() |
  79. +----------+-------------------+
  80. Total font height (ascent plus descent) in pixels.
  81. Method Descriptions
  82. -------------------
  83. .. _class_BitmapFont_add_char:
  84. - 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 **)**
  85. 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.
  86. .. _class_BitmapFont_add_kerning_pair:
  87. - void **add_kerning_pair** **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b, :ref:`int<class_int>` kerning **)**
  88. 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.
  89. .. _class_BitmapFont_add_texture:
  90. - void **add_texture** **(** :ref:`Texture<class_Texture>` texture **)**
  91. Adds a texture to the ``BitmapFont``.
  92. .. _class_BitmapFont_clear:
  93. - void **clear** **(** **)**
  94. Clears all the font data and settings.
  95. .. _class_BitmapFont_create_from_fnt:
  96. - :ref:`Error<enum_@GlobalScope_Error>` **create_from_fnt** **(** :ref:`String<class_String>` path **)**
  97. Creates a BitmapFont from the ``*.fnt`` file at ``path``.
  98. .. _class_BitmapFont_get_char_size:
  99. - :ref:`Vector2<class_Vector2>` **get_char_size** **(** :ref:`int<class_int>` char, :ref:`int<class_int>` next=0 **)** const
  100. Returns the size of a character, optionally taking kerning into account if the next character is provided.
  101. .. _class_BitmapFont_get_kerning_pair:
  102. - :ref:`int<class_int>` **get_kerning_pair** **(** :ref:`int<class_int>` char_a, :ref:`int<class_int>` char_b **)** const
  103. Returns a kerning pair as a difference.
  104. .. _class_BitmapFont_get_texture:
  105. - :ref:`Texture<class_Texture>` **get_texture** **(** :ref:`int<class_int>` idx **)** const
  106. Returns the font atlas texture at index ``idx``.
  107. .. _class_BitmapFont_get_texture_count:
  108. - :ref:`int<class_int>` **get_texture_count** **(** **)** const
  109. Returns the number of textures in the BitmapFont atlas.