Debian Codegraph @

doc/classes/FontVariation.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="FontVariation" inherits="Font" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A variation of a font with additional settings.
5 </brief_description>
6 <description>
7 Provides OpenType variations, simulated bold / slant, and additional font settings like OpenType features and extra spacing.
8 To use simulated bold font variant:
9 [codeblocks]
10 [gdscript]
11 var fv = FontVariation.new()
12 fv.base_font = load("res://BarlowCondensed-Regular.ttf")
13 fv.variation_embolden = 1.2
14 $Label.add_theme_font_override("font", fv)
15 $Label.add_theme_font_size_override("font_size", 64)
16 [/gdscript]
17 [csharp]
18 var fv = new FontVariation();
19 fv.SetBaseFont(ResourceLoader.Load&lt;FontFile&gt;("res://BarlowCondensed-Regular.ttf"));
20 fv.SetVariationEmbolden(1.2);
21 GetNode("Label").AddThemeFontOverride("font", fv);
22 GetNode("Label").AddThemeFontSizeOverride("font_size", 64);
23 [/csharp]
24 [/codeblocks]
25 To set the coordinate of multiple variation axes:
26 [codeblock]
27 var fv = FontVariation.new();
28 var ts = TextServerManager.get_primary_interface()
29 fv.base_font = load("res://BarlowCondensed-Regular.ttf")
30 fv.variation_opentype = { ts.name_to_tag("wght"): 900, ts.name_to_tag("custom_hght"): 900 }
31 [/codeblock]
32 </description>
33 <tutorials>
34 </tutorials>
35 <methods>
36 <method name="set_spacing">
37 <return type="void" />
38 <param index="0" name="spacing" type="int" enum="TextServer.SpacingType" />
39 <param index="1" name="value" type="int" />
40 <description>
41 Sets the spacing for [param spacing] to [param value] in pixels (not relative to the font size).
42 </description>
43 </method>
44 </methods>
45 <members>
46 <member name="base_font" type="Font" setter="set_base_font" getter="get_base_font">
47 Base font used to create a variation. If not set, default [Theme] font is used.
48 </member>
49 <member name="baseline_offset" type="float" setter="set_baseline_offset" getter="get_baseline_offset" default="0.0">
50 Extra baseline offset (as a fraction of font height).
51 </member>
52 <member name="opentype_features" type="Dictionary" setter="set_opentype_features" getter="get_opentype_features" default="{}">
53 A set of OpenType feature tags. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
54 </member>
55 <member name="spacing_bottom" type="int" setter="set_spacing" getter="get_spacing" default="0">
56 Extra spacing at the bottom of the line in pixels.
57 </member>
58 <member name="spacing_glyph" type="int" setter="set_spacing" getter="get_spacing" default="0">
59 Extra spacing between graphical glyphs.
60 </member>
61 <member name="spacing_space" type="int" setter="set_spacing" getter="get_spacing" default="0">
62 Extra width of the space glyphs.
63 </member>
64 <member name="spacing_top" type="int" setter="set_spacing" getter="get_spacing" default="0">
65 Extra spacing at the top of the line in pixels.
66 </member>
67 <member name="variation_embolden" type="float" setter="set_variation_embolden" getter="get_variation_embolden" default="0.0">
68 If is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
69 [b]Note:[/b] Emboldened fonts might have self-intersecting outlines, which will prevent MSDF fonts and [TextMesh] from working correctly.
70 </member>
71 <member name="variation_face_index" type="int" setter="set_variation_face_index" getter="get_variation_face_index" default="0">
72 Active face index in the TrueType / OpenType collection file.
73 </member>
74 <member name="variation_opentype" type="Dictionary" setter="set_variation_opentype" getter="get_variation_opentype" default="{}">
75 Font OpenType variation coordinates. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg]OpenType variation tags[/url].
76 [b]Note:[/b] This [Dictionary] uses OpenType tags as keys. Variation axes can be identified both by tags ([int], e.g. [code]0x77678674[/code]) and names ([String], e.g. [code]wght[/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].
77 [b]Note:[/b] To get available variation axes of a font, use [method Font.get_supported_variation_list].
78 </member>
79 <member name="variation_transform" type="Transform2D" setter="set_variation_transform" getter="get_variation_transform" default="Transform2D(1, 0, 0, 1, 0, 0)">
80 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
81 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].
82 </member>
83 </members>
84 </class>