Class FontVariation
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Provides OpenType variations, simulated bold / slant, and additional font settings like OpenType features and extra spacing.
To use simulated bold font variant:
var fv = new FontVariation();
fv.SetBaseFont(ResourceLoader.Load<FontFile>("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 }
public class FontVariation : Font, IDisposable
- Inheritance
-
FontVariation
- Implements
- Inherited Members
Constructors
FontVariation()
public FontVariation()
Properties
BaseFont
Base font used to create a variation. If not set, default Theme font is used.
public Font BaseFont { get; set; }
Property Value
OpentypeFeatures
A set of OpenType feature tags. More info: OpenType feature tags.
public Dictionary OpentypeFeatures { get; set; }
Property Value
SpacingBottom
Extra spacing at the bottom of the line in pixels.
public int SpacingBottom { get; set; }
Property Value
SpacingGlyph
Extra spacing between graphical glyphs.
public int SpacingGlyph { get; set; }
Property Value
SpacingSpace
Extra width of the space glyphs.
public int SpacingSpace { get; set; }
Property Value
SpacingTop
Extra spacing at the top of the line in pixels.
public int SpacingTop { get; set; }
Property Value
VariationEmbolden
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 TextMesh from working correctly.
public float VariationEmbolden { get; set; }
Property Value
VariationFaceIndex
Active face index in the TrueType / OpenType collection file.
public int VariationFaceIndex { get; set; }
Property Value
VariationOpentype
Font OpenType variation coordinates. More info: OpenType variation tags.
Note: This Dictionary uses OpenType tags as keys. Variation axes can be identified both by tags (int, e.g. 0x77678674
) and names (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 NameToTag(string) and TagToName(long).
Note: To get available variation axes of a font, use GetSupportedVariationList().
public Dictionary VariationOpentype { get; set; }
Property Value
VariationTransform
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)
.
public Transform2D VariationTransform { get; set; }
Property Value
Methods
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.