Turns out Jabberwocky noticed this several years ago but at least as of 1.8 it's never been fixed.
Second, it additionally returns FOUR times the proper width of a space when you callJabberwocky wrote:I use a debug console window for testing and debugging stuff in my game. My console window uses ogre overlays. I found the following issue with space characters written into ogre overlays (ogre v1.7.1):
Every space character written to an ogre overlay window seems to render as 2 spaces. This is particularly annoying when you're trying to format text output into rows and columns. For example, if I call Ogre::OverlayElement::setCaption( "This is some text"), it renders like this:instead ofCode: Select all
This is some text
The problem seems to be with ogretextareaoverlayelement.cpp:Code: Select all
This is some text
That *2.0f multiplier makes all spaces twice as wide as the other characters. This must have been an explicit change at some point, because I'm pretty sure older versions of ogre didn't have this problem. Anyway, I fixed the issue by removing the * 2.0f multiplier:Code: Select all
mSpaceWidth = mpFont->getGlyphAspectRatio(UNICODE_ZERO) * mCharHeight * 2.0f * mViewportAspectCoef;
It's unclear to me if this is a bug, or is somehow desired behavior for some people. But I thought I'd at least mention it here, as it seemed relevant for this thread.Code: Select all
mSpaceWidth = mpFont->getGlyphAspectRatio(UNICODE_ZERO) * mCharHeight * mViewportAspectCoef;
getGlyphAspectRatio(0x0020);
I "fixed" this part by using half the space to calculate where to place the cursor in my editable fields.
Code: Select all
float sp = f->getGlyphAspectRatio(0x0020);
sp = sp/2.0f;