Hi,

I'm having a problem with osgText::Text since r12068. Everything is fine up to r12067, so I'm absolutely certain it's related to this commit:
http://www.openscenegraph.org/projects/osg/changeset/12068

With this change, osgText::Text has excessive character spacing. Characters are so far apart that any text is unreadable (only 2-4 characters fit on the screen using "usual" character sizes/widths...).

I've attached a patch which "fixes" the issue for me and restores "normal" spacing. However, it's simply reverting the relevant changes of r12068. There probably was a good reason to change these lines in the first place. But I'm at loss why it's not working for me. Maybe something was broken - or is there anything that requires applications to be adapted when using >=r12068 osgText::Text?

That's a sample of how the application is using osgText - nothing fancy really:
   text = new osgText::Text;
   text->setFont(font);
   text->setCharacterSize(0.06);
   text->setColor(osg::Vec4(1, 1, 1, 1));
   text->setPosition(osg::Vec3(0, 0.82, 0));
   text->setAlignment(osgText::Text::CENTER_CENTER);
   text->setText(Message);

Any ideas?

cheers,
Thorsten
diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp
index 2269cae..d6b98c3 100644
--- a/src/osgText/Text.cpp
+++ b/src/osgText/Text.cpp
@@ -95,7 +95,7 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite
     Font* activefont = getActiveFont();
     if (!activefont) return last;
 
-    float hr = _characterHeight;
+    float hr = _characterHeight/getFontHeight();
     float wr = hr/getCharacterAspectRatio();
 
     bool kerning = true;
@@ -116,7 +116,7 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite
         if (glyph)
         {
 
-           float width = (float)(glyph->getWidth()) * wr;
+           float width = (float)(glyph->s()) * wr;
 
             if (_layout==RIGHT_TO_LEFT)
             {
@@ -253,7 +253,7 @@ void Text::computeGlyphRepresentation()
     
     unsigned int lineNumber = 0;
 
-    float hr = _characterHeight;
+    float hr = _characterHeight/getFontHeight();
     float wr = hr/getCharacterAspectRatio();
 
     for(String::iterator itr=_text.begin();
@@ -379,8 +379,8 @@ void Text::computeGlyphRepresentation()
                 Glyph* glyph = activefont->getGlyph(_fontSize, charcode);
                 if (glyph)
                 {
-                    float width = (float)(glyph->getWidth()) * wr;
-                    float height = (float)(glyph->getHeight()) * hr;
+                    float width = (float)(glyph->s()) * wr;
+                    float height = (float)(glyph->t()) * hr;
 
                     if (_layout==RIGHT_TO_LEFT)
                     {

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to