Module ctr.gfx.font
The gfx.font module
Usage:
local font = require("ctr.gfx.font")
-
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:
Returns:
font
the loaded font.
Or
-
nil
if an error occurred
-
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
-
: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.