Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: arabic not rendered correctly  (Read 5257 times)

0 Members and 1 Guest are viewing this topic.

mustafa

  • Newbie
  • *
  • Posts: 8
    • View Profile
arabic not rendered correctly
« on: July 01, 2012, 10:37:06 pm »
Greetings,,
please have a look at my code and the attached screenshot
#include <SFML/Graphics.hpp>
int main()
{
    sf::RenderWindow window(sf::VideoMode(300, 200), "hello");
        sf::Font mf;
        mf.loadFromFile("KacstArt.ttf");
        sf::Text text;
sf::String s(L"&#1605;&#1585;&#1581;&#1576;&#1575;");  // This suppose to be Arabic characters in here
        text.setString(s);
        //text.setFont(mf);
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(text);
        window.display();
    }

    return 0;
}
 

any ideas how to fix this
Thanks

[attachment deleted by admin]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: arabic not rendered correctly
« Reply #1 on: July 01, 2012, 10:56:56 pm »
First, I have no idea how you can manage to use HTML unicode sequences in C++ code... ???

I have also no idea about what's wrong, but according to this wikipedia page, your first character (&#1605;) is correctly rendered by SFML, and it doesn't match what you show.
Laurent Gomila - SFML developer

mustafa

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: arabic not rendered correctly
« Reply #2 on: July 01, 2012, 11:57:24 pm »
Oh no i tried to write it in arabic but when i submit the post it turns like this
I will write something. In arabic to let you see what i mean
مرحبا

mustafa

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: arabic not rendered correctly
« Reply #3 on: July 02, 2012, 12:01:32 am »
So maybe if i include arabic characters inside a code tag it turns like that
Anyway thats what I wrote in the code
مرحبا

Let me try to but it in code tags
 
&#1605;&#1585;&#1581;&#1576;&#1575;

 

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: arabic not rendered correctly
« Reply #4 on: July 02, 2012, 01:31:48 am »
Isn't SFML rendering characters from left to right whereas you want the opposite ?
I may be wrong but it does look like it's what being done.
Want to play movies in your SFML application? Check out sfeMovie!

mustafa

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: arabic not rendered correctly
« Reply #5 on: July 02, 2012, 06:51:04 am »
yes that might be it..
another thing to note..
that in Arabic there are 4 presentation for the character

1)single
م
2)beginning
مـ
3)middle
ـمـ
4)end
ـم



Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: arabic not rendered correctly
« Reply #6 on: July 02, 2012, 08:24:47 am »
Ok, I see now.

The right-to-left layout could be added to sf::Text as an option; I'll add an issue on the tracker for that.

The 4 variants of the same character is a more complex problem. I guess you'll have to manually add the "ـ" character to the text, depending on the position of م.
Laurent Gomila - SFML developer

mustafa

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: arabic not rendered correctly
« Reply #7 on: July 02, 2012, 09:51:24 am »
I hope by adding it. it will fix the problem.
but from what I notice the render is rendering the arabic character as signle always
and adding ـ won't fix it.
because
مرحبا
is currently rendered as
ا ب ح ر م

and I think by adding RTL support it will be like this
م ر ح ب ا

adding ـ won't fix it I've used it as example only

because it will be something like this
ـ م

so what I suggest is we refer to this table

http://unicode.org/charts/PDF/UFE70.pdf

row 1 col FEE
row 2 col FEE
row 3 col FEE
row 4 col FEE

and please provide me with a code that can take array of unicode indexes so that we hard code it
what I mean and what I think the string is taken as (FEE1) while it should take it as (FEE3)

so if there is a way to take an array of indexes to the unicode table and we tell the Text class to render it.
it would be perfect for testing this.

also the problem might be with the editor because they usually they represent arabic character as a single presentation م and they leave it to the editor or the OS to make the proper tweaking so that if م comes before another character is represented in the other presentation. but I don't know how SFML is rendering it. and what library is using to do this task further more I don't know if this problem only with linux or with all platforms

finally I would like to thank you for your time and effort.
and please note that it's not that big of a deal. I just wanted to point this out.

Mustafa S.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: arabic not rendered correctly
« Reply #8 on: July 02, 2012, 10:12:31 am »
Quote
so if there is a way to take an array of indexes to the unicode table and we tell the Text class to render it.
it would be perfect for testing this.
You can write Unicode numbers directly into a string with the \uXXX notation:
text.setString(L"\uFEE1\uFEE3...");

But Arabic text is really complicated to render, and I don't think you'll get a perfect result (ie. all characters joined together) with SFML anyway.

Quote
I don't know how SFML is rendering it. and what library is using to do this task
SFML uses the FreeType library.
Laurent Gomila - SFML developer

mustafa

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: arabic not rendered correctly
« Reply #9 on: July 02, 2012, 01:21:49 pm »
I've tried hard coding the string same result.. :/
the problem is with freetype.. I'll check some alternative solution or I'll do what I can do to solve the problem..
if I've got an important update I'll post it to github issues..
:D
thanks again..
and by the way sfml is totally amazing..

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: arabic not rendered correctly
« Reply #10 on: July 02, 2012, 01:27:33 pm »
Actually there seem to be some support for arabic by FreeType : http://www.freetype.org/opentype/index.html
Want to play movies in your SFML application? Check out sfeMovie!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: arabic not rendered correctly
« Reply #11 on: July 02, 2012, 01:32:53 pm »
I read that this morning. The first paragraph, written in red, is:
Quote
Please go to homepage of the HarfBuzz library! FreeType 1 and its OpenType support is no longer maintained.

The current state is explained in the FAQ:
When will FreeType 2 support OpenType?

Well, the engine already reads OpenType/CFF files perfectly. What it doesn't do is handling ‘OpenType Layout’ tables.

FreeType 1 comes with a set of extensions that are used to load and manage OpenType Layout tables. It even has a demonstration program named ftstrtto to show its capabilities. However, this code is no longer maintained, and we strongly advise to not use it.

For FreeType 2, we have decided that the layout operations provided through these tables are better placed in a specific text-layout library like Pango.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: arabic not rendered correctly
« Reply #12 on: July 02, 2012, 01:33:42 pm »
If anyone finds something interesting, please add it to this issue:
https://github.com/SFML/SFML/issues/246
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: arabic not rendered correctly
« Reply #13 on: July 02, 2012, 01:49:27 pm »
I read that this morning. The first paragraph, written in red, is:
Uh.. I didn't even read it ;D . I've gone really too fast through the page.
Want to play movies in your SFML application? Check out sfeMovie!

mustafa

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: arabic not rendered correctly
« Reply #14 on: July 02, 2012, 02:05:47 pm »
I'll investigate more about the Pango library..
it seems it's on a rapid development and it's stable..
I'll see how to use it and possibly how to integrate it with SFML ..
I'll furthermore do some search about it's feature and compare it with freetype ..

This seems very promising:

http://www.flickr.com/photos/behdad/498812683/
http://www.pango.org/ScriptGallery

 

anything