Namespace: font
Language: Lua
Type: Defold Lua
File: script_font.cpp
Source: engine/gamesys/src/gamesys/scripts/script_font.cpp
Functions, messages and properties used to manipulate font resources.
Type: FUNCTION associates a ttf resource to a .fontc file.
Notes
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)
Type: FUNCTION 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:pathhash The path hash of the current file.</dd>
fontstable An array of associated font (e.g. .ttf) files. Each item is a table that contains:
pathstring The path of the font file</dd>
path_hashhash The path of the font file</dd> </dl>
</dl>
Type: FUNCTION prepopulates the font glyph cache with rasterised glyphs
Parameters
fontc (string |
hash) - The path to the .fontc resource |
text (string) - The text to layoutcallback (function(self, request_id, result, errstring)) (optional) - (optional) A callback function that is called after the request is finishedselfobject The current object.</dd>
request_idnumber The request id</dd>
resultboolean True if request was succesful</dd>
errstringstring nil if the request was successful</dd>
</dl>
Returns
request_id (number) - Returns the asynchronous request idExamples
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)
Type: FUNCTION associates a ttf resource to a .fontc file
Notes
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)