Skip to content

alias DefineFontCallback


(alias) DefineFontCallback = fun(name: string, size: number, id: number) -> (Font|integer)

Define a font from within lua code.

The arguments are the user-supplied information, with negative numbers indicating scaled, positive numbers at

The string name is the filename part of the font specification, as given by the user.

The number size is a bit special:

  • If it is positive, it specifies an “at size” in scaled points.
  • If it is negative, its absolute value represents a “scaled” setting relative to the designsize of the font.

The id is the internal number assigned to the font.

The internal structure of the font table that is to be returned is explained in chapter fonts. That table is saved internally, so you can put extra fields in the table for your later Lua code to use. In alternative, retval can be a previously defined fontid. This is useful if a previous definition can be reused instead of creating a whole new font structure.

Setting this callback to false is pointless as it will prevent font loading completely but will nevertheless generate errors.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!