Text Outline pixelated on close up

19 views
Skip to first unread message

Rodrigo Dias

unread,
May 18, 2020, 4:14:01 PM5/18/20
to OpenSceneGraph Users
Hi,

I'm creating text objects that lie over the map, indicating the name of some cities. Pure white text was hard to read (the background represents vegetation, so it's colored, but some parts are white). Adding an outline solved that, but on close up, the outline looks pixelated and ugly. Using a drop_shadow also looks fine from a distance, but strange from a small distance, since the black shadow doesn't touch the white text. Is there something I can do to improve the appearance of the outline from close up, or to reduce the distance between the shadow and the text?

osg::Node* createLabel(const osg::Vec3& pos, float size, const std::string& label, osgText::Text::AxisAlignment axisAlignment)
{
    osg::Geode* geode = new osg::Geode();
    {
        osgText::Text* text = new osgText::Text;
        geode->addDrawable( text );
        text->setPosition(pos);
        text->setCharacterSize(size);
        text->setAxisAlignment(axisAlignment);
        text->setAlignment(osgText::Text::CENTER_CENTER);
        text->setBackdropType(osgText::Text::OUTLINE); // DROP_SHADOW_BOTTOM_RIGHT
        text->setBackdropColor(osg::Vec4(0.0f, 0.0f, 0.0f, 0.5f));
        std::string dest = desaxUTF8( label );
        text->setText( dest );
    }
    return geode;
}

Thanks,

Rodrigo.

text_outline_close.jpg
text_outline_far.jpg
text_shadow_close.jpg
text_shadow_far.jpg

OpenSceneGraph Users

unread,
May 19, 2020, 9:15:25 AM5/19/20
to OpenSceneGraph Users
Hi Rodrigo,

From the looks of it you are using the osgText's default font that really is just there as a fallback, it's not intended for normal application usage.  The OSG has support for using true type fronts, this support is provided by the freetype plugin, make sure this is being built (requires the freetype library to be installed) and assign a font to the Text.  See the osgtext example so see how different fonts are set.

Cheers,
Robert.

--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/82ad1cc1-ec3d-4397-96d3-4bd4dc907c05%40googlegroups.com.
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Rodrigo Dias

unread,
May 19, 2020, 3:47:29 PM5/19/20
to OpenSceneGraph Users
Thank you, Robert!

freetype solved it.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages