Font API documentation

Functions, messages and properties used to manipulate font resources.

Version: alpha

FUNCTIONS
font.add_font() associates a ttf resource to a .fontc file.
font.get_info() Gets information about a font, such as the associa...
font.prewarm_text() prepopulates the font glyph cache with rasterised ...
font.remove_font() associates a ttf resource to a .fontc file

Functions

font.add_font()

font.add_font(fontc,ttf)

associates a ttf resource to a .fontc file.

PARAMETERS

fontc string
hash
The path to the .fontc resource
ttf string
hash
The path to the .ttf resource

EXAMPLES

local font_hash = hash("/assets/fonts/roboto.fontc")
local ttf_hash = hash("/assets/fonts/Roboto/Roboto-Bold.ttf")
font.add_font(font_hash, ttf_hash)

font.get_info()

font.get_info(fontc)

Gets information about a font, such as the associated font files

PARAMETERS

fontc string
hash
The path to the .fontc resource

RETURNS

info table
the information table contains these fields:
path
hash The path hash of the current file.
fonts
table An array of associated font (e.g. .ttf) files. Each item is a table that contains:
path
string The path of the font file
path_hash
hash The path of the font file

font.prewarm_text()

font.prewarm_text(fontc,text,callback)

prepopulates the font glyph cache with rasterised glyphs

PARAMETERS

fontc string
hash
The path to the .fontc resource
text string
The text to layout
[callback] function(self, request_id, result, errstring)
(optional) A callback function that is called after the request is finished
self
object The current object.
request_id
number The request id
result
boolean True if request was succesful
errstring
string nil if the request was successful

RETURNS

request_id number
Returns the asynchronous request id

EXAMPLES

local font_hash = hash("/assets/fonts/roboto.fontc")
font.prewarm_text(font_hash, "Some text", function (self, request_id, result, errstring)
        -- cache is warm, show the text!
    end)

font.remove_font()

font.remove_font(fontc,ttf)

associates a ttf resource to a .fontc file

PARAMETERS

fontc string
hash
The path to the .fontc resource
ttf string
hash
The path to the .ttf resource

EXAMPLES

local font_hash = hash("/assets/fonts/roboto.fontc")
local ttf_hash = hash("/assets/fonts/Roboto/Roboto-Bold.ttf")
font.remove_font(font_hash, ttf_hash)