bug in TextAreaOverlayElement
Posted: Sun Apr 29, 2012 10:12 pm
I'm new here, I've only been using Ogre for a couple of months and this is my first post. I'm not sure if this counts as a "papercut" or not.
I noticed that the FPS meter in my app (using a TextAreaOverlayElement) had a weird problem where the space character was displayed about twice as wide as it should be (I'm using a fixed-width font).
The strange thing is that this extra-wide space only seemed to affect that one TextAreaOverlayElement, other TextAreaOverlayElements that I created later had normal looking spaces. After a bit of debugging I think I found the issue, and it seems that if you create and use a TextAreaOverlayElement before the font has been loaded, it gets a bad value set in the mSpaceWidth member. I'm not setting the space-width at all. I made a local change in OgreTextAreaOverlayElement.cpp which appears to fix the issue:
OgreTextAreaOverlayElement.cpp, line 153:
Basically I just added the "font is loaded" check to this early-exit which prevents this function from using a bad value to initialize mSpaceWidth. I don't really know the code well enough to know if this is the right way to do it.
I noticed that the FPS meter in my app (using a TextAreaOverlayElement) had a weird problem where the space character was displayed about twice as wide as it should be (I'm using a fixed-width font).
The strange thing is that this extra-wide space only seemed to affect that one TextAreaOverlayElement, other TextAreaOverlayElements that I created later had normal looking spaces. After a bit of debugging I think I found the issue, and it seems that if you create and use a TextAreaOverlayElement before the font has been loaded, it gets a bad value set in the mSpaceWidth member. I'm not setting the space-width at all. I made a local change in OgreTextAreaOverlayElement.cpp which appears to fix the issue:
OgreTextAreaOverlayElement.cpp, line 153:
Code: Select all
void TextAreaOverlayElement::updatePositionGeometry()
{
float *pVert;
if (mFont.isNull() || ! mFont->isLoaded())
{
// if font is not loaded, avoid setting mSpaceWidth with bad value
// not initialised yet, probably due to the order of creation in a template
return;
}
...