Hi Sherman,
I download the FontForge <http://fontforge.sourceforge.net/> editor on
sourceforge.
When I examine a Glyph of "arial.ttf" font with a size of 12 :
- "A", there are 9 line for the glyph and 3 blank line under.
- "a", there are 2 blank line on the top, 7 line for the glyph and 3
blank line under.
- "q", there are 2 blank line on the top, 10 line for the glyph.
My conclusion is when you specify a size for a font,
this ensure that all glyph of the font have a height lesser to the specified
size.
But the place of the glyph is for someone largely over the base line ( for
example "`"),
and for other under the base line, "_". So all the height is used by the
font.
Other source:
In Qt documentation, for a given Font, height is equal to ascend of this
Font
(space over the base line) + descend of this Font (space under the base
line)
+ 1 ( for the base line) pixels.
try attached example,
I take your code and adapt it in a main function.
I print text with height equal to the screen height
(1024 for me, modify the SCREEN_SIZE in file
osgtext_sherman2 : l.11 if you need). When the text is
display in fullscreen, you are sure that all text have
a height less or equal to the screen height,
many time the glyph height is half of the screen
height, but for some glyph ( for example the "|" or "$" glyph)
the height is 3/4 of the screen height.
HTH
David Callu
2008/8/22 sherman wilcox <[EMAIL PROTECTED]>
> Can someone explain why the code below consistently produces text that
> is half the height specified? If I render this text, take a screenshot
> and measure the height of the text "ABC" in a paint program it will
> measure up as approximately 64 pixels tall for a character size /
> resolution of 128. I change the 128 to 256, the text will then
> measures 128 and so on. Always measures half of what I specify. Should
> this not render text that is approximately 128 pixels in height? I
> understand that the characters won't be exactly the width/height I
> specify, but half? Is this a bug or what?
>
> {
> osg::Vec3d pos(osg::DegreesToRadians(someLat),
> osg::DegreesToRadians(someLon), 0);
> ellipsoidModel->convertLatLongHeightToXYZ(pos[0], pos[1], pos[2],
> pos[0], pos[1], pos[2]);
> osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform();
> mt->setMatrix(osg::Matrix::identity());
> mt->setMatrix(osg::Matrix::translate(pos));
>
> osg::ref_ptr<osgText::Text> text = new osgText::Text;
> text->setFont("Arial.ttf");
> osgText::Text::BackdropType type = osgText::Text::OUTLINE;
> text->setBackdropType(type);
> text->setColor(osg::Vec4(1,1,1,1));
> text->setBackdropColor(osg::Vec4(0,0,0,1));
> text->setAlignment(osgText::TextBase::CENTER_CENTER);
> text->setAutoRotateToScreen(true);
> text->setText("ABC");
> text->setCharacterSizeMode( osgText::TextBase::SCREEN_COORDS );
> text->setCharacterSize(128);
> text->setFontResolution(128, 128);
>
>
> osg::ref_ptr<osg::Geode> geode = new osg::Geode();
> geode->addDrawable(text.get());
>
> mt->addChild(geode.get());
> mt->getOrCreateStateSet()->setMode(GL_DEPTH_TEST,
> osg::StateAttribute::OFF);
> root->addChild(mt.get());
> }
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
#include <osg/Geode>
#include <osg/MatrixTransform>
#include <osgText/Text>
#include <osgGA/TrackballManipulator>
#include <osgGA/StateSetManipulator>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
//#include <>
#define SCREEN_SIZE 1024
int main()
{
osgViewer::Viewer viewer;
viewer.setCameraManipulator(new osgGA::TrackballManipulator());
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
viewer.addEventHandler(new osgViewer::StatsHandler);
osg::ref_ptr<osgText::Text> text = new osgText::Text;
text->setFont("arial.ttf");
text->setBackdropType(osgText::Text::OUTLINE);
text->setColor(osg::Vec4(1, 1, 1, 1));
text->setBackdropColor(osg::Vec4(0, 0, 0, 1));
text->setAlignment(osgText::TextBase::CENTER_CENTER);
text->setAutoRotateToScreen(true);
text->setText("!\"#$%&'()*+,-./123456789:;<=>[EMAIL PROTECTED]|}~");
text->setCharacterSizeMode(osgText::TextBase::SCREEN_COORDS);
text->setCharacterSize(SCREEN_SIZE);
text->setFontResolution(SCREEN_SIZE, SCREEN_SIZE);
osg::ref_ptr<osg::Geode> geode(new osg::Geode());
geode->addDrawable(text.get());
osg::ref_ptr<osg::Group> root = new osg::Group();
root->addChild(geode.get());
root->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
viewer.setSceneData(root.get() );
viewer.setThreadSafeReferenceCounting(true);
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
viewer.realize();
while (viewer.done() == false)
{
viewer.frame();
}
return 0;
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org