Fonts#

EG-Overlay uses FreeType2 to render font glyphs on screen. This means that any font that FreeType2 supports can be used, however, module authors are encouraged to use the default fonts detailed below.

Fonts can be accessed using the getfont() function in the eg-overlay-ui module.

Default Fonts#

EG-Overlay comes with 3 default fonts:

Each of the above fonts are initialized with default values and can be accessed in a fonts table on the eg-overlay-ui module as regular, monospace, and icon.

Example#
local ui = require 'eg-overlay-ui'

local regfont = ui.fonts.regular
local monofont = ui.fonts.monospace
local iconfont = ui.fonts.icon

Functions#

eg-overlay-ui.getfont(path, size[, vars])#

Get a font.

If the font hasn’t been loaded yet, it will be initialized first.

Parameters:
  • path (string) – The path to the font file.

  • size (integer) – The font height in pixels.

  • vars (table) – (Optional) A table of font variable values, such as wght.

Return type:

uifont

Example#
local ui = require 'eg-overlay-ui'

local bold = ui.getfont('path/to/font.tff', 14, {wght = 900})

Note

Variables supported will differ for each font. Some fonts will not support variables at all.

Unspecified, unsupported font variables or invalid values will be ignored and be given default values.

Inter, the regular default font supports the following variables:

  • slnt: slant

  • wght: weight

CascadeCode, the monospace default font supports the following variables:

  • wght: weight

Google Material Design Icons, the icon default font supports the following variables:

  • FILL: 0 for outlined or 1 for filled icons

  • GRAD: grade, similar to wght

  • opsz: optical size

  • wght: weight

Version History

Version

Notes

0.3.0

Added

Classes#

class eg-overlay-ui.uifont#

A font with a unique combination of size and font variables.

A font is used to render text within the overlay and is most commonly used with uitext elements.

path()#

Return the path of the font file this font was created from.

This exists mostly for debugging purposes.

Return type:

string

Version History

Version

Notes

0.3.0

Added

tosize(newsize)#

Create a new uifont based on this font with a different size.

Parameters:

newsize (integer)

Return type:

uifont

Version History

Version

Notes

0.3.0

Added

tosizeperc(sizepercent)#

Create a new uifont based on this font with a scaled size.

This method can be used to create a font based on the EG-Overlay default fonts, such as a font that is 75% of the default size, etc.

Parameters:

sizepercent (number) – 1.0 is the same size as this font

Return type:

uifont

Version History

Version

Notes

0.3.0

Added