2022-05-09 11:47:10 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 10:08:05 +02:00
<class name= "FontVariation" inherits= "Font" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2022-05-09 11:47:10 +02:00
<brief_description >
2023-04-30 16:26:09 +02:00
A variation of a font with additional settings.
2022-05-09 11:47:10 +02:00
</brief_description>
<description >
2023-04-30 16:26:09 +02:00
Provides OpenType variations, simulated bold / slant, and additional font settings like OpenType features and extra spacing.
2022-05-09 11:47:10 +02:00
To use simulated bold font variant:
[codeblocks]
[gdscript]
var fv = FontVariation.new()
fv.set_base_font(load("res://BarlowCondensed-Regular.ttf"))
2023-02-06 14:07:35 +01:00
fv.set_variation_embolden(1.2)
$Label.add_theme_font_override("font", fv)
$Label.add_theme_font_size_override("font_size", 64)
2022-05-09 11:47:10 +02:00
[/gdscript]
[csharp]
var fv = new FontVariation();
fv.SetBaseFont(ResourceLoader.Load< FontFile> ("res://BarlowCondensed-Regular.ttf"));
fv.SetVariationEmbolden(1.2);
2023-02-06 14:07:35 +01:00
GetNode("Label").AddThemeFontOverride("font", fv);
GetNode("Label").AddThemeFontSizeOverride("font_size", 64);
2022-05-09 11:47:10 +02:00
[/csharp]
[/codeblocks]
2023-03-01 15:11:45 +01:00
To set the coordinate of multiple variation axes:
[codeblock]
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 }
[/codeblock]
2022-05-09 11:47:10 +02:00
</description>
<tutorials >
</tutorials>
<methods >
<method name= "set_spacing" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "spacing" type= "int" enum= "TextServer.SpacingType" />
<param index= "1" name= "value" type= "int" />
2022-05-09 11:47:10 +02:00
<description >
2022-08-12 18:07:53 +02:00
Sets the spacing for [code]type[/code] (see [enum TextServer.SpacingType]) to [param value] in pixels (not relative to the font size).
2022-05-09 11:47:10 +02:00
</description>
</method>
</methods>
<members >
<member name= "base_font" type= "Font" setter= "set_base_font" getter= "get_base_font" >
Base font used to create a variation. If not set, default [Theme] font is used.
</member>
<member name= "opentype_features" type= "Dictionary" setter= "set_opentype_features" getter= "get_opentype_features" default= "{}" >
A set of OpenType feature tags. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
</member>
<member name= "spacing_bottom" type= "int" setter= "set_spacing" getter= "get_spacing" default= "0" >
Extra spacing at the bottom of the line in pixels.
</member>
<member name= "spacing_glyph" type= "int" setter= "set_spacing" getter= "get_spacing" default= "0" >
2023-02-11 17:18:33 +01:00
Extra spacing between graphical glyphs.
2022-05-09 11:47:10 +02:00
</member>
<member name= "spacing_space" type= "int" setter= "set_spacing" getter= "get_spacing" default= "0" >
Extra width of the space glyphs.
</member>
<member name= "spacing_top" type= "int" setter= "set_spacing" getter= "get_spacing" default= "0" >
Extra spacing at the top of the line in pixels.
</member>
<member name= "variation_embolden" type= "float" setter= "set_variation_embolden" getter= "get_variation_embolden" default= "0.0" >
If is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
[b]Note:[/b] Emboldened fonts might have self-intersecting outlines, which will prevent MSDF fonts and [TextMesh] from working correctly.
</member>
<member name= "variation_face_index" type= "int" setter= "set_variation_face_index" getter= "get_variation_face_index" default= "0" >
Active face index in the TrueType / OpenType collection file.
</member>
<member name= "variation_opentype" type= "Dictionary" setter= "set_variation_opentype" getter= "get_variation_opentype" default= "{}" >
Font OpenType variation coordinates. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg]OpenType variation tags[/url].
2023-03-01 15:11:45 +01:00
[b]Note:[/b] This [Dictionary] uses OpenType tags as keys. Variation axes can be identified both by tags([code]int[/code]) and names ([code]string[/code]). Some axes might be accessible by multiple names. For example, [code]wght[/code] refers to the same axis as [code]weight[/code]. Tags on the other hand are unique. To convert between names and tags, use [method TextServer.name_to_tag] and [method TextServer.tag_to_name].
[b]Note:[/b] To get available variation axes of a font, use [method Font.get_supported_variation_list].
2022-05-09 11:47:10 +02:00
</member>
<member name= "variation_transform" type= "Transform2D" setter= "set_variation_transform" getter= "get_variation_transform" default= "Transform2D(1, 0, 0, 1, 0, 0)" >
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 [code]Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0)[/code].
</member>
</members>
</class>