[osg-users] Trouble Drawing Text in Arabic

Erik Hensens ehensens at hunter.com
Tue Nov 1 13:35:31 PDT 2016


I am having some trouble drawing text correctly in Arabic. I can get the Arabic letters themselves to show up correctly, but the letters do not connect together as they should.

I am not an Arabic speaker, but my understanding is that when letters in Arabic are adjacent to each other within a word, the letters take different shapes and connect to each other, similar to cursive English.

As a sanity check, I used the exact same TTF font and showed the same Arabic string on a 2D drawing area using Gtk. This 2D drawing area window shows the text correctly rendered with the letters connected properly.

Here is the code I am using to display the 3D Arabic text:

// Create the text drawable
osg::ref_ptr < osgText::Text > pTextDrawable = new osgText::Text;

// Set the font to use

// Set the text to show
pTextDrawable->setText(std::string(szArabicText), osgText::String::ENCODING_UTF8);

// Set up the appearance of the text
pTextDrawable->setPosition(osg::Vec3(640.0f, 360.0f, 0.0f));
pTextDrawable->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));

// Create the text geode
osg::ref_ptr<osg::Geode> pTextGeode = new osg::Geode;

// Add the text drawable to the text geode

// Add the text geode to the heads-up camera

I am attaching both the 2D drawing area text screen capture (white text on gray background) with the text correctly rendered, as well as a screen capture of the 3D text with the individual letters drawn in the correct order but not properly connected together (white text on red background). Again, these are both using the same font (Scheherazade) and the same text string.

How can I get OSG to render these Arabic letters properly?

Thank you very much!


Read this topic online here:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Arabic3DText.png
Type: image/png
Size: 12169 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20161101/f9b90ad4/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Arabic2DText.png
Type: image/png
Size: 7564 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20161101/f9b90ad4/attachment-0005.png>

More information about the osg-users mailing list