i am not sure if this is a bug in CEGUI itself or a bug in the tutorials.
Thats from the tutorial:
// load in a font. The first font loaded automatically becomes the default font.
CEGUI::FontManager::getSingleton().loadFont(“../datafiles/fonts/Commonwealth-10.font”);
First of all, there seems to be no function "FontManager::loadFont()". So i used createFont() instead, which also loads a font from a file.
This worked so far, but the the tutorial states, that the first loaded font becomes automatically the default-font. This seems not to work, at least not while loading it via createFont().
A loadScheme() then works fine, but if it contains a font, this font will also be loaded, but not set as the default font.
So if there is no call of setDefaultFont() bevore a loadWindowLayout(), it will crash due to a illegal memory access.
The cause is in WLFrameWindow::layoutComponentWidgets(). There is this line:
titleSz.d_height = d_titlebar->getFont()->getLineSpacing() + TitlebarTextPadding;
If there is no default font set yet, getFont() returns NULL, and the getLineSpacing() will fail due to an access violation.
So it seems that the first loaded Font will not automatically become the default font. If I do a setDefaultFont() bevore loading the layout, everything is fine
So we have 3 posibillities:
- The tutorial is wrong about the automatically setting of the default font
- A bug in createFont() not setting the default font.
- I am totally missunderstanding something
But anyway, it would be nice if there would be an error in the CEGUI.log or an appropriate exception instead an illegal memory access if no default font is set for some reason. That would really improve the time for users to find the reason for the crash.
I just wanted to report that error (if it really is one) to save others a lot of time if they walk into the same trap i did
