From af01a9e9846ae218fb5f436745e8f040f105f266 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 6 Feb 2012 13:35:45 +0000 Subject: [PATCH] From Mathias Froehlich, "The attached change to the default font makes the baseline correctly working and makes the glyphs aspect ratio match their 12x8 bitmaps. I am not exactly sure about osgTexts current internals but it matches the changes that happened lately to the txf font. " --- src/osgText/DefaultFont.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/osgText/DefaultFont.cpp b/src/osgText/DefaultFont.cpp index 2b6bc3f23..8fafbf554 100644 --- a/src/osgText/DefaultFont.cpp +++ b/src/osgText/DefaultFont.cpp @@ -223,10 +223,15 @@ void DefaultFont::constructGlyphs() (*data++)=((*ptr)&1)?value_on:value_off; } - glyph->setHorizontalBearing(osg::Vec2(0.0f,0.0f)); // bottom left. - glyph->setHorizontalAdvance(1.0f); + float coord_scale = 1.0f/float(sourceHeight); + + glyph->setWidth(sourceWidth*coord_scale); + glyph->setHeight(sourceHeight*coord_scale); + + glyph->setHorizontalBearing(osg::Vec2(0.0f,-2*coord_scale)); // bottom left. + glyph->setHorizontalAdvance(sourceWidth*coord_scale); glyph->setVerticalBearing(osg::Vec2(0.5f,1.0f)); // top middle. - glyph->setVerticalAdvance(1.0f); + glyph->setVerticalAdvance(sourceHeight*coord_scale); addGlyph(fontRes,i,glyph.get()); }