GUI text nodes

Defold supports a specific type of GUI node that allows text to be rendered in a GUI scene. Any font resource added to a project can be used for text node rendering.

Adding text nodes

The fonts that you wish to use in GUI text nodes must be added to the GUI component. Either right-click the Fonts folder, use the GUI top menu or press the corresponding keyboard shortcut.


Text nodes have a set of special properties:

Any text node you create must have the Font property set.
This property contains the text displayed.
Line Break
Text alignment follows the pivot setting and setting this property allows the text to flow over several lines. The width of the node determines where the text will wrap.


By setting the node pivot you can change the alignment mode for the text.

If the pivot is set to Center, North or South, the text is center-aligned.
If the pivot is set to any of the West modes, the text is left-aligned.
If the pivot is set to any of the East modes, the text is right-aligned.

Text alignment

Modifying text nodes in runtime

Text nodes respond to any generic node manipulation functions for setting size, pivot, color and so forth. A few text node only functions exist:

function on_message(self, message_id, message, sender)
    if message_id == hash("set_score") then
        local s = gui.get_node("score")
        gui.set_text(s, message.score)