class_fontvariation.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/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. A variation of a font with additional settings.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Provides 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. To set the coordinate of multiple variation axes:
  30. ::
  31. var fv = FontVariation.new();
  32. var ts = TextServerManager.get_primary_interface()
  33. fv.base_font = load("res://BarlowCondensed-Regular.ttf")
  34. fv.variation_opentype = { ts.name_to_tag("wght"): 900, ts.name_to_tag("custom_hght"): 900 }
  35. .. rst-class:: classref-reftable-group
  36. Properties
  37. ----------
  38. .. table::
  39. :widths: auto
  40. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  41. | :ref:`Font<class_Font>` | :ref:`base_font<class_FontVariation_property_base_font>` | |
  42. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  43. | :ref:`Dictionary<class_Dictionary>` | :ref:`opentype_features<class_FontVariation_property_opentype_features>` | ``{}`` |
  44. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  45. | :ref:`int<class_int>` | :ref:`spacing_bottom<class_FontVariation_property_spacing_bottom>` | ``0`` |
  46. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  47. | :ref:`int<class_int>` | :ref:`spacing_glyph<class_FontVariation_property_spacing_glyph>` | ``0`` |
  48. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  49. | :ref:`int<class_int>` | :ref:`spacing_space<class_FontVariation_property_spacing_space>` | ``0`` |
  50. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  51. | :ref:`int<class_int>` | :ref:`spacing_top<class_FontVariation_property_spacing_top>` | ``0`` |
  52. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  53. | :ref:`float<class_float>` | :ref:`variation_embolden<class_FontVariation_property_variation_embolden>` | ``0.0`` |
  54. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  55. | :ref:`int<class_int>` | :ref:`variation_face_index<class_FontVariation_property_variation_face_index>` | ``0`` |
  56. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  57. | :ref:`Dictionary<class_Dictionary>` | :ref:`variation_opentype<class_FontVariation_property_variation_opentype>` | ``{}`` |
  58. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  59. | :ref:`Transform2D<class_Transform2D>` | :ref:`variation_transform<class_FontVariation_property_variation_transform>` | ``Transform2D(1, 0, 0, 1, 0, 0)`` |
  60. +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
  61. .. rst-class:: classref-reftable-group
  62. Methods
  63. -------
  64. .. table::
  65. :widths: auto
  66. +------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`set_spacing<class_FontVariation_method_set_spacing>` **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)** |
  68. +------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. .. rst-class:: classref-section-separator
  70. ----
  71. .. rst-class:: classref-descriptions-group
  72. Property Descriptions
  73. ---------------------
  74. .. _class_FontVariation_property_base_font:
  75. .. rst-class:: classref-property
  76. :ref:`Font<class_Font>` **base_font**
  77. .. rst-class:: classref-property-setget
  78. - void **set_base_font** **(** :ref:`Font<class_Font>` value **)**
  79. - :ref:`Font<class_Font>` **get_base_font** **(** **)**
  80. Base font used to create a variation. If not set, default :ref:`Theme<class_Theme>` font is used.
  81. .. rst-class:: classref-item-separator
  82. ----
  83. .. _class_FontVariation_property_opentype_features:
  84. .. rst-class:: classref-property
  85. :ref:`Dictionary<class_Dictionary>` **opentype_features** = ``{}``
  86. .. rst-class:: classref-property-setget
  87. - void **set_opentype_features** **(** :ref:`Dictionary<class_Dictionary>` value **)**
  88. - :ref:`Dictionary<class_Dictionary>` **get_opentype_features** **(** **)**
  89. A set of OpenType feature tags. More info: `OpenType feature tags <https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags>`__.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_FontVariation_property_spacing_bottom:
  93. .. rst-class:: classref-property
  94. :ref:`int<class_int>` **spacing_bottom** = ``0``
  95. .. rst-class:: classref-property-setget
  96. - void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  97. - :ref:`int<class_int>` **get_spacing** **(** **)**
  98. Extra spacing at the bottom of the line in pixels.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_FontVariation_property_spacing_glyph:
  102. .. rst-class:: classref-property
  103. :ref:`int<class_int>` **spacing_glyph** = ``0``
  104. .. rst-class:: classref-property-setget
  105. - void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  106. - :ref:`int<class_int>` **get_spacing** **(** **)**
  107. Extra spacing between graphical glyphs.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_FontVariation_property_spacing_space:
  111. .. rst-class:: classref-property
  112. :ref:`int<class_int>` **spacing_space** = ``0``
  113. .. rst-class:: classref-property-setget
  114. - void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  115. - :ref:`int<class_int>` **get_spacing** **(** **)**
  116. Extra width of the space glyphs.
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_FontVariation_property_spacing_top:
  120. .. rst-class:: classref-property
  121. :ref:`int<class_int>` **spacing_top** = ``0``
  122. .. rst-class:: classref-property-setget
  123. - void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  124. - :ref:`int<class_int>` **get_spacing** **(** **)**
  125. Extra spacing at the top of the line in pixels.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_FontVariation_property_variation_embolden:
  129. .. rst-class:: classref-property
  130. :ref:`float<class_float>` **variation_embolden** = ``0.0``
  131. .. rst-class:: classref-property-setget
  132. - void **set_variation_embolden** **(** :ref:`float<class_float>` value **)**
  133. - :ref:`float<class_float>` **get_variation_embolden** **(** **)**
  134. If is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
  135. \ **Note:** Emboldened fonts might have self-intersecting outlines, which will prevent MSDF fonts and :ref:`TextMesh<class_TextMesh>` from working correctly.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_FontVariation_property_variation_face_index:
  139. .. rst-class:: classref-property
  140. :ref:`int<class_int>` **variation_face_index** = ``0``
  141. .. rst-class:: classref-property-setget
  142. - void **set_variation_face_index** **(** :ref:`int<class_int>` value **)**
  143. - :ref:`int<class_int>` **get_variation_face_index** **(** **)**
  144. Active face index in the TrueType / OpenType collection file.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_FontVariation_property_variation_opentype:
  148. .. rst-class:: classref-property
  149. :ref:`Dictionary<class_Dictionary>` **variation_opentype** = ``{}``
  150. .. rst-class:: classref-property-setget
  151. - void **set_variation_opentype** **(** :ref:`Dictionary<class_Dictionary>` value **)**
  152. - :ref:`Dictionary<class_Dictionary>` **get_variation_opentype** **(** **)**
  153. Font OpenType variation coordinates. More info: `OpenType variation tags <https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg>`__.
  154. \ **Note:** This :ref:`Dictionary<class_Dictionary>` uses OpenType tags as keys. Variation axes can be identified both by tags (:ref:`int<class_int>`, e.g. ``0x77678674``) and names (:ref:`String<class_String>`, e.g. ``wght``). Some axes might be accessible by multiple names. For example, ``wght`` refers to the same axis as ``weight``. Tags on the other hand are unique. To convert between names and tags, use :ref:`TextServer.name_to_tag<class_TextServer_method_name_to_tag>` and :ref:`TextServer.tag_to_name<class_TextServer_method_tag_to_name>`.
  155. \ **Note:** To get available variation axes of a font, use :ref:`Font.get_supported_variation_list<class_Font_method_get_supported_variation_list>`.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_FontVariation_property_variation_transform:
  159. .. rst-class:: classref-property
  160. :ref:`Transform2D<class_Transform2D>` **variation_transform** = ``Transform2D(1, 0, 0, 1, 0, 0)``
  161. .. rst-class:: classref-property-setget
  162. - void **set_variation_transform** **(** :ref:`Transform2D<class_Transform2D>` value **)**
  163. - :ref:`Transform2D<class_Transform2D>` **get_variation_transform** **(** **)**
  164. 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
  165. For example, to simulate italic typeface by slanting, apply the following transform ``Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0)``.
  166. .. rst-class:: classref-section-separator
  167. ----
  168. .. rst-class:: classref-descriptions-group
  169. Method Descriptions
  170. -------------------
  171. .. _class_FontVariation_method_set_spacing:
  172. .. rst-class:: classref-method
  173. void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
  174. Sets the spacing for ``spacing`` (see :ref:`SpacingType<enum_TextServer_SpacingType>`) to ``value`` in pixels (not relative to the font size).
  175. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  176. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  177. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  178. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  179. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  180. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  181. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`