[RESOLVED] Different sized text on screen at once

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Elof Valantor
Posts: 5
Joined: Thu Feb 03, 2011 3:51 pm

[RESOLVED] Different sized text on screen at once

Post by Elof Valantor »

I'm using Nalins CGUITTFont to get true type fonts into my program and am having a hard time figuring out how to get different font sizes to show up on the screen.

I create two different sized fonts like this:

Code: Select all

font16 = CGUITTFont::createTTFont(guienv, "C:\\Windows\\fonts\\calibri.ttf", 16);
font32 = CGUITTFont::createTTFont(guienv, "C:\\Windows\\fonts\\calibri.ttf", 32);
And apply one to the skin like this:

Code: Select all

skin = guienv->getSkin();
skin->setFont(font16);
skin->setColor(EGDC_BUTTON_TEXT, SColor(255, 255, 255, 255));
Now lets say I want to display some size 16 text, and then somewhere else on the screen display some size 32 text. I'm not really sure how to do it (it must be possible, surely?). I've tried:

Code: Select all

guienv->addStaticText(L"Some text", rect<s32>(10, 10, 50, 50), false);
skin->setFont(font32);
skin->setColor(EGDC_BUTTON_TEXT, SColor(255, 255, 255, 255));
guienv->addStaticText(L"Some more text", rect<s32>(100, 100, 150, 150), false);
But all that does it make all the text size 32. I also tried to use the draw() function in CGUITTFont (i.e. font32->draw(etc etc)) but that doesn't draw anything (but then I don't know how it's supposed to work). I've tried combinations of other things like calling multiple guienv->drawAll() at different stages. I'm really stumped.

So how does it work? Does it even work? I could just keep all the text the same size, but I'd prefer not to.
Last edited by Elof Valantor on Fri Jun 03, 2011 8:57 pm, edited 1 time in total.
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

IGUIStaticText has setOverrideFont() method, you should use it for every element which has to have different font.
Elof Valantor
Posts: 5
Joined: Thu Feb 03, 2011 3:51 pm

Post by Elof Valantor »

That's what I need. Thank you. I don't know how I missed that...
Post Reply