font_base
This type represents the base class for font types. You cannot create an instance of this type. Instead, use the children types.
This type inherits managed
type. All of its base methods and fields are also available in this type.
Definitions:
codepoint: Unicode representation of the character.
kerning: a distance between two characters.
glyph: visual representation of a character.
height
Type: float
Font height, in pixels.
ascent
Type: float
Font ascent value, in pixels.
descent
Type: float
Font descent value, in pixels.
line_gap
Type: float
Font line gap, in pixels.
kerning_gap
Type: float
Font kerning gap, in pixels.
outline_alpha
Type: float
Font outline opacity (0
to 1
). Defaults to 0.45
.
flags
Type: font_flags
Font flags. Use bit
library to read flags.
y_offset
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.
x_offset
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.
fallback_font
Type: font_base
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.
dropshadow_color
Type: color
Shadow color. Only R, G, B values are used.
get_kerned_char_width
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
get_kerning
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
get_text_size
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
wrap_text
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
get_glyph
Returns glyph information for a character.
Arguments
Name
Type
Description
codepoint
int
Codepoint.
Returns
Type
Description
Glyph information.
Example
get_texture
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