Line return syntax in strings for use with text nodes? (SOLVED)

So today I started to try and get my head around the GUI functionality in Defold (going through the manuals as normal and appreciating the great docs!). However, a couple of questions have cropped up.

One of the things I will need to do in my game is to produce an onscreen log of what occurs in the game world, turn by turn. I have figured out the text node, sizing and placing it, got my custom font and line break working after a bit of trial and error with dodgy .ttf files (which didn’t work with the line break feature).

But now I’m interested in formatting the text in this node… Is it possible to use a html style mark-up syntax or something similar within the text field of the text box?

So for example, I can have one text node with a number of paragraphs of text by including a “< p >” (or your equivalent) somewhere in the Text field of the text node?

Or is it necessary to have a separate text node for each and every paragraph I wish to display in my log?

No worries either way, just wanted to check before I start figuring out how to handle different sized text nodes (depending on the character length of text field) and getting them aligned correctly in my gui.

Also, I am working in editor 2.0 and I can’t seem to see the antialias property in the .font component that is created when I add a custom font. I can see this in the manual for 1.0 so is this feature gone or just absent as yet in 2.0?

Thanks

1 Like

You can use the code \n within your text to insert a new line - or 2 for a new paragraph i.e

gui.set_text(node, "Paragraph 1\n\nParagraph2")

Ensure that line break is ticked for the respective node

3 Likes

Brilliant!
Thanks Ben, I’ll give that a go right now :wink:

Edit: Yep that is exactly what i was looking for! Cheers

Edit: adjusted the thread title to reflect solved and to be a bit more descriptive for others potentially searching for this.

5 Likes