class_dynamicfont.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the DynamicFont.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_DynamicFont:
  5. DynamicFont
  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. DynamicFont renders vector font files at runtime.
  12. Properties
  13. ----------
  14. +-----------------------------------------------+------------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`extra_spacing_bottom<class_DynamicFont_property_extra_spacing_bottom>` |
  16. +-----------------------------------------------+------------------------------------------------------------------------------+
  17. | :ref:`int<class_int>` | :ref:`extra_spacing_char<class_DynamicFont_property_extra_spacing_char>` |
  18. +-----------------------------------------------+------------------------------------------------------------------------------+
  19. | :ref:`int<class_int>` | :ref:`extra_spacing_space<class_DynamicFont_property_extra_spacing_space>` |
  20. +-----------------------------------------------+------------------------------------------------------------------------------+
  21. | :ref:`int<class_int>` | :ref:`extra_spacing_top<class_DynamicFont_property_extra_spacing_top>` |
  22. +-----------------------------------------------+------------------------------------------------------------------------------+
  23. | :ref:`DynamicFontData<class_DynamicFontData>` | :ref:`font_data<class_DynamicFont_property_font_data>` |
  24. +-----------------------------------------------+------------------------------------------------------------------------------+
  25. | :ref:`Color<class_Color>` | :ref:`outline_color<class_DynamicFont_property_outline_color>` |
  26. +-----------------------------------------------+------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`outline_size<class_DynamicFont_property_outline_size>` |
  28. +-----------------------------------------------+------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`size<class_DynamicFont_property_size>` |
  30. +-----------------------------------------------+------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`use_filter<class_DynamicFont_property_use_filter>` |
  32. +-----------------------------------------------+------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`use_mipmaps<class_DynamicFont_property_use_mipmaps>` |
  34. +-----------------------------------------------+------------------------------------------------------------------------------+
  35. Methods
  36. -------
  37. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`add_fallback<class_DynamicFont_method_add_fallback>` **(** :ref:`DynamicFontData<class_DynamicFontData>` data **)** |
  39. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`DynamicFontData<class_DynamicFontData>` | :ref:`get_fallback<class_DynamicFont_method_get_fallback>` **(** :ref:`int<class_int>` idx **)** const |
  41. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_fallback_count<class_DynamicFont_method_get_fallback_count>` **(** **)** const |
  43. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`remove_fallback<class_DynamicFont_method_remove_fallback>` **(** :ref:`int<class_int>` idx **)** |
  45. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_fallback<class_DynamicFont_method_set_fallback>` **(** :ref:`int<class_int>` idx, :ref:`DynamicFontData<class_DynamicFontData>` data **)** |
  47. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. Enumerations
  49. ------------
  50. .. _enum_DynamicFont_SpacingType:
  51. .. _class_DynamicFont_constant_SPACING_TOP:
  52. .. _class_DynamicFont_constant_SPACING_BOTTOM:
  53. .. _class_DynamicFont_constant_SPACING_CHAR:
  54. .. _class_DynamicFont_constant_SPACING_SPACE:
  55. enum **SpacingType**:
  56. - **SPACING_TOP** = **0** --- Spacing at the top.
  57. - **SPACING_BOTTOM** = **1** --- Spacing at the bottom.
  58. - **SPACING_CHAR** = **2** --- Character spacing.
  59. - **SPACING_SPACE** = **3** --- Space spacing.
  60. Description
  61. -----------
  62. DynamicFont renders vector font files (such as TTF or OTF) dynamically at runtime instead of using a prerendered texture atlas like :ref:`BitmapFont<class_BitmapFont>`. This trades the faster loading time of :ref:`BitmapFont<class_BitmapFont>`\ s for the ability to change font parameters like size and spacing during runtime. :ref:`DynamicFontData<class_DynamicFontData>` is used for referencing the font file paths.
  63. ::
  64. var dynamic_font = DynamicFont.new()
  65. dynamic_font.font_data = load("res://BarlowCondensed-Bold.ttf")
  66. dynamic_font.size = 64
  67. $"Label".set("custom_fonts/font", dynamic_font)
  68. Property Descriptions
  69. ---------------------
  70. .. _class_DynamicFont_property_extra_spacing_bottom:
  71. - :ref:`int<class_int>` **extra_spacing_bottom**
  72. +----------+--------------------+
  73. | *Setter* | set_spacing(value) |
  74. +----------+--------------------+
  75. | *Getter* | get_spacing() |
  76. +----------+--------------------+
  77. Extra spacing at the bottom in pixels.
  78. .. _class_DynamicFont_property_extra_spacing_char:
  79. - :ref:`int<class_int>` **extra_spacing_char**
  80. +----------+--------------------+
  81. | *Setter* | set_spacing(value) |
  82. +----------+--------------------+
  83. | *Getter* | get_spacing() |
  84. +----------+--------------------+
  85. Extra character spacing in pixels.
  86. .. _class_DynamicFont_property_extra_spacing_space:
  87. - :ref:`int<class_int>` **extra_spacing_space**
  88. +----------+--------------------+
  89. | *Setter* | set_spacing(value) |
  90. +----------+--------------------+
  91. | *Getter* | get_spacing() |
  92. +----------+--------------------+
  93. Extra space spacing in pixels.
  94. .. _class_DynamicFont_property_extra_spacing_top:
  95. - :ref:`int<class_int>` **extra_spacing_top**
  96. +----------+--------------------+
  97. | *Setter* | set_spacing(value) |
  98. +----------+--------------------+
  99. | *Getter* | get_spacing() |
  100. +----------+--------------------+
  101. Extra spacing at the top in pixels.
  102. .. _class_DynamicFont_property_font_data:
  103. - :ref:`DynamicFontData<class_DynamicFontData>` **font_data**
  104. +----------+----------------------+
  105. | *Setter* | set_font_data(value) |
  106. +----------+----------------------+
  107. | *Getter* | get_font_data() |
  108. +----------+----------------------+
  109. The font data.
  110. .. _class_DynamicFont_property_outline_color:
  111. - :ref:`Color<class_Color>` **outline_color**
  112. +----------+--------------------------+
  113. | *Setter* | set_outline_color(value) |
  114. +----------+--------------------------+
  115. | *Getter* | get_outline_color() |
  116. +----------+--------------------------+
  117. .. _class_DynamicFont_property_outline_size:
  118. - :ref:`int<class_int>` **outline_size**
  119. +----------+-------------------------+
  120. | *Setter* | set_outline_size(value) |
  121. +----------+-------------------------+
  122. | *Getter* | get_outline_size() |
  123. +----------+-------------------------+
  124. .. _class_DynamicFont_property_size:
  125. - :ref:`int<class_int>` **size**
  126. +----------+-----------------+
  127. | *Setter* | set_size(value) |
  128. +----------+-----------------+
  129. | *Getter* | get_size() |
  130. +----------+-----------------+
  131. The font size.
  132. .. _class_DynamicFont_property_use_filter:
  133. - :ref:`bool<class_bool>` **use_filter**
  134. +----------+-----------------------+
  135. | *Setter* | set_use_filter(value) |
  136. +----------+-----------------------+
  137. | *Getter* | get_use_filter() |
  138. +----------+-----------------------+
  139. If ``true``, filtering is used.
  140. .. _class_DynamicFont_property_use_mipmaps:
  141. - :ref:`bool<class_bool>` **use_mipmaps**
  142. +----------+------------------------+
  143. | *Setter* | set_use_mipmaps(value) |
  144. +----------+------------------------+
  145. | *Getter* | get_use_mipmaps() |
  146. +----------+------------------------+
  147. If ``true``, mipmapping is used.
  148. Method Descriptions
  149. -------------------
  150. .. _class_DynamicFont_method_add_fallback:
  151. - void **add_fallback** **(** :ref:`DynamicFontData<class_DynamicFontData>` data **)**
  152. Adds a fallback font.
  153. .. _class_DynamicFont_method_get_fallback:
  154. - :ref:`DynamicFontData<class_DynamicFontData>` **get_fallback** **(** :ref:`int<class_int>` idx **)** const
  155. Returns the fallback font at index ``idx``.
  156. .. _class_DynamicFont_method_get_fallback_count:
  157. - :ref:`int<class_int>` **get_fallback_count** **(** **)** const
  158. Returns the number of fallback fonts.
  159. .. _class_DynamicFont_method_remove_fallback:
  160. - void **remove_fallback** **(** :ref:`int<class_int>` idx **)**
  161. Removes the fallback font at index ``idx``.
  162. .. _class_DynamicFont_method_set_fallback:
  163. - void **set_fallback** **(** :ref:`int<class_int>` idx, :ref:`DynamicFontData<class_DynamicFontData>` data **)**
  164. Sets the fallback font at index ``idx``.