reckfellENGINE

Font

The base font resource and text measurement API.

On this page
class FontReckfellSharpInherits Resource

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.

Working example.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Properties1

FallbacksProperty
# Fallbacks
C#
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
# DrawChar · 1/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
charlong—
fontSizeint—
modulateColor?—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

Returns float
# DrawChar · 2/2
C#
public 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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
charlong—
fontSizeint—
modulateColor?default
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

Returns float
DrawCharOutline2 overloads
# DrawCharOutline · 1/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
charlong—
fontSizeint—
sizeint—
modulateColor?—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

Returns float
# DrawCharOutline · 2/2
C#
public 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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
charlong—
fontSizeint—
sizeint-1
modulateColor?default
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

Returns float
DrawMultilineString2 overloads
# DrawMultilineString · 1/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
textstring—
alignmentHorizontalAlignment—
widthfloat—
fontSizeint—
maxLinesint—
modulateColor?—
brkFlagsTextServer.LineBreakFlag—
justificationFlagsTextServer.JustificationFlag—
directionTextServer.Direction—
orientationTextServer.Orientation—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawMultilineString · 2/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
maxLinesint-1
modulateColor?default
brkFlagsTextServer.LineBreakFlagTextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawMultilineStringOutline2 overloads
# DrawMultilineStringOutline · 1/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
textstring—
alignmentHorizontalAlignment—
widthfloat—
fontSizeint—
maxLinesint—
sizeint—
modulateColor?—
brkFlagsTextServer.LineBreakFlag—
justificationFlagsTextServer.JustificationFlag—
directionTextServer.Direction—
orientationTextServer.Orientation—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawMultilineStringOutline · 2/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
maxLinesint-1
sizeint1
modulateColor?default
brkFlagsTextServer.LineBreakFlagTextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawString2 overloads
# DrawString · 1/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
textstring—
alignmentHorizontalAlignment—
widthfloat—
fontSizeint—
modulateColor?—
justificationFlagsTextServer.JustificationFlag—
directionTextServer.Direction—
orientationTextServer.Orientation—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawString · 2/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
modulateColor?default
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawStringOutline2 overloads
# DrawStringOutline · 1/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
textstring—
alignmentHorizontalAlignment—
widthfloat—
fontSizeint—
sizeint—
modulateColor?—
justificationFlagsTextServer.JustificationFlag—
directionTextServer.Direction—
orientationTextServer.Orientation—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawStringOutline · 2/2
C#
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.

Parameters
NameTypeDefault
canvasItemRid—
posVector2—
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
sizeint1
modulateColor?default
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

FindVariation5 overloads
# FindVariation · 1/5
C#
public Rid FindVariation(Reckfell.Collections.Dictionary variationCoordinates, int faceIndex, float strength, Transform2D? transform);

Returns TextServer RID of the font cache for specific variation.

Parameters
NameTypeDefault
variationCoordinatesReckfell.Collections.Dictionary—
faceIndexint—
strengthfloat—
transformTransform2D?—
transform

If the parameter is null, then the default value is Transform2D.Identity.

Returns Rid
# FindVariation · 2/5
C#
public 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.

Parameters
NameTypeDefault
variationCoordinatesReckfell.Collections.Dictionary—
faceIndexint—
strengthfloat—
transformTransform2D?—
spacingTopint—
spacingBottomint—
spacingSpaceint—
spacingGlyphint—
transform

If the parameter is null, then the default value is Transform2D.Identity.

Returns Rid
# FindVariation · 3/5
C#
public 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.

Parameters
NameTypeDefault
variationCoordinatesReckfell.Collections.Dictionary—
faceIndexint—
strengthfloat—
transformTransform2D?—
spacingTopint—
spacingBottomint—
spacingSpaceint—
spacingGlyphint—
baselineOffsetfloat—
transform

If the parameter is null, then the default value is Transform2D.Identity.

Returns Rid
# FindVariation · 4/5
C#
public 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.

Parameters
NameTypeDefault
variationCoordinatesReckfell.Collections.Dictionary—
faceIndexint0
strengthfloat0f
transformTransform2D?default
spacingTopint0
spacingBottomint0
spacingSpaceint0
spacingGlyphint0
baselineOffsetfloat0f
paletteIndexlong0
customColorsColor[]null
transform

If the parameter is null, then the default value is Transform2D.Identity.

customColors

If the parameter is null, then the default value is Array.Empty<Color>().

Returns Rid
# FindVariation · 5/5
C#
public 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.

Parameters
NameTypeDefault
variationCoordinatesReckfell.Collections.Dictionary—
faceIndexint—
strengthfloat—
transformTransform2D?—
spacingTopint—
spacingBottomint—
spacingSpaceint—
spacingGlyphint—
baselineOffsetfloat—
paletteIndexlong—
customColorsReadOnlySpan<Color>—
transform

If the parameter is null, then the default value is Transform2D.Identity.

Returns Rid
GetAscentfloat
# GetAscent
C#
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).

Parameters
NameTypeDefault
fontSizeint16
Returns float
GetCharSizeVector2
# GetCharSize
C#
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.

Parameters
NameTypeDefault
charlong—
fontSizeint—
Returns Vector2
GetDescentfloat
# GetDescent
C#
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).

Parameters
NameTypeDefault
fontSizeint16
Returns float
GetFaceCountlong
# GetFaceCount
C#
public long GetFaceCount();

Returns number of faces in the TrueType / OpenType collection.

Returns long
GetFallbacksReckfell.Collections.Array<Font>
# GetFallbacks
C#
public Reckfell.Collections.Array<Font> GetFallbacks();
Returns Reckfell.Collections.Array<Font>
GetFontNamestring
# GetFontName
C#
public string GetFontName();

Returns font family name.

Returns string
GetFontStretchint
# GetFontStretch
C#
public int GetFontStretch();

Returns font stretch amount, compared to a normal width. A percentage value between 50% and 200%.

Returns int
GetFontStyleTextServer.FontStyle
# GetFontStyle
C#
public TextServer.FontStyle GetFontStyle();

Returns font style flags.

Returns TextServer.FontStyle
GetFontStyleNamestring
# GetFontStyleName
C#
public string GetFontStyleName();

Returns font style name.

Returns string
GetFontWeightint
# GetFontWeight
C#
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.

Returns int
GetHeightfloat
# GetHeight
C#
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).

Parameters
NameTypeDefault
fontSizeint16
Returns float
GetMultilineStringSizeVector2
# GetMultilineStringSize
C#
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.

Parameters
NameTypeDefault
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
maxLinesint-1
brkFlagsTextServer.LineBreakFlagTextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
Returns Vector2
GetOpentypeFeaturesReckfell.Collections.Dictionary
# GetOpentypeFeatures
C#
public Reckfell.Collections.Dictionary GetOpentypeFeatures();

Returns a set of OpenType feature tags. More info: OpenType feature tags.

Returns Reckfell.Collections.Dictionary
GetOtNameStringsReckfell.Collections.Dictionary
# GetOtNameStrings
C#
public Reckfell.Collections.Dictionary GetOtNameStrings();

Returns Reckfell.Collections.Dictionary with OpenType font name strings (localized font names, version, description, license information, sample text, etc.).

Returns Reckfell.Collections.Dictionary
GetPaletteColorsColor[]
# GetPaletteColors
C#
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.

Parameters
NameTypeDefault
indexlong—
Returns Color[]
GetPaletteCountlong
# GetPaletteCount
C#
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.

Returns long
GetPaletteNamestring
# GetPaletteName
C#
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.

Parameters
NameTypeDefault
indexlong—
Returns string
GetRidsReckfell.Collections.Array<Rid>
# GetRids
C#
public Reckfell.Collections.Array<Rid> GetRids();

Returns Reckfell.Collections.Array of valid Font Rids, which can be passed to the TextServer methods.

Returns Reckfell.Collections.Array<Rid>
GetSpacingint
# GetSpacing
C#
public int GetSpacing(TextServer.SpacingType spacing);

Returns the amount of spacing for the given spacing type.

Parameters
NameTypeDefault
spacingTextServer.SpacingType—
Returns int
GetStringSizeVector2
# GetStringSize
C#
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:

C#
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.

Parameters
NameTypeDefault
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
Returns Vector2
GetSupportedCharsstring
# GetSupportedChars
C#
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.

Returns string
GetSupportedFeatureListReckfell.Collections.Dictionary
# GetSupportedFeatureList
C#
public Reckfell.Collections.Dictionary GetSupportedFeatureList();

Returns list of OpenType features supported by font.

Returns Reckfell.Collections.Dictionary
GetSupportedVariationListReckfell.Collections.Dictionary
# GetSupportedVariationList
C#
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.

Returns Reckfell.Collections.Dictionary
GetUnderlinePositionfloat
# GetUnderlinePosition
C#
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.

Parameters
NameTypeDefault
fontSizeint16
Returns float
GetUnderlineThicknessfloat
# GetUnderlineThickness
C#
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.

Parameters
NameTypeDefault
fontSizeint16
Returns float
HasCharbool
# HasChar
C#
public bool HasChar(long @char);

Returns true if a Unicode char is available in the font.

Parameters
NameTypeDefault
charlong—
Returns bool
IsLanguageSupportedbool
# IsLanguageSupported
C#
public bool IsLanguageSupported(string language);

Returns true if the font supports the given language (as a ISO 639 code).

Parameters
NameTypeDefault
languagestring—
Returns bool
IsScriptSupportedbool
# IsScriptSupported
C#
public bool IsScriptSupported(string script);

Returns true if the font supports the given script (as a ISO 15924 code).

Parameters
NameTypeDefault
scriptstring—
Returns bool
SetCacheCapacityvoid
# SetCacheCapacity
C#
public void SetCacheCapacity(int singleLine, int multiLine);

Sets LRU cache capacity for draw_* methods.

Parameters
NameTypeDefault
singleLineint—
multiLineint—
SetFallbacksvoid
# SetFallbacks
C#
public void SetFallbacks(Reckfell.Collections.Array<Font> fallbacks);
Parameters
NameTypeDefault
fallbacksReckfell.Collections.Array<Font>—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.