class_fontvariation.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/FontVariation.xml.
  6. .. _class_FontVariation:
  7. FontVariation
  8. =============
  9. **Inherits:** :ref:`Font<class_Font>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Variation of the :ref:`Font<class_Font>`.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. OpenType variations, simulated bold / slant, and additional font settings like OpenType features and extra spacing.
  15. To use simulated bold font variant:
  16. .. tabs::
  17. .. code-tab:: gdscript
  18. var fv = FontVariation.new()
  19. fv.set_base_font(load("res://BarlowCondensed-Regular.ttf"))
  20. fv.set_variation_embolden(1.2)
  21. $Label.add_theme_font_override("font", fv)
  22. $Label.add_theme_font_size_override("font_size", 64)
  23. .. code-tab:: csharp
  24. var fv = new FontVariation();
  25. fv.SetBaseFont(ResourceLoader.Load<FontFile>("res://BarlowCondensed-Regular.ttf"));
  26. fv.SetVariationEmbolden(1.2);
  27. GetNode("Label").AddThemeFontOverride("font", fv);
  28. GetNode("Label").AddThemeFontSizeOverride("font_size", 64);
  29. .. rst-class:: classref-reftable-group
  30. Properties
  31. ----------
  32. .. table::
  33. :widths: auto
  34. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  35. | :ref:`Font<class_Font>` | :ref:`base_font<class_FontVariation_property_base_font>` | |
  36. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  37. | :ref:`Font[]<class_Font>` | :ref:`fallbacks<class_FontVariation_property_fallbacks>` | ``[]`` |
  38. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  39. | :ref:`Dictionary<class_Dictionary>` | :ref:`opentype_features<class_FontVariation_property_opentype_features>` | ``{}`` |
  40. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  41. | :ref:`int<class_int>` | :ref:`spacing_bottom<class_FontVariation_property_spacing_bottom>` | ``0`` |
  42. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  43. | :ref:`int<class_int>` | :ref:`spacing_glyph<class_FontVariation_property_spacing_glyph>` | ``0`` |
  44. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  45. | :ref:`int<class_int>` | :ref:`spacing_space<class_FontVariation_property_spacing_space>` | ``0`` |
  46. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  47. | :ref:`int<class_int>` | :ref:`spacing_top<class_FontVariation_property_spacing_top>` | ``0`` |
  48. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  49. | :ref:`float<class_float>` | :ref:`variation_embolden<class_FontVariation_property_variation_embolden>` | ``0.0`` |
  50. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  51. | :ref:`int<class_int>` | :ref:`variation_face_index<class_FontVariation_property_variation_face_index>` | ``0`` |
  52. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  53. | :ref:`Dictionary<class_Dictionary>` | :ref:`variation_opentype<class_FontVariation_property_variation_opentype>` | ``{}`` |
  54. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  55. | :ref:`Transform2D<class_Transform2D>` | :ref:`variation_transform<class_FontVariation_property_variation_transform>` | ``Transform2D(1, 0, 0, 1, 0, 0)`` |
  56. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  57. .. rst-class:: classref-reftable-group
  58. Methods
  59. -------
  60. .. table::
  61. :widths: auto
  62. +------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_spacing<class_FontVariation_method_set_spacing>` **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)** |
  64. +------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. .. rst-class:: classref-section-separator
  66. ----
  67. .. rst-class:: classref-descriptions-group
  68. Property Descriptions
  69. ---------------------
  70. .. _class_FontVariation_property_base_font:
  71. .. rst-class:: classref-property
  72. :ref:`Font<class_Font>` **base_font**
  73. .. rst-class:: classref-property-setget
  74. - void **set_base_font** **(** :ref:`Font<class_Font>` value **)**
  75. - :ref:`Font<class_Font>` **get_base_font** **(** **)**
  76. Base font used to create a variation. If not set, default :ref:`Theme<class_Theme>` font is used.
  77. .. rst-class:: classref-item-separator
  78. ----
  79. .. _class_FontVariation_property_fallbacks:
  80. .. rst-class:: classref-property
  81. :ref:`Font[]<class_Font>` **fallbacks** = ``[]``
  82. .. rst-class:: classref-property-setget
  83. - void **set_fallbacks** **(** :ref:`Font[]<class_Font>` value **)**
  84. - :ref:`Font[]<class_Font>` **get_fallbacks** **(** **)**
  85. Array of fallback :ref:`Font<class_Font>`\ s. If not set :ref:`base_font<class_FontVariation_property_base_font>` fallback are ussed.
  86. .. rst-class:: classref-item-separator
  87. ----
  88. .. _class_FontVariation_property_opentype_features:
  89. .. rst-class:: classref-property
  90. :ref:`Dictionary<class_Dictionary>` **opentype_features** = ``{}``
  91. .. rst-class:: classref-property-setget
  92. - void **set_opentype_features** **(** :ref:`Dictionary<class_Dictionary>` value **)**
  93. - :ref:`Dictionary<class_Dictionary>` **get_opentype_features** **(** **)**
  94. A set of OpenType feature tags. More info: `OpenType feature tags <https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags>`__.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_FontVariation_property_spacing_bottom:
  98. .. rst-class:: classref-property
  99. :ref:`int<class_int>` **spacing_bottom** = ``0``
  100. .. rst-class:: classref-property-setget
  101. - void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  102. - :ref:`int<class_int>` **get_spacing** **(** **)**
  103. Extra spacing at the bottom of the line in pixels.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_FontVariation_property_spacing_glyph:
  107. .. rst-class:: classref-property
  108. :ref:`int<class_int>` **spacing_glyph** = ``0``
  109. .. rst-class:: classref-property-setget
  110. - void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  111. - :ref:`int<class_int>` **get_spacing** **(** **)**
  112. Extra spacing between graphical glyphs
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_FontVariation_property_spacing_space:
  116. .. rst-class:: classref-property
  117. :ref:`int<class_int>` **spacing_space** = ``0``
  118. .. rst-class:: classref-property-setget
  119. - void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  120. - :ref:`int<class_int>` **get_spacing** **(** **)**
  121. Extra width of the space glyphs.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_FontVariation_property_spacing_top:
  125. .. rst-class:: classref-property
  126. :ref:`int<class_int>` **spacing_top** = ``0``
  127. .. rst-class:: classref-property-setget
  128. - void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  129. - :ref:`int<class_int>` **get_spacing** **(** **)**
  130. Extra spacing at the top of the line in pixels.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_FontVariation_property_variation_embolden:
  134. .. rst-class:: classref-property
  135. :ref:`float<class_float>` **variation_embolden** = ``0.0``
  136. .. rst-class:: classref-property-setget
  137. - void **set_variation_embolden** **(** :ref:`float<class_float>` value **)**
  138. - :ref:`float<class_float>` **get_variation_embolden** **(** **)**
  139. If is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
  140. \ **Note:** Emboldened fonts might have self-intersecting outlines, which will prevent MSDF fonts and :ref:`TextMesh<class_TextMesh>` from working correctly.
  141. .. rst-class:: classref-item-separator
  142. ----
  143. .. _class_FontVariation_property_variation_face_index:
  144. .. rst-class:: classref-property
  145. :ref:`int<class_int>` **variation_face_index** = ``0``
  146. .. rst-class:: classref-property-setget
  147. - void **set_variation_face_index** **(** :ref:`int<class_int>` value **)**
  148. - :ref:`int<class_int>` **get_variation_face_index** **(** **)**
  149. Active face index in the TrueType / OpenType collection file.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_FontVariation_property_variation_opentype:
  153. .. rst-class:: classref-property
  154. :ref:`Dictionary<class_Dictionary>` **variation_opentype** = ``{}``
  155. .. rst-class:: classref-property-setget
  156. - void **set_variation_opentype** **(** :ref:`Dictionary<class_Dictionary>` value **)**
  157. - :ref:`Dictionary<class_Dictionary>` **get_variation_opentype** **(** **)**
  158. Font OpenType variation coordinates. More info: `OpenType variation tags <https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg>`__.
  159. .. rst-class:: classref-item-separator
  160. ----
  161. .. _class_FontVariation_property_variation_transform:
  162. .. rst-class:: classref-property
  163. :ref:`Transform2D<class_Transform2D>` **variation_transform** = ``Transform2D(1, 0, 0, 1, 0, 0)``
  164. .. rst-class:: classref-property-setget
  165. - void **set_variation_transform** **(** :ref:`Transform2D<class_Transform2D>` value **)**
  166. - :ref:`Transform2D<class_Transform2D>` **get_variation_transform** **(** **)**
  167. 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
  168. For example, to simulate italic typeface by slanting, apply the following transform ``Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0)``.
  169. .. rst-class:: classref-section-separator
  170. ----
  171. .. rst-class:: classref-descriptions-group
  172. Method Descriptions
  173. -------------------
  174. .. _class_FontVariation_method_set_spacing:
  175. .. rst-class:: classref-method
  176. void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  177. Sets the spacing for ``type`` (see :ref:`SpacingType<enum_TextServer_SpacingType>`) to ``value`` in pixels (not relative to the font size).
  178. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  179. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  180. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  181. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  182. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  183. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`