:github_url: hide .. _class_FontVariation: FontVariation ============= **Hérite de :** :ref:`Font` **<** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` Une variation d'une police avec des paramètres supplémentaires. .. rst-class:: classref-introduction-group Description ----------- Provides 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.base_font = load("res://BarlowCondensed-Regular.ttf") fv.variation_embolden = 1.2 $Label.add_theme_font_override("font", fv) $Label.add_theme_font_size_override("font_size", 64) .. code-tab:: csharp var fv = new FontVariation(); fv.SetBaseFont(ResourceLoader.Load("res://BarlowCondensed-Regular.ttf")); fv.SetVariationEmbolden(1.2); GetNode("Label").AddThemeFontOverride("font", fv); GetNode("Label").AddThemeFontSizeOverride("font_size", 64); To set the coordinate of multiple variation axes: :: var fv = FontVariation.new(); var ts = TextServerManager.get_primary_interface() fv.base_font = load("res://BarlowCondensed-Regular.ttf") fv.variation_opentype = { ts.name_to_tag("wght"): 900, ts.name_to_tag("custom_hght"): 900 } .. rst-class:: classref-reftable-group Propriétés -------------------- .. table:: :widths: auto +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`Font` | :ref:`base_font` | | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`float` | :ref:`baseline_offset` | ``0.0`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`Dictionary` | :ref:`opentype_features` | ``{}`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`int` | :ref:`spacing_bottom` | ``0`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`int` | :ref:`spacing_glyph` | ``0`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`int` | :ref:`spacing_space` | ``0`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`int` | :ref:`spacing_top` | ``0`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`float` | :ref:`variation_embolden` | ``0.0`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`int` | :ref:`variation_face_index` | ``0`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`Dictionary` | :ref:`variation_opentype` | ``{}`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ | :ref:`Transform2D` | :ref:`variation_transform` | ``Transform2D(1, 0, 0, 1, 0, 0)`` | +---------------------------------------+--------------------------------------------------------------------------------+-----------------------------------+ .. rst-class:: classref-reftable-group Méthodes ---------------- .. table:: :widths: auto +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_spacing`\ (\ spacing\: :ref:`SpacingType`, value\: :ref:`int`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descriptions des propriétés ------------------------------------------------------ .. _class_FontVariation_property_base_font: .. rst-class:: classref-property :ref:`Font` **base_font** :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_base_font**\ (\ value\: :ref:`Font`\ ) - :ref:`Font` **get_base_font**\ (\ ) Base font used to create a variation. If not set, default :ref:`Theme` font is used. .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_baseline_offset: .. rst-class:: classref-property :ref:`float` **baseline_offset** = ``0.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_baseline_offset**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_baseline_offset**\ (\ ) Extra baseline offset (as a fraction of font height). .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_opentype_features: .. rst-class:: classref-property :ref:`Dictionary` **opentype_features** = ``{}`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_opentype_features**\ (\ value\: :ref:`Dictionary`\ ) - :ref:`Dictionary` **get_opentype_features**\ (\ ) A set of OpenType feature tags. More info: `OpenType feature tags `__. .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_spacing_bottom: .. rst-class:: classref-property :ref:`int` **spacing_bottom** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_spacing**\ (\ spacing\: :ref:`SpacingType`, value\: :ref:`int`\ ) - :ref:`int` **get_spacing**\ (\ ) Extra spacing at the bottom of the line in pixels. .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_spacing_glyph: .. rst-class:: classref-property :ref:`int` **spacing_glyph** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_spacing**\ (\ spacing\: :ref:`SpacingType`, value\: :ref:`int`\ ) - :ref:`int` **get_spacing**\ (\ ) Extra spacing between graphical glyphs. .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_spacing_space: .. rst-class:: classref-property :ref:`int` **spacing_space** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_spacing**\ (\ spacing\: :ref:`SpacingType`, value\: :ref:`int`\ ) - :ref:`int` **get_spacing**\ (\ ) Extra width of the space glyphs. .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_spacing_top: .. rst-class:: classref-property :ref:`int` **spacing_top** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_spacing**\ (\ spacing\: :ref:`SpacingType`, value\: :ref:`int`\ ) - :ref:`int` **get_spacing**\ (\ ) Extra spacing at the top of the line in pixels. .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_variation_embolden: .. rst-class:: classref-property :ref:`float` **variation_embolden** = ``0.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_variation_embolden**\ (\ value\: :ref:`float`\ ) - :ref:`float` **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` from working correctly. .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_variation_face_index: .. rst-class:: classref-property :ref:`int` **variation_face_index** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_variation_face_index**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_variation_face_index**\ (\ ) Active face index in the TrueType / OpenType collection file. .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_variation_opentype: .. rst-class:: classref-property :ref:`Dictionary` **variation_opentype** = ``{}`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_variation_opentype**\ (\ value\: :ref:`Dictionary`\ ) - :ref:`Dictionary` **get_variation_opentype**\ (\ ) Font OpenType variation coordinates. More info: `OpenType variation tags `__. \ **Note:** This :ref:`Dictionary` uses OpenType tags as keys. Variation axes can be identified both by tags (:ref:`int`, e.g. ``0x77678674``) and names (:ref:`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()` and :ref:`TextServer.tag_to_name()`. \ **Note:** To get available variation axes of a font, use :ref:`Font.get_supported_variation_list()`. .. rst-class:: classref-item-separator ---- .. _class_FontVariation_property_variation_transform: .. rst-class:: classref-property :ref:`Transform2D` **variation_transform** = ``Transform2D(1, 0, 0, 1, 0, 0)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_variation_transform**\ (\ value\: :ref:`Transform2D`\ ) - :ref:`Transform2D` **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)``. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descriptions des méthodes -------------------------------------------------- .. _class_FontVariation_method_set_spacing: .. rst-class:: classref-method |void| **set_spacing**\ (\ spacing\: :ref:`SpacingType`, value\: :ref:`int`\ ) :ref:`🔗` Définit l'espacement dans ``spacing`` à la valeur ``value`` en pixels (non relatif à la taille de police). .. |virtual| replace:: :abbr:`virtual (Cette méthode doit typiquement être redéfinie par l'utilisateur pour avoir un effet.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (Cette méthode n'a pas d'effets de bord. Elle ne modifie aucune des variables membres de l'instance.)` .. |vararg| replace:: :abbr:`vararg (Cette méthode accepte n'importe quel nombre d'arguments après ceux décris ici.)` .. |constructor| replace:: :abbr:`constructor (Cette méthode est utilisée pour construire un type.)` .. |static| replace:: :abbr:`static (Cette méthode n'a pas besoin d'instance pour être appelée, elle peut donc être directement appelée en utilisant le nom de la classe.)` .. |operator| replace:: :abbr:`operator (Cette méthode décrit un opérateur valide à utiliser avec ce type en tant qu'opérande gauche.)` .. |bitfield| replace:: :abbr:`BitField (Cette valeur est un nombre entier composé d'un masque de bits des options suivantes.)` .. |void| replace:: :abbr:`void (Aucune valeur de retour.)`