No opposition or acceptance of this request?
Here is the patch:
Code: Select all
Index: include/OgreFont.h
===================================================================
--- include/OgreFont.h (revision 7443)
+++ include/OgreFont.h (working copy)
@@ -113,6 +113,8 @@
Real mTtfSize;
/// Resolution (dpi) of truetype font
uint mTtfResolution;
+ /// Max distance to baseline of this (truetype) font
+ int mTtfMaxBearingY;
public:
@@ -220,6 +222,14 @@
Only applicable for FT_TRUETYPE Font objects.
*/
uint getTrueTypeResolution(void) const;
+ /** Gets the maximum baseline distance of all glyphs used in the texture.
+ @remarks
+ Only applicable for FT_TRUETYPE Font objects.
+ The baseline is the vertical origin of horizontal based glyphs. The bearingY
+ attribute is the distance from the baseline (origin) to the top of the glyph's
+ bounding box.
+ */
+ int getTrueTypeMaxBearingY() const;
/** Returns the texture coordinates of the associated glyph.
Index: src/OgreFont.cpp
===================================================================
--- src/OgreFont.cpp (revision 7443)
+++ src/OgreFont.cpp (working copy)
@@ -58,7 +58,7 @@
Font::Font(ResourceManager* creator, const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader)
:Resource (creator, name, handle, group, isManual, loader),
- mType(FT_TRUETYPE), mTtfSize(0), mTtfResolution(0), mAntialiasColour(false)
+ mType(FT_TRUETYPE), mTtfSize(0), mTtfResolution(0), mTtfMaxBearingY(0), mAntialiasColour(false)
{
if (createParamDictionary("Font"))
@@ -130,6 +130,11 @@
return mTtfResolution;
}
//---------------------------------------------------------------------
+ int Font::getTrueTypeMaxBearingY() const
+ {
+ return mTtfMaxBearingY;
+ }
+ //---------------------------------------------------------------------
const Font::GlyphInfo& Font::getGlyphInfo(CodePoint id) const
{
CodePointMap::const_iterator i = mCodePointMap.find(id);
@@ -257,7 +262,7 @@
//FILE *fo_def = stdout;
- int max_height = 0, max_width = 0, max_bear = 0;
+ int max_height = 0, max_width = 0;
// Backwards compatibility - if codepoints not supplied, assume 33-166
if (mCodePointRangeList.empty())
@@ -277,8 +282,8 @@
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->metrics.horiBearingY > mTtfMaxBearingY )
+ mTtfMaxBearingY = 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 );
@@ -356,7 +361,7 @@
continue;
}
- int y_bearnig = ( max_bear >> 6 ) - ( face->glyph->metrics.horiBearingY >> 6 );
+ int y_bearnig = ( mTtfMaxBearingY >> 6 ) - ( face->glyph->metrics.horiBearingY >> 6 );
for(int j = 0; j < face->glyph->bitmap.rows; j++ )
{
Just put it into the OgreMain folder and apply it!
