[SOLVED] exception with getGlyphAspectRatio

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
suny
Greenskin
Posts: 137
Joined: Thu Mar 12, 2020 5:53 pm
x 60

[SOLVED] exception with getGlyphAspectRatio

Post by suny »

Ogre Version: :?: 1.13
Operating System: :?: windows

I'm porting my game from 1.12.13 to 1.13, and I have some code that helps me compute the size of a sentence. The sentence is in wstring to be compatible with french or german characters.
It was working well until 1.13.
What should I do to update my code?
S.

Code: Select all

std::wstring longestLine;
Ogre::FontPtr mpFont = Ogre::FontManager::getSingleton().getByName(fontName, Game::getSingletonPtr()->gameName);
Ogre::Real fAspectRatio = mpFont->getGlyphAspectRatio(static_cast<Ogre::Font::CodePoint>(longestLine[iChar])); 
Exception thrown at 0x7637C5AF in ShmupCreator.exe: Microsoft C++ exception: Ogre::ItemIdentityException at memory location 0x00BE61A0.
Last edited by suny on Tue Sep 21, 2021 8:38 am, edited 1 time in total.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: exception with getGlyphAspectRatio

Post by paroj »

do mpFont->load() before getGlyphAspectRatio
User avatar
suny
Greenskin
Posts: 137
Joined: Thu Mar 12, 2020 5:53 pm
x 60

Re: exception with getGlyphAspectRatio

Post by suny »

Yes, I did.
But digging a little bit, I have an exception because Ogre can't find the glyph 32 in my font:

Code: Select all

desc = "Code point 32 not found in font ArialBlk64"
The font has every code point except the 32 (30,31,33,34...) and so my code throw when I try to read a space character from a string.

My font script:

Code: Select all

font ArialBlk64
{
	type	truetype
	source	ariblk.ttf
	size	64
	resolution 72
	code_points 30-255
}
I resolved the issue by not trying to read the glyphRatio if the char is 32. Not sure if not including the space in the font texture is an optimization or not though.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: exception with getGlyphAspectRatio

Post by paroj »

this means that glyph 32 is not defined in the ttf file, which kind of makes sense. Previously Ogre would give you some arbitrary value here. Internally Ogre uses the width of "0" to define the whitespace.
Post Reply