Module ctr.gfx.font

The gfx.font module

Usage:

    local font = require("ctr.gfx.font")

Functions

load (path) Load a font.
setDefault (font) Set a font as the default one.
getDefault () Return the default font.
setSize (size) Set the default text size.
getSize () Return the default text size.

font object

:width (text[, font=default size]) Return the width of a string with a font.
:unload () Unload a font.


Functions

load (path)
Load a font. Supported formats: TTF, OTF, TTC, OTC, WOFF, PFA, PFB, PCF, FNT, BDF, PFR, and others. ctrµLua support all formats supported by FreeType. See here for a more complete list: http://freetype.org/freetype2/docs/index.html

Parameters:

  • path string path to the file

Returns:

    font the loaded font.

Or

  1. nil if an error occurred
  2. string error message
setDefault (font)
Set a font as the default one.

Parameters:

  • font font the font to set as the default one.
getDefault ()
Return the default font.

Returns:

    font default font
setSize (size)
Set the default text size.

Parameters:

  • size number new default text size
getSize ()
Return the default text size.

Returns:

    number the default text size

font object

:width (text[, font=default size])
Return the width of a string with a font.

Parameters:

  • text string the text to test
  • font integer size, in pixels (default default size)

Returns:

    number the width of the text (in pixels)
:unload ()
Unload a font.
generated by LDoc 1.4.3 Last updated 2017-06-05 14:35:27