From Matt Green, fix to handling of centering of multi-line text entries.

This commit is contained in:
Robert Osfield
2006-06-08 13:34:29 +00:00
parent 7d3ddc0e1b
commit 4d35807a54

View File

@@ -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());