From Matt Green, fix to handling of centering of multi-line text entries.
This commit is contained in:
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user