Quantcast

TrackNode UTF8 symbols not working

classic Classic list List threaded Threaded
3 messages Options
Nikkitta Nikkitta
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

TrackNode UTF8 symbols not working

Hi,

I want to show a label near object with some data.
Let me show you a small piece of my code with only 1 element:

// Setting scheme
osgEarth::Symbology::TextSymbol* psiNextSymbol = new osgEarth::Symbology::TextSymbol();
    psiNextSymbol->pixelOffset()->set(-5, 10);
    psiNextSymbol->alignment() = osgEarth::Symbology::TextSymbol::ALIGN_RIGHT_BOTTOM;
    psiNextSymbol->size() = 12.0f;
    psiNextSymbol->fill()->color() = osgEarth::Annotation::Color::White;
    psiNextSymbol->halo()->color() = osgEarth::Annotation::Color::Black;
    psiNextSymbol->encoding() = osgEarth::Symbology::TextSymbol::ENCODING_UTF8;

m_labelSchema[WPT_PSINEXT] = osgEarth::Annotation::TrackNodeField(psiNextSymbol, true);

// Setting TrackNode
osg::ref_ptr<osgEarth::Annotation::TrackNode> lbl = new osgEarth::Annotation::TrackNode(
        m_mapNode,
        osgEarth::GeoPoint(
          geoSRS,
          locations[i].x(), locations[i].y(), locations[i].z(),
          locations[i].altitudeMode()),
        NULL,
        m_labelSchema);

lbl->setFieldValue(WPT_PSINEXT, ("ψ next = 12.3°"));

Here - the symbol of Psi is drawn as "?".
I have my .cpp file converted to "UTF8 without BOM".
I have a font with UTF8 support:
osgEarth::Registry::instance()->setDefaultFont(osgText::readFontFile(getMainWindow()->exeFolder.toStdString() + "/data/OpenSans-Bold.ttf"));

Also I want to display some Cyrillic text, but let's start with this symbol of Psi.

Any ideas?
Best regards,
Nikita Petrov
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TrackNode UTF8 symbols not working

Does it work with a simple LabelNode?
Glenn Waldron / Pelican Mapping
Nikkitta Nikkitta
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TrackNode UTF8 symbols not working

Yes, it works with the following code:
    osgEarth::Symbology::Style labelStyle;
    labelStyle.getOrCreate<osgEarth::TextSymbol>()->encoding() = osgEarth::TextSymbol::ENCODING_UTF8;
    m_groups->getGroup_root()->addChild(new osgEarth::Annotation::LabelNode(m_mapNode, osgEarth::GeoPoint(geoSRS, 39.912294, 43.484717), "ψ next = 12.3°", labelStyle));

P.S. I have OSG and osgEarth built on 02/02/2017 from master branches.
Best regards,
Nikita Petrov
Loading...