Ogre::Font::getTrueTypeMaxBearingY
Posted: Mon Apr 28, 2008 11:37 pm
When the Ogre::Font class loads a true type font, the max bearing y is already calculated:
File: OgreFont.cpp
Function: void Font::loadResource(Resource* res)
Code:
I would like to request that "max_bear" as used above is made into a member of the Ogre::Font class. With this information I will be able to format a line of text of multiple fonts so that they all line up on the same baseline.
Examples:
yyyy
jjjj
Again, I'm not asking for anything major, just that we keep track of the max bearingY value, and allow access to it. I can provide a patch if that is more welcome.
File: OgreFont.cpp
Function: void Font::loadResource(Resource* res)
Code:
Code: Select all
// Calculate maximum width, height and bearing
size_t glyphCount = 0;
for (CodePointRangeList::const_iterator r = mCodePointRangeList.begin();
r != mCodePointRangeList.end(); ++r)
{
const CodePointRange& range = *r;
for(CodePoint cp = range.first; cp <= range.second; ++cp, ++glyphCount)
{
FT_Load_Char( face, cp, FT_LOAD_RENDER );
if( ( 2 * ( face->glyph->bitmap.rows << 6 ) - face->glyph->metrics.horiBearingY ) > max_height )
max_height = ( 2 * ( face->glyph->bitmap.rows << 6 ) - face->glyph->metrics.horiBearingY );
if( face->glyph->metrics.horiBearingY > max_bear )
max_bear = face->glyph->metrics.horiBearingY;
if( (face->glyph->advance.x >> 6 ) + ( face->glyph->metrics.horiBearingX >> 6 ) > max_width)
max_width = (face->glyph->advance.x >> 6 ) + ( face->glyph->metrics.horiBearingX >> 6 );
}
}
Examples:
yyyy
jjjj
Again, I'm not asking for anything major, just that we keep track of the max bearingY value, and allow access to it. I can provide a patch if that is more welcome.