class_fontvariation.rst 14 KB

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