Page 1 of 1

(solved) Text of TaharezLook/Button missing (not appearing)

Posted: Tue Jan 29, 2008 12:40
by schnorr
Hello,

I am using CEGUI in a Ogre application to make buttons, menus, etc.
I have a layout definition like this for a "quit" button:
<Window Type="TaharezLook/Button" Name="quit" >
<Property Name="Font" Value="Iconified-12" />
<Property Name="Text" Value="Exit" />
<Property Name="Alpha" Value="0.3" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="ClippedByParent" Value="False" />
<Property Name="UnifiedAreaRect" Value="{{0.465,0},{0.508078,0},{0.715,0},{0.758078,0}}" />
</Window>

This is the code I use to load the layout into the Ogre application:
mRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
mSystem = new CEGUI::System(mRenderer);
CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
mSystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
CEGUI::Window* myRoot = win->loadWindowLayout("app.layout");
CEGUI::System::getSingleton().setGUISheet(myRoot);

The Iconified-12 font is present in the resources.cfg file of the Ogre app. Its contents are:
<?xml version="1.0" ?>
<Font Name="Iconified-12" Filename="Iconiv2.ttf" Type="FreeType" Size="12" NativeHorzRes="800" NativeVertRes="600" AutoScaled="true"/>

The file Iconiv2.ttf is also present.

The problem is that the "Exit" text of the button (which was specified in the layout) does not appear inside the button when the app is executed.
Does anyone know what's causing this? I am using Linux, CEGUI 0.5.0 and Ogre 1.4.5.

Before I was creating the same button directly in the source code. And it worked, the button text appeared.

Thanks

Posted: Tue Jan 29, 2008 12:55
by scriptkid
Before I was creating the same button directly in the source code. And it worked, the button text appeared.


Then your code probably created the font, while your current setup doesn't do that. Either your TaharezLook.scheme file should include the font, or your code should create it.

HTH :)

Posted: Tue Jan 29, 2008 13:15
by schnorr
So..

The only difference is that in the old code, I did:

Code: Select all

mSystem->setDefaultFont((CEGUI::utf8*)"bluehighway-12");

So, I removed this line in the code because it throws an exception and then segfault:
terminate called after throwing an instance of 'CEGUI::UnknownObjectException'
Aborted (core dumped)

Following your sugestion, I changed to use the Iconified-12 font:

Code: Select all

mSystem->setDefaultFont("Iconified-12");

The exception is still happening.... :cry:

Should I keep the setDefaultFont? If so, how to avoid the segfault?

Thanks again...

Posted: Tue Jan 29, 2008 13:30
by schnorr
Hello,

I read the documentation a little bit more, specially
http://www.cegui.org.uk/wiki/index.php/The_Imbeciles_Guide_to_Loading_Data_Files_and_Initialisation

I added the following line of code and the text is showing up:

Code: Select all

CEGUI::FontManager::getSingleton().createFont("bluehighway-12.font");

I think this should also work with the iconified font.
I thought that during the layout parsing, the font was automatically "created".

Thanks

Posted: Tue Jan 29, 2008 15:58
by scriptkid
Hi,

fonts always need to be created first. A layout is just a data-driven way to create windows. So it needs the exact pre-setup like you would when creating your gui from code.