Font
The base font resource and text measurement API.
Font describes a font and fallback fonts. Control/Theme normally sets text size, so one resource can serve several sizes. Use FontFile for an imported file, FontVariation for a variation and SystemFont for an OS-installed family.
C# character units, Unicode code points and rendered glyphs can have different counts. Measure with the same font, size and shaping settings used for drawing. Check required languages and export: a file does not guarantee every glyph.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties1
FallbacksProperty
public Reckfell.Collections.Array<Font> Fallbacks { get; set; }Fallback fonts for missing glyphs. Check target-language coverage, metrics and resource export; a fallback list does not guarantee every Unicode string.
Methods47
DrawChar2 overloads
public float DrawChar(Rid canvasItem, Vector2 pos, long @char, int fontSize, Color? modulate);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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
Note: Do not use this function to draw strings character by character, use Font.DrawString or TextLine instead.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
char | long | — |
fontSize | int | — |
modulate | Color? | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
floatpublic float DrawChar(Rid canvasItem, Vector2 pos, long @char, int fontSize, Color? modulate = default, float oversampling = 0f);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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
Note: Do not use this function to draw strings character by character, use Font.DrawString or TextLine instead.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
char | long | — |
fontSize | int | — |
modulate | Color? | default |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
floatDrawCharOutline2 overloads
public float DrawCharOutline(Rid canvasItem, Vector2 pos, long @char, int fontSize, int size, Color? modulate);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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
Note: Do not use this function to draw strings character by character, use Font.DrawString or TextLine instead.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
char | long | — |
fontSize | int | — |
size | int | — |
modulate | Color? | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
floatpublic float DrawCharOutline(Rid canvasItem, Vector2 pos, long @char, int fontSize, int size = -1, Color? modulate = default, float oversampling = 0f);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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
Note: Do not use this function to draw strings character by character, use Font.DrawString or TextLine instead.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
char | long | — |
fontSize | int | — |
size | int | -1 |
modulate | Color? | default |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
floatDrawMultilineString2 overloads
public void DrawMultilineString(Rid canvasItem, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, int maxLines, Color? modulate, TextServer.LineBreakFlag brkFlags, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation 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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
See also CanvasItem.DrawMultilineString.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | — |
width | float | — |
fontSize | int | — |
maxLines | int | — |
modulate | Color? | — |
brkFlags | TextServer.LineBreakFlag | — |
justificationFlags | TextServer.JustificationFlag | — |
direction | TextServer.Direction | — |
orientation | TextServer.Orientation | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawMultilineString(Rid canvasItem, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int maxLines = -1, Color? modulate = default, TextServer.LineBreakFlag brkFlags = TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
See also CanvasItem.DrawMultilineString.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
maxLines | int | -1 |
modulate | Color? | default |
brkFlags | TextServer.LineBreakFlag | TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawMultilineStringOutline2 overloads
public void DrawMultilineStringOutline(Rid canvasItem, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, int maxLines, int size, Color? modulate, TextServer.LineBreakFlag brkFlags, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation 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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
See also CanvasItem.DrawMultilineStringOutline.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | — |
width | float | — |
fontSize | int | — |
maxLines | int | — |
size | int | — |
modulate | Color? | — |
brkFlags | TextServer.LineBreakFlag | — |
justificationFlags | TextServer.JustificationFlag | — |
direction | TextServer.Direction | — |
orientation | TextServer.Orientation | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawMultilineStringOutline(Rid canvasItem, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int maxLines = -1, int size = 1, Color? modulate = default, TextServer.LineBreakFlag brkFlags = TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
See also CanvasItem.DrawMultilineStringOutline.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
maxLines | int | -1 |
size | int | 1 |
modulate | Color? | default |
brkFlags | TextServer.LineBreakFlag | TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawString2 overloads
public void DrawString(Rid canvasItem, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, Color? modulate, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation 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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
See also CanvasItem.DrawString.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | — |
width | float | — |
fontSize | int | — |
modulate | Color? | — |
justificationFlags | TextServer.JustificationFlag | — |
direction | TextServer.Direction | — |
orientation | TextServer.Orientation | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawString(Rid canvasItem, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, Color? modulate = default, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
See also CanvasItem.DrawString.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
modulate | Color? | default |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawStringOutline2 overloads
public void DrawStringOutline(Rid canvasItem, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, int size, Color? modulate, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation 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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
See also CanvasItem.DrawStringOutline.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | — |
width | float | — |
fontSize | int | — |
size | int | — |
modulate | Color? | — |
justificationFlags | TextServer.JustificationFlag | — |
direction | TextServer.Direction | — |
orientation | TextServer.Orientation | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawStringOutline(Rid canvasItem, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int size = 1, Color? modulate = default, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
See also CanvasItem.DrawStringOutline.
| Name | Type | Default |
|---|---|---|
canvasItem | Rid | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
size | int | 1 |
modulate | Color? | default |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
FindVariation5 overloads
public Rid FindVariation(Reckfell.Collections.Dictionary variationCoordinates, int faceIndex, float strength, Transform2D? transform);Returns TextServer RID of the font cache for specific variation.
| Name | Type | Default |
|---|---|---|
variationCoordinates | Reckfell.Collections.Dictionary | — |
faceIndex | int | — |
strength | float | — |
transform | Transform2D? | — |
transformIf the parameter is null, then the default value is Transform2D.Identity.
Ridpublic Rid FindVariation(Reckfell.Collections.Dictionary variationCoordinates, int faceIndex, float strength, Transform2D? transform, int spacingTop, int spacingBottom, int spacingSpace, int spacingGlyph);Returns TextServer RID of the font cache for specific variation.
| Name | Type | Default |
|---|---|---|
variationCoordinates | Reckfell.Collections.Dictionary | — |
faceIndex | int | — |
strength | float | — |
transform | Transform2D? | — |
spacingTop | int | — |
spacingBottom | int | — |
spacingSpace | int | — |
spacingGlyph | int | — |
transformIf the parameter is null, then the default value is Transform2D.Identity.
Ridpublic Rid FindVariation(Reckfell.Collections.Dictionary variationCoordinates, int faceIndex, float strength, Transform2D? transform, int spacingTop, int spacingBottom, int spacingSpace, int spacingGlyph, float baselineOffset);Returns TextServer RID of the font cache for specific variation.
| Name | Type | Default |
|---|---|---|
variationCoordinates | Reckfell.Collections.Dictionary | — |
faceIndex | int | — |
strength | float | — |
transform | Transform2D? | — |
spacingTop | int | — |
spacingBottom | int | — |
spacingSpace | int | — |
spacingGlyph | int | — |
baselineOffset | float | — |
transformIf the parameter is null, then the default value is Transform2D.Identity.
Ridpublic Rid FindVariation(Reckfell.Collections.Dictionary variationCoordinates, int faceIndex = 0, float strength = 0f, Transform2D? transform = default, int spacingTop = 0, int spacingBottom = 0, int spacingSpace = 0, int spacingGlyph = 0, float baselineOffset = 0f, long paletteIndex = 0, Color[] customColors = null);Returns TextServer RID of the font cache for specific variation.
| Name | Type | Default |
|---|---|---|
variationCoordinates | Reckfell.Collections.Dictionary | — |
faceIndex | int | 0 |
strength | float | 0f |
transform | Transform2D? | default |
spacingTop | int | 0 |
spacingBottom | int | 0 |
spacingSpace | int | 0 |
spacingGlyph | int | 0 |
baselineOffset | float | 0f |
paletteIndex | long | 0 |
customColors | Color[] | null |
transformIf the parameter is null, then the default value is Transform2D.Identity.
customColorsIf the parameter is null, then the default value is Array.Empty<Color>().
Ridpublic Rid FindVariation(Reckfell.Collections.Dictionary variationCoordinates, int faceIndex, float strength, Transform2D? transform, int spacingTop, int spacingBottom, int spacingSpace, int spacingGlyph, float baselineOffset, long paletteIndex, ReadOnlySpan<Color> customColors);Returns TextServer RID of the font cache for specific variation.
| Name | Type | Default |
|---|---|---|
variationCoordinates | Reckfell.Collections.Dictionary | — |
faceIndex | int | — |
strength | float | — |
transform | Transform2D? | — |
spacingTop | int | — |
spacingBottom | int | — |
spacingSpace | int | — |
spacingGlyph | int | — |
baselineOffset | float | — |
paletteIndex | long | — |
customColors | ReadOnlySpan<Color> | — |
transformIf the parameter is null, then the default value is Transform2D.Identity.
RidGetAscentfloat
public float GetAscent(int fontSize = 16);Returns the maximum font ascent (number of pixels above the baseline) of this font and all fallback fonts. 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).
| Name | Type | Default |
|---|---|---|
fontSize | int | 16 |
floatGetCharSizeVector2
public Vector2 GetCharSize(long @char, int fontSize);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 Font.GetStringSize or TextLine instead. The height returned is the font height (see also Font.GetHeight) and has no relation to the glyph height.
| Name | Type | Default |
|---|---|---|
char | long | — |
fontSize | int | — |
Vector2GetDescentfloat
public float GetDescent(int fontSize = 16);Returns the maximum font descent (number of pixels below the baseline) of this font and all fallback fonts. 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).
| Name | Type | Default |
|---|---|---|
fontSize | int | 16 |
floatGetFaceCountlong
public long GetFaceCount();Returns number of faces in the TrueType / OpenType collection.
longGetFallbacksReckfell.Collections.Array<Font>
public Reckfell.Collections.Array<Font> GetFallbacks();Reckfell.Collections.Array<Font>GetFontNamestring
public string GetFontName();Returns font family name.
stringGetFontStretchint
public int GetFontStretch();Returns font stretch amount, compared to a normal width. A percentage value between 50% and 200%.
intGetFontStyleTextServer.FontStyle
public TextServer.FontStyle GetFontStyle();Returns font style flags.
TextServer.FontStyleGetFontStyleNamestring
public string GetFontStyleName();Returns font style name.
stringGetFontWeightint
public int GetFontWeight();Returns weight (boldness) of the font. A value in the 100...999 range, normal font weight is 400, bold font weight is 700.
intGetHeightfloat
public float GetHeight(int fontSize = 16);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).
| Name | Type | Default |
|---|---|---|
fontSize | int | 16 |
floatGetMultilineStringSizeVector2
public Vector2 GetMultilineStringSize(string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int maxLines = -1, TextServer.LineBreakFlag brkFlags = TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal);Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account.
See also Font.DrawMultilineString.
| Name | Type | Default |
|---|---|---|
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
maxLines | int | -1 |
brkFlags | TextServer.LineBreakFlag | TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
Vector2GetOpentypeFeaturesReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary GetOpentypeFeatures();Returns a set of OpenType feature tags. More info: OpenType feature tags.
Reckfell.Collections.DictionaryGetOtNameStringsReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary GetOtNameStrings();Returns Reckfell.Collections.Dictionary with OpenType font name strings (localized font names, version, description, license information, sample text, etc.).
Reckfell.Collections.DictionaryGetPaletteColorsColor[]
public Color[] GetPaletteColors(long index);Returns the array in the predefined color palette at index. Palette contains all colors used to render font glyphs. Each palette has the same number of colors. Colors can be overridden using FontVariation.
| Name | Type | Default |
|---|---|---|
index | long | — |
Color[]GetPaletteCountlong
public long GetPaletteCount();Returns the number of predefined color palettes. Palette contains all colors used to render font glyphs. Each palette has the same number of colors.
longGetPaletteNamestring
public string GetPaletteName(long index);Returns the name of the predefined color palette at index. Palette contains all colors used to render font glyphs. Each palette has the same number of colors.
| Name | Type | Default |
|---|---|---|
index | long | — |
stringGetRidsReckfell.Collections.Array<Rid>
public Reckfell.Collections.Array<Rid> GetRids();Returns Reckfell.Collections.Array of valid Font Rids, which can be passed to the TextServer methods.
Reckfell.Collections.Array<Rid>GetSpacingint
public int GetSpacing(TextServer.SpacingType spacing);Returns the amount of spacing for the given spacing type.
| Name | Type | Default |
|---|---|---|
spacing | TextServer.SpacingType | — |
intGetStringSizeVector2
public Vector2 GetStringSize(string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal);Returns the size of a bounding box of a single-line string, taking kerning, advance and subpixel positioning into account. See also Font.GetMultilineStringSize and Font.DrawString.
For example, to get the string size as displayed by a single-line Label, use:
Label label = GetEntity<Label>("Label");
Vector2 stringSize = label.GetThemeFont("font").GetStringSize(label.Text, HorizontalAlignment.Left, -1, label.GetThemeFontSize("font_size"));Note: Since kerning, advance and subpixel positioning are taken into account by Font.GetStringSize, using separate Font.GetStringSize calls on substrings of a string then adding the results together will return a different result compared to using a single Font.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 Font.GetHeight.
| Name | Type | Default |
|---|---|---|
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
Vector2GetSupportedCharsstring
public string 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.
stringGetSupportedFeatureListReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary GetSupportedFeatureList();Returns list of OpenType features supported by font.
Reckfell.Collections.DictionaryGetSupportedVariationListReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary GetSupportedVariationList();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 FontVariation, use FontVariation.VariationOpentype.
Reckfell.Collections.DictionaryGetUnderlinePositionfloat
public float GetUnderlinePosition(int fontSize = 16);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.
| Name | Type | Default |
|---|---|---|
fontSize | int | 16 |
floatGetUnderlineThicknessfloat
public float GetUnderlineThickness(int fontSize = 16);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.
| Name | Type | Default |
|---|---|---|
fontSize | int | 16 |
floatHasCharbool
public bool HasChar(long @char);Returns true if a Unicode char is available in the font.
| Name | Type | Default |
|---|---|---|
char | long | — |
boolIsLanguageSupportedbool
public bool IsLanguageSupported(string language);Returns true if the font supports the given language (as a ISO 639 code).
| Name | Type | Default |
|---|---|---|
language | string | — |
boolIsScriptSupportedbool
public bool IsScriptSupported(string script);Returns true if the font supports the given script (as a ISO 15924 code).
| Name | Type | Default |
|---|---|---|
script | string | — |
boolSetCacheCapacityvoid
public void SetCacheCapacity(int singleLine, int multiLine);Sets LRU cache capacity for draw_* methods.
| Name | Type | Default |
|---|---|---|
singleLine | int | — |
multiLine | int | — |
SetFallbacksvoid
public void SetFallbacks(Reckfell.Collections.Array<Font> fallbacks);| Name | Type | Default |
|---|---|---|
fallbacks | Reckfell.Collections.Array<Font> | — |