Documentation
¶
Overview ¶
Provides OpenType variations, simulated bold / slant, and additional font settings like OpenType features and extra spacing.
To use simulated bold font variant:
package main import ( "graphics.gd/classdb/Font" "graphics.gd/classdb/FontVariation" "graphics.gd/classdb/Resource" "graphics.gd/classdb/TextServer" "graphics.gd/classdb/TextServerManager" "graphics.gd/variant/String" ) func ExampleFontVariation() { var fv = FontVariation.New() var ts = TextServer.Advanced(TextServerManager.GetPrimaryInterface()) fv.SetBaseFont(Resource.Load[Font.Instance]("res://BarlowCondensed-Regular.ttf")) fv.SetVariationOpentype(map[any]any{ ts.NameToTag(String.New("wght")): 900, ts.NameToTag(String.New("custom_hght")): 900, }) }
To set the coordinate of multiple variation axes:
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) AsFont() Font.Instance
- func (self Instance) AsFontVariation() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) BaseFont() Font.Instance
- func (self Instance) BaselineOffset() Float.X
- func (self Instance) ID() ID
- func (self Instance) SetBaseFont(value Font.Instance)
- func (self Instance) SetBaselineOffset(value Float.X)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOpentypeFeatures(value map[any]any)
- func (self Instance) SetSpacingBottom(value int)
- func (self Instance) SetSpacingGlyph(value int)
- func (self Instance) SetSpacingSpace(value int)
- func (self Instance) SetSpacingTop(value int)
- func (self Instance) SetVariationEmbolden(value Float.X)
- func (self Instance) SetVariationFaceIndex(value int)
- func (self Instance) SetVariationOpentype(value map[any]any)
- func (self Instance) SetVariationTransform(value Transform2D.OriginXY)
- func (self Instance) VariationEmbolden() Float.X
- func (self Instance) VariationFaceIndex() int
- func (self Instance) VariationOpentype() map[any]any
- func (self Instance) VariationTransform() Transform2D.OriginXY
- func (self Instance) Virtual(name string) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsFontVariation ¶
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.FontVariation
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsFontVariation ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) BaseFont ¶
Base font used to create a variation. If not set, default Theme font is used.
func (Instance) BaselineOffset ¶
Extra baseline offset (as a fraction of font height).
func (Instance) SetBaseFont ¶
SetBaseFont sets the property returned by [GetBaseFont].
func (Instance) SetBaselineOffset ¶
SetBaselineOffset sets the property returned by [GetBaselineOffset].
func (Instance) SetOpentypeFeatures ¶
A set of OpenType feature tags. More info: OpenType feature tags.
func (Instance) SetSpacingBottom ¶
Extra spacing at the bottom of the line in pixels.
func (Instance) SetSpacingGlyph ¶
Extra spacing between graphical glyphs.
func (Instance) SetSpacingSpace ¶
Extra width of the space glyphs.
func (Instance) SetSpacingTop ¶
Extra spacing at the top of the line in pixels.
func (Instance) SetVariationEmbolden ¶
SetVariationEmbolden sets the property returned by [GetVariationEmbolden].
func (Instance) SetVariationFaceIndex ¶
SetVariationFaceIndex sets the property returned by [GetVariationFaceIndex].
func (Instance) SetVariationOpentype ¶
SetVariationOpentype sets the property returned by [GetVariationOpentype].
func (Instance) SetVariationTransform ¶
func (self Instance) SetVariationTransform(value Transform2D.OriginXY)
SetVariationTransform sets the property returned by [GetVariationTransform].
func (Instance) 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.
func (Instance) VariationFaceIndex ¶
Active face index in the TrueType / OpenType collection file.
func (Instance) VariationOpentype ¶
Font OpenType variation coordinates. More info: OpenType variation tags.
Note: This data structure 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 TextServer.NameToTag and TextServer.TagToName.
Note: To get available variation axes of a font, use Font.GetSupportedVariationList.
func (Instance) VariationTransform ¶
func (self Instance) VariationTransform() Transform2D.OriginXY
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).