Internationalized font and text drawing support.
    public abstract class Font : Resource

Font contains a Unicode-compatible character set, as well as the ability to draw it with variable width, ascent, descent and kerning. For creating fonts from TTF files (or other font formats), see the editor support for fonts.

Inheritance Chain

Derived Classes

Methods

    public void Draw(RID canvasItem, Vector2 position, string @string, Color? modulate = default(Color?), int clipW = -1, Color? outlineModulate = default(Color?))

Draw string into a canvas item using the font at a given position, with modulate color, and optionally clipping the width. position specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.

    public float DrawChar(RID canvasItem, Vector2 position, int @char, int next = -1, Color? modulate = default(Color?), bool outline = false)

Draw character char into a canvas item using the font at a given position, with modulate color, and optionally kerning if next is passed. clipping the width. position specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis. The width used by the character is returned, making this function useful for drawing strings character by character.

    public float GetAscent()

Returns the font ascent (number of pixels above the baseline).

    public float GetDescent()

Returns the font descent (number of pixels below the baseline).

    public float GetHeight()

Returns the total font height (ascent plus descent) in pixels.

    public Vector2 GetStringSize(string @string)

Returns the size of a string, taking kerning and advance into account.

    public Vector2 GetWordwrapStringSize(string @string, float width)

    public bool HasOutline()

    public bool IsDistanceFieldHint()

    public void UpdateChanges()

After editing a font (changing size, ascent, char rects, etc.). Call this function to propagate changes to controls that might use it.

Tags: