diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index 909a64b0f..b85622b9f 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -377,6 +377,18 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite while (lastValidChar!=first && deliminatorSet.count(*lastValidChar)==0) { --lastValidChar; + + //Substract off glyphs from the cursor position (to correctly center text) + Font::Glyph* glyph = activefont->getGlyph(*lastValidChar); + if (glyph) + { + switch(_layout) + { + case LEFT_TO_RIGHT: cursor.x() -= glyph->getHorizontalAdvance() * wr; break; + case VERTICAL: cursor.y() += glyph->getVerticalAdvance() * hr; break; + case RIGHT_TO_LEFT: break; // nop. + } + } } if (first!=lastValidChar) { @@ -919,7 +931,6 @@ void Text::drawImplementation(osg::State& state) const } } - glNormal3fv(_normal.ptr()); glColor4fv(_color.ptr());