Functions, messages and properties used to manipulate font resources.
Version: alpha
| RECORDS | |
|---|---|
| font.file_info | Associated font file information |
| font.info | Font resource information |
| FUNCTIONS | |
|---|---|
| font.add_font() | associates a TTF or OTF 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 or OTF resource to a .fontc file |
Associated font file information
FIELDS
path |
string |
path to the .ttf or .otf font file |
path_hash |
hash |
hashed font-file path |
Font resource information
FIELDS
path |
hash |
path hash of the .fontc resource |
fonts |
font.file_info[] |
associated font files |
font.add_font(fontc:string|hash, font:string|hash)
associates a TTF or OTF resource to a .fontc file.
PARAMETERS
fontc |
stringhash |
The path to the .fontc resource |
font |
stringhash |
The path to the .ttf or .otf 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(fontc:string|hash)→info:font.info
Gets information about a font, such as the associated font files
PARAMETERS
fontc |
stringhash |
The path to the .fontc resource |
RETURNS
info |
font.info |
font resource information |
font.prewarm_text(fontc:string|hash, text:string, [callback:fun(self:script_instance, request_id:integer, result:boolean, errstring?:string)])→request_id:integer
prepopulates the font glyph cache with rasterised glyphs
PARAMETERS
fontc |
stringhash |
The path to the .fontc resource |
text |
string |
The text to layout |
[callback] |
function(
self:script_instance,
request_id:integer,
result:boolean,
errstring?:string) |
(optional) A callback function that is called after the request is finished
|
RETURNS
request_id |
integer |
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(fontc:string|hash, font:string|hash)
associates a TTF or OTF resource to a .fontc file
PARAMETERS
fontc |
stringhash |
The path to the .fontc resource |
font |
stringhash |
The path to the .ttf or .otf 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)