From bb48cef38cd3ab0f4e59c19ba493804290d9a3b1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 3 Oct 2011 10:36:18 +0000 Subject: [PATCH] Added Font::getVertical(float& ascender, float& descender) methods. --- include/osgText/Font | 8 ++++- src/osgPlugins/freetype/FreeTypeFont.cpp | 45 +++++++++++++++++++----- src/osgPlugins/freetype/FreeTypeFont.h | 4 +++ 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/include/osgText/Font b/include/osgText/Font index 39b96410a..90af2cb36 100644 --- a/include/osgText/Font +++ b/include/osgText/Font @@ -104,7 +104,11 @@ public: /** Return true if this font provides vertical alignments and spacing or glyphs.*/ virtual bool hasVertical() const; - /** Set the margin around each glyph, + /** Get the ascender and descender sizes of the font where supported by the FontImplementation, + * return true on success, return false when not supported.*/ + virtual bool getVerticalSize(float& ascender, float& descender) const { return _implementation ? _implementation->getVerticalSize(ascender, descender) : false; } + + /** Set the margin around each glyph, * to ensure that texture filtering doesn't bleed adjacent glyph's into each other. * Default margin is 1 texels.*/ void setGlyphImageMargin(unsigned int margin); @@ -236,6 +240,8 @@ public: } Font* _facade; + + virtual bool getVerticalSize(float & ascender, float & descender) const { return false; } }; diff --git a/src/osgPlugins/freetype/FreeTypeFont.cpp b/src/osgPlugins/freetype/FreeTypeFont.cpp index 23b3c7d8f..a4fb749af 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont.cpp @@ -299,7 +299,7 @@ osgText::Glyph* FreeTypeFont::getGlyph(const osgText::FontResolution& fontRes, u setFontResolution(fontRes); - float coord_scale = 1.0f/(float(_currentRes.second)*64.0f); + float coord_scale = getCoordScale(); // // GT: fix for symbol fonts (i.e. the Webdings font) as the wrong character are being @@ -394,13 +394,15 @@ osgText::Glyph* FreeTypeFont::getGlyph(const osgText::FontResolution& fontRes, u glyph->setVerticalAdvance((float)metrics->vertAdvance * coord_scale); #if 0 - OSG_NOTICE<<"getGlyph("<units_per_EM = "<<_face->units_per_EM<<", scale="<<1.0f/float(_face->units_per_EM)<