[SOLVED] Newline on Label

Hey everyone,

I need some way to insert a newline on some Label* text (TTF). I unfortunately cannot simply set the dimensions as it’s text such as

text
Bigger text goes at the bottom

Therefore I need a way or a character that allows me to do this. “Text /n newline” doesn’t work. I am aware of RichText but I cannot use this and would prefer to use Label.

Any solution or patch that you guys are aware of?

Thanks!

hi @ugriffin

I am not sure though, but I think if you give a pre-formatted string, it will act similarly.
What I mean to say is -

std::string str = "Hello\nWorld";  // formatted manually

auto label = Label::createWithTTF(str.c_str(), "fonts/Marker Felt.ttf", 30, Size::ZERO, TextHAlignment::CENTER, TextVAlignment::CENTER);

I remember I have a function that fetches the string directly from json by passing a key value
something like -

LanguageManager::getInstance()->getStringForKey("hello")

that will return a std::string, so the above mentioned method should work also I believe.
You could try that, if it works then fine.

Happy Coding :smile:

1 Like

You have to escape it. The escape character is , not /.

Awesome, thanks! Just what I needed. :slight_smile: