OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Trouble Drawing Text in Arabic


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
ehensens
User


Joined: 12 Mar 2015
Posts: 34

PostPosted: Tue Nov 01, 2016 8:35 pm    Post subject:
Trouble Drawing Text in Arabic
Reply with quote

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
Back to top
View user's profile Send private message
Jan Ciger
Guest





PostPosted: Wed Nov 02, 2016 9:37 am    Post subject:
Trouble Drawing Text in Arabic
Reply with quote

On Tue, Nov 1, 2016 at 9:35 PM, Erik Hensens < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
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.




Uff, I think you are pushing the poor old osgText far beyond its design limits. This sort of thing requires some special treatment in the code, which GTK does but osgText doesn't. osgText only takes the glyphs rendered by FreeType, one by one. So if there are alternative glyphs to use in certain situations (like ligatures) or something else, FreeType needs to handle it and I believe it doesn't currently (or at least not automatically). GTK uses Pango/Cairo combination, not raw FreeType for font rendering, I believe. 


So you could be out of luck here and may have to write your own text rendering module - e..g use Pango/Cairo to render into a texture and display it on a quad.


Regards,


J.

------------------
Post generated by Mail2Forum
Back to top
Chris Hanson
Guest





PostPosted: Wed Nov 02, 2016 2:36 pm    Post subject:
Trouble Drawing Text in Arabic
Reply with quote

Is this something osgCairo ( https://github.com/cubicool/osgcairo ) might solve for you?​

------------------
Post generated by Mail2Forum
Back to top
Jan Ciger
Guest





PostPosted: Wed Nov 02, 2016 4:29 pm    Post subject:
Trouble Drawing Text in Arabic
Reply with quote

On Wed, Nov 2, 2016 at 3:35 PM, Chris Hanson < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Is this something osgCairo ( https://github.com/cubicool/osgcairo ) might solve for you?​




Love that TODO in the README!


However, be aware that when I have played with Pango/Cairo for OSG some years ago for one of our projects, these libraries had major issues with multithreading in OSG, resulting in randomly corrupted text/textures. I haven't tried osgCairo, though, perhaps it fixes that problem.


J.

------------------
Post generated by Mail2Forum
Back to top
ehensens
User


Joined: 12 Mar 2015
Posts: 34

PostPosted: Wed Nov 02, 2016 4:36 pm    Post subject:
Re: Trouble Drawing Text in Arabic
Reply with quote

Jan Ciger wrote:
On Wed, Nov 2, 2016 at 3:35 PM, Chris Hanson < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Is this something osgCairo ( https://github.com/cubicool/osgcairo ) might solve for you?​




Love that TODO in the README!


However, be aware that when I have played with Pango/Cairo for OSG some years ago for one of our projects, these libraries had major issues with multithreading in OSG, resulting in randomly corrupted text/textures. I haven't tried osgCairo, though, perhaps it fixes that problem.


J.

------------------
Post generated by Mail2Forum


Thank you both very much for your responses! Also, Jan, thanks for the warning given your previous experiences with these libraries.

I will do some experimentation with both osgPango and osgCairo to see if this fixes my issues. Cool
Back to top
View user's profile Send private message
ehensens
User


Joined: 12 Mar 2015
Posts: 34

PostPosted: Wed Nov 09, 2016 9:17 pm    Post subject:
Re: Trouble Drawing Text in Arabic
Reply with quote

ehensens wrote:
Jan Ciger wrote:
On Wed, Nov 2, 2016 at 3:35 PM, Chris Hanson < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Is this something osgCairo ( https://github.com/cubicool/osgcairo ) might solve for you?​




Love that TODO in the README!


However, be aware that when I have played with Pango/Cairo for OSG some years ago for one of our projects, these libraries had major issues with multithreading in OSG, resulting in randomly corrupted text/textures. I haven't tried osgCairo, though, perhaps it fixes that problem.


J.

------------------
Post generated by Mail2Forum


Thank you both very much for your responses! Also, Jan, thanks for the warning given your previous experiences with these libraries.

I will do some experimentation with both osgPango and osgCairo to see if this fixes my issues. Cool


Thanks everyone for your contributions. Just wanted to update this thread; I ended up rendering the text directly to a 2D GtkDrawingArea using Pango and Cairo, creating a bitmap, and then showing the bitmap on the scene under a billboard heads up camera.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Compute line numbers for Glyphs in Te... Ferran Pallarès General 2 Wed Oct 24, 2018 5:58 pm View latest post
No new posts strange behaviour with osgText::Text christoph General 0 Wed Jul 18, 2018 12:06 pm View latest post
No new posts Culling and instanced drawing wernerM General 7 Fri Jul 13, 2018 4:45 pm View latest post
No new posts massive text rendering OmegaDoom General 3 Mon Jul 09, 2018 12:14 pm View latest post
No new posts indirect drawing sergio2k18 General 2 Sun Jul 08, 2018 7:09 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP