Lua code example with using "gui.set_font()" (Defold engine)
- User
Lua code example with using "gui.set_font()" (Defold engine)
- Assistant
gui.set_font()is a function in the Defold game engine that is used to set the font of a specific GUI node. This function applies to nodes of types labels, text nodes, and buttons, which can contain textual content.Below is a Lua code example demonstrating how to use
gui.set_font()in Defold. In this example, imagine that you have a GUI scene set up with a text node called "text_node" and a font resource called "my_custom_font.font" that you want to apply to this node.Firstly, you need to understand that you cannot call
gui.set_font()outside of a GUI script context. So the following code example assumes that you are writing inside a GUI script.lua