[osg-users] Trouble Drawing Text in Arabic

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


Hello!

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:



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

// Set the font to use
pTextDrawable->setFont("/usr/share/fonts/truetype/scheherazade/ScheherazadeRegOT.ttf");

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

// Set up the appearance of the text
pTextDrawable->setCharacterSize(30.0f);
pTextDrawable->setAxisAlignment(osgText::TextBase::XY_PLANE);
pTextDrawable->setPosition(osg::Vec3(640.0f, 360.0f, 0.0f));
pTextDrawable->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
pTextDrawable->setMaximumWidth(1000.0f);
pTextDrawable->setLayout(osgText::Text::RIGHT_TO_LEFT);
pTextDrawable->setAlignment(osgText::TextBase::CENTER_TOP);

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

// Add the text drawable to the text geode
pTextGeode->addDrawable(pTextDrawable);

// Add the text geode to the heads-up camera
pHeadsUpCamera->addChild(pTextGeode);




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!

Cheers,
Erik

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69194#69194



-------------- 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