™️FontBase

This type represents the base class for font types. You cannot create an instance of this type. Instead, use the children types.

circle-info

This type inherits Managed type. All of its base methods and fields are also available in this type.

circle-info

Definitions:

  • codepoint: Unicode representation of the character.

  • kerning: a distance between two characters.

  • glyph: visual representation of a character.

height

FieldRead only

Type: float

Font height, in pixels.


ascent

Field

Type: float

Font ascent value, in pixels.


descent

Field

Type: float

Font descent value, in pixels.


lineGap

Field

Type: float

Font line gap, in pixels.


kerningGap

Field

Type: float

Font kerning gap, in pixels.


outlineAlpha

Field

Type: float

Font outline opacity (0 to 1). Defaults to 0.45.


flags

FieldRead only

Type: FontFlags

Font flags. Use bit library to read flags.


yOffset

Field

Type: int

Glyph Y offset, in pixels. Will alter the location of a glyph in the atlas. Changing this value after the font was created is meaningless.


xOffset

Field

Type: int

Glyph X offset, in pixels. Will alter the location of a glyph in the atlas. Changing this value after the font was created is meaningless.


fallbackFont

Field

Type: FontBase

Fallback font to use, in case a glyph is not found in this font. Is it useful when one font does not have codepoints for specific symbols, that are present in another font, but you still want to prefer this font's glyphs over other font.


dropshadowColor

Field

Type: Color

Shadow color. Only R, G, B values are used.


GetKernedCharWidth

Method

Returns character width, included with kerning.

Arguments

Name

Type

Description

left

int

Previous character codepoint.

right

int

Current character codepoint.

Returns

Type

Description

float

Distance, in pixels.

Example


GetKerning

Method

Returns kerning value for a single character. If kerning is disabled, will instead return kerning gap.

Arguments

Name

Type

Description

cp

int

Codepoint.

Returns

Type

Description

float

Kerning value, in pixels.

Example


GetTextSize

Method

Returns text area size.

Arguments

Name

Type

Description

text

string

Text.

skip_scaling

bool

If set to true, will skip global DPI scaling. Defaults to false.

til_newline

bool

Calculate size only until a line break is met. Defaults to false.

Returns

Type

Description

Text area size.

Example


WrapText

Method

Wraps text to meet the desired width. Wrapping is done by breaking text by words and inserting line breaks in between. If one of the words is longer than the target width, will instead use that word's width.

Arguments

Name

Type

Description

text

string

Text to wrap.

width

float

Target width.

Returns

Type

Description

string

Wrapped text.

Example


GetGlyph

Method

Returns glyph information for a character.

Arguments

Name

Type

Description

codepoint

int

Codepoint.

Returns

Type

Description

Glyph information.

Example


GetTexture

Method

Returns a texture atlas that contains the provided glyph.

Arguments

Name

Type

Description

gl

Character glyph.

Returns

Type

Description

int

Texture pointer, or nil if not found.

Example

Last updated