Documentation
¶
Overview ¶
Abstract base class for different font types. It has methods for drawing text and font character introspection.
Index ¶
- type Advanced
- type Any
- type Expanded
- func (self Expanded) DrawChar(canvas_item RID.CanvasItem, pos Vector2.XY, char int, font_size int, ...) Float.X
- func (self Expanded) DrawCharOutline(canvas_item RID.CanvasItem, pos Vector2.XY, char int, font_size int, size int, ...) Float.X
- func (self Expanded) DrawMultilineString(canvas_item RID.CanvasItem, pos Vector2.XY, text string, ...)
- func (self Expanded) DrawMultilineStringOutline(canvas_item RID.CanvasItem, pos Vector2.XY, text string, ...)
- func (self Expanded) DrawString(canvas_item RID.CanvasItem, pos Vector2.XY, text string, ...)
- func (self Expanded) DrawStringOutline(canvas_item RID.CanvasItem, pos Vector2.XY, text string, ...)
- func (self Expanded) FindVariation(variation_coordinates map[string]float32, face_index int, strength Float.X, ...) RID.Font
- func (self Expanded) GetAscent(font_size int) Float.X
- func (self Expanded) GetDescent(font_size int) Float.X
- func (self Expanded) GetHeight(font_size int) Float.X
- func (self Expanded) GetMultilineStringSize(text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, ...) Vector2.XY
- func (self Expanded) GetStringSize(text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, ...) Vector2.XY
- func (self Expanded) GetUnderlinePosition(font_size int) Float.X
- func (self Expanded) GetUnderlineThickness(font_size int) Float.X
- type Extension
- type ID
- type Instance
- func (self Instance) AsFont() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) DrawChar(canvas_item RID.CanvasItem, pos Vector2.XY, char int, font_size int) Float.X
- func (self Instance) DrawCharOutline(canvas_item RID.CanvasItem, pos Vector2.XY, char int, font_size int) Float.X
- func (self Instance) DrawMultilineString(canvas_item RID.CanvasItem, pos Vector2.XY, text string)
- func (self Instance) DrawMultilineStringOutline(canvas_item RID.CanvasItem, pos Vector2.XY, text string)
- func (self Instance) DrawString(canvas_item RID.CanvasItem, pos Vector2.XY, text string)
- func (self Instance) DrawStringOutline(canvas_item RID.CanvasItem, pos Vector2.XY, text string)
- func (self Instance) Fallbacks() []Instance
- func (self Instance) FindVariation(variation_coordinates map[string]float32) RID.Font
- func (self Instance) GetAscent() Float.X
- func (self Instance) GetCharSize(char int, font_size int) Vector2.XY
- func (self Instance) GetDescent() Float.X
- func (self Instance) GetFaceCount() int
- func (self Instance) GetFontName() string
- func (self Instance) GetFontStretch() int
- func (self Instance) GetFontStyle() TextServer.FontStyle
- func (self Instance) GetFontStyleName() string
- func (self Instance) GetFontWeight() int
- func (self Instance) GetHeight() Float.X
- func (self Instance) GetMultilineStringSize(text string) Vector2.XY
- func (self Instance) GetOpentypeFeatures() map[string][2]string
- func (self Instance) GetOtNameStrings() map[string]map[string]string
- func (self Instance) GetRids() [][]RID.Font
- func (self Instance) GetSpacing(spacing TextServer.SpacingType) int
- func (self Instance) GetStringSize(text string) Vector2.XY
- func (self Instance) GetSupportedChars() string
- func (self Instance) GetSupportedFeatureList() map[string]OpenTypeFeature
- func (self Instance) GetSupportedVariationList() map[string]map[string]struct{ ... }
- func (self Instance) GetUnderlinePosition() Float.X
- func (self Instance) GetUnderlineThickness() Float.X
- func (self Instance) HasChar(char int) bool
- func (self Instance) ID() ID
- func (self Instance) IsLanguageSupported(language string) bool
- func (self Instance) IsScriptSupported(script string) bool
- func (self Instance) SetCacheCapacity(single_line int, multi_line int)
- func (self Instance) SetFallbacks(value []Instance)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) Virtual(name string) reflect.Value
- type OpenTypeFeature
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 Expanded ¶
func (Expanded) DrawChar ¶
func (self Expanded) DrawChar(canvas_item RID.CanvasItem, pos Vector2.XY, char int, font_size int, modulate Color.RGBA) Float.X
Draw a single Unicode character 'char' into a canvas item using the font, at a given position, with 'modulate' color. 'pos' specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.
Note: Do not use this function to draw strings character by character, use Instance.DrawString or graphics.gd/classdb/TextLine instead.
func (Expanded) DrawCharOutline ¶
func (self Expanded) DrawCharOutline(canvas_item RID.CanvasItem, pos Vector2.XY, char int, font_size int, size int, modulate Color.RGBA) Float.X
Draw a single Unicode character 'char' outline into a canvas item using the font, at a given position, with 'modulate' color and 'size' outline size. 'pos' specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.
Note: Do not use this function to draw strings character by character, use Instance.DrawString or graphics.gd/classdb/TextLine instead.
func (Expanded) DrawMultilineString ¶
func (self Expanded) DrawMultilineString(canvas_item RID.CanvasItem, pos Vector2.XY, text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, max_lines int, modulate Color.RGBA, brk_flags TextServer.LineBreakFlag, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation)
Breaks 'text' into lines using rules specified by 'brk_flags' and draws it into a canvas item using the font, at a given position, with 'modulate' color, optionally clipping the width and aligning horizontally. 'pos' specifies the baseline of the first line, not the top. To draw from the top, ascent must be added to the Y axis.
See also graphics.gd/classdb/CanvasItem.Instance.DrawMultilineString.
func (Expanded) DrawMultilineStringOutline ¶
func (self Expanded) DrawMultilineStringOutline(canvas_item RID.CanvasItem, pos Vector2.XY, text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, max_lines int, size int, modulate Color.RGBA, brk_flags TextServer.LineBreakFlag, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation)
Breaks 'text' to the lines using rules specified by 'brk_flags' and draws text outline into a canvas item using the font, at a given position, with 'modulate' color and 'size' outline size, optionally clipping the width and aligning horizontally. 'pos' specifies the baseline of the first line, not the top. To draw from the top, ascent must be added to the Y axis.
See also graphics.gd/classdb/CanvasItem.Instance.DrawMultilineStringOutline.
func (Expanded) DrawString ¶
func (self Expanded) DrawString(canvas_item RID.CanvasItem, pos Vector2.XY, text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, modulate Color.RGBA, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation)
Draw 'text' into a canvas item using the font, at a given position, with 'modulate' color, optionally clipping the width and aligning horizontally. 'pos' specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.
See also graphics.gd/classdb/CanvasItem.Instance.DrawString.
func (Expanded) DrawStringOutline ¶
func (self Expanded) DrawStringOutline(canvas_item RID.CanvasItem, pos Vector2.XY, text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, size int, modulate Color.RGBA, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation)
Draw 'text' outline into a canvas item using the font, at a given position, with 'modulate' color and 'size' outline size, optionally clipping the width and aligning horizontally. 'pos' specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.
See also graphics.gd/classdb/CanvasItem.Instance.DrawStringOutline.
func (Expanded) FindVariation ¶
func (self Expanded) FindVariation(variation_coordinates map[string]float32, face_index int, strength Float.X, transform Transform2D.OriginXY, spacing_top int, spacing_bottom int, spacing_space int, spacing_glyph int, baseline_offset Float.X) RID.Font
Returns graphics.gd/classdb/TextServer RID of the font cache for specific variation.
func (Expanded) GetAscent ¶
Returns the average font ascent (number of pixels above the baseline).
Note: Real ascent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the ascent of empty line).
func (Expanded) GetDescent ¶
Returns the average font descent (number of pixels below the baseline).
Note: Real descent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the descent of empty line).
func (Expanded) GetHeight ¶
Returns the total average font height (ascent plus descent) in pixels.
Note: Real height of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the height of empty line).
func (Expanded) GetMultilineStringSize ¶
func (self Expanded) GetMultilineStringSize(text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, max_lines int, brk_flags TextServer.LineBreakFlag, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation) Vector2.XY
Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account.
See also Instance.DrawMultilineString.
func (Expanded) GetStringSize ¶
func (self Expanded) GetStringSize(text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation) Vector2.XY
Returns the size of a bounding box of a single-line string, taking kerning, advance and subpixel positioning into account. See also Instance.GetMultilineStringSize and Instance.DrawString.
For example, to get the string size as displayed by a single-line Label, use:
Note: Since kerning, advance and subpixel positioning are taken into account by Instance.GetStringSize, using separate Instance.GetStringSize calls on substrings of a string then adding the results together will return a different result compared to using a single Instance.GetStringSize call on the full string.
Note: Real height of the string is context-dependent and can be significantly different from the value returned by Instance.GetHeight.
func (Expanded) GetUnderlinePosition ¶
Returns average pixel offset of the underline below the baseline.
Note: Real underline position of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
func (Expanded) GetUnderlineThickness ¶
Returns average thickness of the underline.
Note: Real underline thickness of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
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]) 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 ¶
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) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) DrawChar ¶
func (self Instance) DrawChar(canvas_item RID.CanvasItem, pos Vector2.XY, char int, font_size int) Float.X
Draw a single Unicode character 'char' into a canvas item using the font, at a given position, with 'modulate' color. 'pos' specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.
Note: Do not use this function to draw strings character by character, use Instance.DrawString or graphics.gd/classdb/TextLine instead.
func (Instance) DrawCharOutline ¶
func (self Instance) DrawCharOutline(canvas_item RID.CanvasItem, pos Vector2.XY, char int, font_size int) Float.X
Draw a single Unicode character 'char' outline into a canvas item using the font, at a given position, with 'modulate' color and 'size' outline size. 'pos' specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.
Note: Do not use this function to draw strings character by character, use Instance.DrawString or graphics.gd/classdb/TextLine instead.
func (Instance) DrawMultilineString ¶
Breaks 'text' into lines using rules specified by 'brk_flags' and draws it into a canvas item using the font, at a given position, with 'modulate' color, optionally clipping the width and aligning horizontally. 'pos' specifies the baseline of the first line, not the top. To draw from the top, ascent must be added to the Y axis.
See also graphics.gd/classdb/CanvasItem.Instance.DrawMultilineString.
func (Instance) DrawMultilineStringOutline ¶
func (self Instance) DrawMultilineStringOutline(canvas_item RID.CanvasItem, pos Vector2.XY, text string)
Breaks 'text' to the lines using rules specified by 'brk_flags' and draws text outline into a canvas item using the font, at a given position, with 'modulate' color and 'size' outline size, optionally clipping the width and aligning horizontally. 'pos' specifies the baseline of the first line, not the top. To draw from the top, ascent must be added to the Y axis.
See also graphics.gd/classdb/CanvasItem.Instance.DrawMultilineStringOutline.
func (Instance) DrawString ¶
Draw 'text' into a canvas item using the font, at a given position, with 'modulate' color, optionally clipping the width and aligning horizontally. 'pos' specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.
See also graphics.gd/classdb/CanvasItem.Instance.DrawString.
func (Instance) DrawStringOutline ¶
Draw 'text' outline into a canvas item using the font, at a given position, with 'modulate' color and 'size' outline size, optionally clipping the width and aligning horizontally. 'pos' specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.
See also graphics.gd/classdb/CanvasItem.Instance.DrawStringOutline.
func (Instance) FindVariation ¶
Returns graphics.gd/classdb/TextServer RID of the font cache for specific variation.
func (Instance) GetAscent ¶
Returns the average font ascent (number of pixels above the baseline).
Note: Real ascent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the ascent of empty line).
func (Instance) GetCharSize ¶
Returns the size of a character. Does not take kerning into account.
Note: Do not use this function to calculate width of the string character by character, use Instance.GetStringSize or graphics.gd/classdb/TextLine instead. The height returned is the font height (see also Instance.GetHeight) and has no relation to the glyph height.
func (Instance) GetDescent ¶
Returns the average font descent (number of pixels below the baseline).
Note: Real descent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the descent of empty line).
func (Instance) GetFaceCount ¶
Returns number of faces in the TrueType / OpenType collection.
func (Instance) GetFontStretch ¶
Returns font stretch amount, compared to a normal width. A percentage value between 50% and 200%.
func (Instance) GetFontStyle ¶
func (self Instance) GetFontStyle() TextServer.FontStyle
Returns font style flags, see [TextServer.FontStyle].
func (Instance) GetFontStyleName ¶
Returns font style name.
func (Instance) GetFontWeight ¶
Returns weight (boldness) of the font. A value in the 100...999 range, normal font weight is 400, bold font weight is 700.
func (Instance) GetHeight ¶
Returns the total average font height (ascent plus descent) in pixels.
Note: Real height of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the height of empty line).
func (Instance) GetMultilineStringSize ¶
Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account.
See also Instance.DrawMultilineString.
func (Instance) GetOpentypeFeatures ¶
Returns a set of OpenType feature tags. More info: OpenType feature tags.
func (Instance) GetOtNameStrings ¶
Returns data structure with OpenType font name strings (localized font names, version, description, license information, sample text, etc.).
func (Instance) GetRids ¶
Returns slice of valid graphics.gd/classdb/Font [Resource.ID]s, which can be passed to the graphics.gd/classdb/TextServer methods.
func (Instance) GetSpacing ¶
func (self Instance) GetSpacing(spacing TextServer.SpacingType) int
Returns the spacing for the given type (see [TextServer.SpacingType]).
func (Instance) GetStringSize ¶
Returns the size of a bounding box of a single-line string, taking kerning, advance and subpixel positioning into account. See also Instance.GetMultilineStringSize and Instance.DrawString.
For example, to get the string size as displayed by a single-line Label, use:
Note: Since kerning, advance and subpixel positioning are taken into account by Instance.GetStringSize, using separate Instance.GetStringSize calls on substrings of a string then adding the results together will return a different result compared to using a single Instance.GetStringSize call on the full string.
Note: Real height of the string is context-dependent and can be significantly different from the value returned by Instance.GetHeight.
func (Instance) GetSupportedChars ¶
Returns a string containing all the characters available in the font.
If a given character is included in more than one font data source, it appears only once in the returned string.
func (Instance) GetSupportedFeatureList ¶
func (self Instance) GetSupportedFeatureList() map[string]OpenTypeFeature
Returns list of OpenType features supported by font.
func (Instance) GetSupportedVariationList ¶
func (self Instance) GetSupportedVariationList() map[string]map[string]struct { X int32 Y int32 Z int32 }
Returns list of supported variation coordinates, each coordinate is returned as tag: Vector3i(min_value,max_value,default_value).
Font variations allow for continuous change of glyph characteristics along some given design axis, such as weight, width or slant.
To print available variation axes of a variable font:
Note: To set and get variation coordinates of a graphics.gd/classdb/FontVariation, use graphics.gd/classdb/FontVariation.Instance.VariationOpentype.
func (Instance) GetUnderlinePosition ¶
Returns average pixel offset of the underline below the baseline.
Note: Real underline position of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
func (Instance) GetUnderlineThickness ¶
Returns average thickness of the underline.
Note: Real underline thickness of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate.
func (Instance) IsLanguageSupported ¶
Returns true, if font supports given language (ISO 639 code).
func (Instance) IsScriptSupported ¶
Returns true, if font supports given script (ISO 15924 code).
func (Instance) SetCacheCapacity ¶
Sets LRU cache capacity for draw_* methods.