Default Font Bug

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

User avatar
Sternenstaub
Just popping in
Just popping in
Posts: 2
Joined: Mon May 09, 2005 16:07

Default Font Bug

Postby Sternenstaub » Mon May 09, 2005 16:36

Hi,

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 :)

User avatar
zakalawe
Just popping in
Just popping in
Posts: 7
Joined: Mon May 09, 2005 07:17
Location: Edinburgh, Scotland
Contact:

Re: Default Font Bug

Postby zakalawe » Tue May 10, 2005 08:30

I don't know the context of this issue at all, but the most recent change to FontManager.cpp was a commit by eddie in February that added the feature you are trying to use:

http://cvs.sourceforge.net/viewcvs.py/c ... 1.8&r2=1.9

So it sounds as if your expectations are correct, at least.

User avatar
Sternenstaub
Just popping in
Just popping in
Posts: 2
Joined: Mon May 09, 2005 16:07

Re: Default Font Bug

Postby Sternenstaub » Tue May 10, 2005 22:45

Hi,

thanks for that information.

If I interpret it right, that change has been made on 21.2.05.
The CEGUI MK2 V0.2.0 in the download ara is from the 17.02.05.
So it seems like the tutorial is reffering to the CVS-Version.
Perhaps there should be a note about that added in the wiki-tutorial?
I have no idea how many people are using the cvs-version instead of the version in the download-area, but i guess a lot of people prefer always a stable-release instad of a cvs-version when i they have the choise, and are not involved in the developement or belong to the team.
So i guess for the "average user" like me it would be very helpfull if there would be at least a note in the tutorial, that this behaviour of automatically setting the first loaded font as the default font is just valid for the cvs-version, not the last stable release.
This could save some people a lot of time who are following the wiki-tutorial.
The point is, that I first thought there is a bug on my side, and i rechecked the scheme-, layout- and other files over and over again, compared my code to the one in the tutorial over and over again to see where i did something wrong, not knowing that it just cant work that way it is explained in the tutorial with the latest stable-release.
A generall access violation as the only error message is also not very helpfull to get a clue about what someone did wrong :)

To be sure I dont get missunderstood: This is not meant to be a complaint, even if perhaps some things may sound strange or accidently "rough", because english is not my native language.
I just want to point that out, so that peraps the CEGUI-team can add a note about that to the tutorial, so that other people using CEGUI dont walk into the same trap and can save hours of searching for what they may did wrong, when it just dont work the way it is described in the tutorial with the stable-release :)


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 12 guests