Files
godot-docs/classes/class_fontvariation.rst
2022-07-27 13:58:15 +02:00

274 lines
12 KiB
ReStructuredText

:github_url: hide
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the FontVariation.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_FontVariation:
FontVariation
=============
**Inherits:** :ref:`Font<class_Font>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
Variation of the :ref:`Font<class_Font>`.
Description
-----------
OpenType variations, simulated bold / slant, and additional font settings like OpenType features and extra spacing.
To use simulated bold font variant:
.. tabs::
.. code-tab:: gdscript
var fv = FontVariation.new()
fv.set_base_font(load("res://BarlowCondensed-Regular.ttf"))
fv.set_variation_embolden(1.2);
$"Label".set("custom_fonts/font", fv)
$"Label".set("custom_fonts/font_size", 64)
.. code-tab:: csharp
var fv = new FontVariation();
fv.SetBaseFont(ResourceLoader.Load<FontFile>("res://BarlowCondensed-Regular.ttf"));
fv.SetVariationEmbolden(1.2);
GetNode("Label").Set("custom_fonts/font", fv);
GetNode("Label").Set("custom_font_sizes/font_size", 64);
Properties
----------
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Font<class_Font>` | :ref:`base_font<class_FontVariation_property_base_font>` | |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Font[]<class_Font>` | :ref:`fallbacks<class_FontVariation_property_fallbacks>` | ``[]`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Dictionary<class_Dictionary>` | :ref:`opentype_features<class_FontVariation_property_opentype_features>` | ``{}`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`spacing_bottom<class_FontVariation_property_spacing_bottom>` | ``0`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`spacing_glyph<class_FontVariation_property_spacing_glyph>` | ``0`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`spacing_space<class_FontVariation_property_spacing_space>` | ``0`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`spacing_top<class_FontVariation_property_spacing_top>` | ``0`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`float<class_float>` | :ref:`variation_embolden<class_FontVariation_property_variation_embolden>` | ``0.0`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`int<class_int>` | :ref:`variation_face_index<class_FontVariation_property_variation_face_index>` | ``0`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Dictionary<class_Dictionary>` | :ref:`variation_opentype<class_FontVariation_property_variation_opentype>` | ``{}`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
| :ref:`Transform2D<class_Transform2D>` | :ref:`variation_transform<class_FontVariation_property_variation_transform>` | ``Transform2D(1, 0, 0, 1, 0, 0)`` |
+---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+
Methods
-------
+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_spacing<class_FontVariation_method_set_spacing>` **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)** |
+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
Property Descriptions
---------------------
.. _class_FontVariation_property_base_font:
- :ref:`Font<class_Font>` **base_font**
+----------+----------------------+
| *Setter* | set_base_font(value) |
+----------+----------------------+
| *Getter* | get_base_font() |
+----------+----------------------+
Base font used to create a variation. If not set, default :ref:`Theme<class_Theme>` font is used.
----
.. _class_FontVariation_property_fallbacks:
- :ref:`Font[]<class_Font>` **fallbacks**
+-----------+----------------------+
| *Default* | ``[]`` |
+-----------+----------------------+
| *Setter* | set_fallbacks(value) |
+-----------+----------------------+
| *Getter* | get_fallbacks() |
+-----------+----------------------+
Array of fallback :ref:`Font<class_Font>`\ s. If not set :ref:`base_font<class_FontVariation_property_base_font>` fallback are ussed.
----
.. _class_FontVariation_property_opentype_features:
- :ref:`Dictionary<class_Dictionary>` **opentype_features**
+-----------+------------------------------+
| *Default* | ``{}`` |
+-----------+------------------------------+
| *Setter* | set_opentype_features(value) |
+-----------+------------------------------+
| *Getter* | get_opentype_features() |
+-----------+------------------------------+
A set of OpenType feature tags. More info: `OpenType feature tags <https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags>`__.
----
.. _class_FontVariation_property_spacing_bottom:
- :ref:`int<class_int>` **spacing_bottom**
+-----------+--------------------+
| *Default* | ``0`` |
+-----------+--------------------+
| *Setter* | set_spacing(value) |
+-----------+--------------------+
| *Getter* | get_spacing() |
+-----------+--------------------+
Extra spacing at the bottom of the line in pixels.
----
.. _class_FontVariation_property_spacing_glyph:
- :ref:`int<class_int>` **spacing_glyph**
+-----------+--------------------+
| *Default* | ``0`` |
+-----------+--------------------+
| *Setter* | set_spacing(value) |
+-----------+--------------------+
| *Getter* | get_spacing() |
+-----------+--------------------+
Extra spacing between graphical glyphs
----
.. _class_FontVariation_property_spacing_space:
- :ref:`int<class_int>` **spacing_space**
+-----------+--------------------+
| *Default* | ``0`` |
+-----------+--------------------+
| *Setter* | set_spacing(value) |
+-----------+--------------------+
| *Getter* | get_spacing() |
+-----------+--------------------+
Extra width of the space glyphs.
----
.. _class_FontVariation_property_spacing_top:
- :ref:`int<class_int>` **spacing_top**
+-----------+--------------------+
| *Default* | ``0`` |
+-----------+--------------------+
| *Setter* | set_spacing(value) |
+-----------+--------------------+
| *Getter* | get_spacing() |
+-----------+--------------------+
Extra spacing at the top of the line in pixels.
----
.. _class_FontVariation_property_variation_embolden:
- :ref:`float<class_float>` **variation_embolden**
+-----------+-------------------------------+
| *Default* | ``0.0`` |
+-----------+-------------------------------+
| *Setter* | set_variation_embolden(value) |
+-----------+-------------------------------+
| *Getter* | get_variation_embolden() |
+-----------+-------------------------------+
If is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
\ **Note:** Emboldened fonts might have self-intersecting outlines, which will prevent MSDF fonts and :ref:`TextMesh<class_TextMesh>` from working correctly.
----
.. _class_FontVariation_property_variation_face_index:
- :ref:`int<class_int>` **variation_face_index**
+-----------+---------------------------------+
| *Default* | ``0`` |
+-----------+---------------------------------+
| *Setter* | set_variation_face_index(value) |
+-----------+---------------------------------+
| *Getter* | get_variation_face_index() |
+-----------+---------------------------------+
Active face index in the TrueType / OpenType collection file.
----
.. _class_FontVariation_property_variation_opentype:
- :ref:`Dictionary<class_Dictionary>` **variation_opentype**
+-----------+-------------------------------+
| *Default* | ``{}`` |
+-----------+-------------------------------+
| *Setter* | set_variation_opentype(value) |
+-----------+-------------------------------+
| *Getter* | get_variation_opentype() |
+-----------+-------------------------------+
Font OpenType variation coordinates. More info: `OpenType variation tags <https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg>`__.
----
.. _class_FontVariation_property_variation_transform:
- :ref:`Transform2D<class_Transform2D>` **variation_transform**
+-----------+-----------------------------------+
| *Default* | ``Transform2D(1, 0, 0, 1, 0, 0)`` |
+-----------+-----------------------------------+
| *Setter* | set_variation_transform(value) |
+-----------+-----------------------------------+
| *Getter* | get_variation_transform() |
+-----------+-----------------------------------+
2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
For example, to simulate italic typeface by slanting, apply the following transform ``Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0)``.
Method Descriptions
-------------------
.. _class_FontVariation_method_set_spacing:
- void **set_spacing** **(** :ref:`SpacingType<enum_TextServer_SpacingType>` spacing, :ref:`int<class_int>` value **)**
Sets the spacing for ``type`` (see :ref:`SpacingType<enum_TextServer_SpacingType>`) to ``value`` in pixels (not relative to the font size).
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`