[no bug]setOverrideFont

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

[no bug]setOverrideFont

Post by Reiko »

setOverrideFont doesn't seem to be working with the statictext part of a combobox.

Code: Select all

// Load some fonts
IGUIFont *font1 = guienv->getFont(L"font1.png");
IGUIFont *font2 = guienv->getFont(L"font2.png");

// Set default font to font1
guienv->getSkin()->setFont(font1);

// Make a static text, set override font to font2. This works.
guienv->addStaticText(L"Test", rect<s32>(20,20,120,40))->setOverrideFont(font2);

// Make a combo box
IGUIComboBox *combo = guienv->addComboBox(rect<s32>(20,60,120,80));
combo->addItem(L"item 1");
combo->addItem(L"item 2");
combo->addItem(L"item 3");

// Set override font on text part of combo box. Doesn't work, font used will be the skin's default (font1)
irr::core::list<IGUIElement *> kids = combo->getChildren();
for (irr::core::list<IGUIElement *>::Iterator i = kids.begin(); i != kids.end(); ++i)
{
	if (((stringc)(*i)->getTypeName()).equals_ignore_case("staticText") == 0)
	{
		static_cast<IGUIStaticText *>(*i)->setOverrideFont(font2);
	}
}
Should that be working or am I doing this wrong?

I haven't tried it with others though (eg. list box)
CuteAlien
Admin
Posts: 9687
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

equals_ignore_case isn't like string compare returning 0 when equal, but it's a boolean - so you would check for true. But it's probably easier to check for getType() == EGUIET_STATIC_TEXT instead.

I haven't written a test now, but I think that should work then as there is nothing special done with fonts as far as I can see. If it still doesn't work just say it, then I take another look.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Post by Reiko »

Yup, it was my bad. It does work.

Thanks.
Post Reply