Persian font support

Hi experts
I try to use sdl ttf? to render some persian words

Persian words are written from right to left

But? i find following problems

  1. Words are written from left to right ( instead of right to left)
    2.words are seperated into a bunch of? characters that are not connected

Could you please tell me what is the problem
Regards
MahdiSent from Yahoo! Mail on Android

Message-ID:
<1386743865.13295.YahooMailAndroidMobile at web162002.mail.bf1.yahoo.com>
Content-Type: text/plain; charset=“iso-8859-1”

Hi experts
I try to use sdl ttf? to render some persian words

Persian words are written from right to left

But? i find following problems

  1. Words are written from left to right ( instead of right to left)
    2.words are seperated into a bunch of? characters that are not connected

Could you please tell me what is the problem

Problem 1: I guess that SDL_ttf isn’t currently designed to support
anything other than left-to-right languages? This might or might not
be fixable with the current interface. If it’s fixable, then that will
presumably involve either a table describing the traits of letters, or
a plugin function providing such information when asked. Such a thing
would essentially need to support information about arbitrary
directions (there could be a language conventionally written in
spirals for all I know, and I believe that some are written
vertically), and arbitrary relative locations (Japanese, as I
understand it, apparently sometimes uses smaller, simpler characters,
located parallel to the main text, to provide alternate readings: I
think that Chinese might do the same; even if these are things that
should be left to code that uses SDL_ttf, I think that some of the
European accent characters are intended to be displayed above a
character, instead of displayed where they occur in the text).

Problem 2: SDL_ttf must be currently written to assume non-cursive
characters. This works fine for your average Greco-Roman derived
writing, Chinese-derived writing (such as Japanese), etc., but not so
well for cursive styles, such as Arabic (which I’m going to assume
modern Persian letters are derived from, since the problem should be
identical even if that isn’t the case).

Fixing the second problem would probably require a robust function to
find the break-points between two words. This is the sort of thing
that needs someone proficient in the language (or at least with an
understanding of what it should LOOK like, even if they can’t actually
read it), so can you try to write that (or at least a list of the
relevant Unicode code-points for the characters) for us? Ideally it
would indicate actual breaks between words, and optional break points
for e.g. breaking long words (including complete gibberish) that can’t
fit into the full provided area for text. I know that Unicode supports
at least one such character, but the presence of such things shouldn’t
be counted on, so the function would also need to understand
characters that are acceptable breakpoints by themselves, much like
’-’ is in English.

Someone else is looking at improving SDL_ttf itself at some point, so
I think that the function is the main thing that’s needed (everything
else might wind up wasted effort, since depending on the details an
additional API might be provided).> Date: Tue, 10 Dec 2013 22:37:45 -0800 (PST)

From: mahdi monhi <m_monhi at yahoo.com>
To: “sdl at lists.libsdl.org
Subject: [SDL] persian font support

Firstly the TTF contains info about where each letter rests. The fonts I
made taught me a lot. Make sure to get a font that you see working how you
would like. Secondly you can get the width and do one letter at a time
so you can place letters from right to left. You can rewrite SDL TTF to
better fit your case too but I realize that would suck to take on when you
just want it to work. P.s. if you
need a custom font I may be able to help. Most English fonts are sad so I
imagine those fonts are not that hot either.On Dec 11, 2013 12:40 AM, “mahdi monhi” <m_monhi at yahoo.com> wrote:

Hi experts
I try to use sdl ttf to render some persian words

Persian words are written from right to left

But i find following problems

  1. Words are written from left to right ( instead of right to left)
    2.words are seperated into a bunch of characters that are not connected

Could you please tell me what is the problem
Regards
Mahdi
Sent from Yahoo! Mail on Android


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Rendering complex scripts correctly is a very difficult thing to do: the
conventions of orthography have evolved over thousands of years and for the
vast majority of that time there has been no pressure for those conventions
to follow strict or easily programmed rules. It is possible to do it
well, but it is not a task that should be undertaken lightly.

Luckily, this is a problem that is faced by a very large amount of
software, and so there are good existing solutions. One good option is to
use the HarfBuzz library [1], which implements glyph shaping rules
(‘shaping’ is the process of selecting appropriate glyphs and positioning
them). On Windows, there are also APIs provided by Microsoft to do this:
Uniscribe does it, and on recent versions of Windows I believe DirectWrite
includes this functionality (though I’ve never used it myself). I imagine
OS X provides similar functionality, probably through CoreText, but I’ve
never had reason to investigate.

Glyph shaping is not the only part of the layout problem – as Jared Maddox
notes, you also have to find word boundaries, and you’ll probably have to
cope with bi-directional text. You could look into using ICU [2] to do
these things (or FriBiDi [3] to help handle bi-directional text). I think
ICU also includes its own glyph shaping engine, but I haven’t used it and I
don’t know how it compares to harfbuzz in quality or ease of use.

I currently use harfbuzz myself, but only for very simple text; basically
English and other latin script languages; all left-to-right and easy to
deal with.

John B

[1] http://freedesktop.org/wiki/Software/HarfBuzz/
[2] http://site.icu-project.org/
[3] http://fribidi.org/

Message-ID:
<CAKCUQMa4KgKLRALnEYQL=j94dAXOdJk3SxNj94z3Ud8-v5v1Kw at mail.gmail.com>
Content-Type: text/plain; charset=“iso-8859-1”

Secondly you can get the width and do one letter at a time
so you can place letters from right to left.

I’ve read up on Arabic before, and if Persian uses the same writing
system as Arabic, then this won’t help. Arabic, at least, has
different FORMS of letters for when they’re isolated, at the beginning
of a word, in the middle of a word, and at the end of a word, for a
total of 4 forms each. Written Arabic that doesn’t use the correct
form is NOT correctly written, because that’s just how the system
works. I don’t know how many letters Arabic has, but I suspect that
adapting the PC character set to deal with Arabic writing was a major
undertaking, if it ever got done at all. You have to deal with things
as distinct words in these languages, otherwise your text comes out
completely wrong: which seems to be one of the problems that the OP is
talking about. Hopefully he’ll either write those functions that I
mentioned, or get us the code-points needed to write them.> Date: Thu, 12 Dec 2013 03:34:02 -0600

From: R Manard
To: SDL Development List
Subject: Re: [SDL] persian font support

Dear Experts,

Thanks a lot for your comments about Persian font discussion.

but some points about Persian language:

*. It consists of 32 letters.

*. Most of the letters have 2 forms of small and large shape.

*. Large letters are put at the beginning and end letter of words.

*. Small letters are only used in middle part of words.

  • Words are written from write to left.

  • Words are separated by space character.

By knowing above facts l would like to add Persian font support to SDL_ttf library.

But I have no idea where to start.
?

Thus I start with the links that John shared.

Regards

Mahdi,________________________________
From: John Bartholomew <jpa.bartholomew at gmail.com>
To: SDL Development List
Sent: Thursday, December 12, 2013 3:21 PM
Subject: Re: [SDL] persian font support

Rendering complex scripts correctly is a very difficult thing to do: the conventions of orthography have evolved over thousands of years and for the vast majority of that time there has been no pressure for those conventions to follow strict or easily programmed rules. It is possible to do it well, but it is not a task that should be undertaken lightly.

Luckily, this is a problem that is faced by a very large amount of software, and so there are good existing solutions. One good option is to use the HarfBuzz library [1], which implements glyph shaping rules (‘shaping’ is the process of selecting appropriate glyphs and positioning them). On Windows, there are also APIs provided by Microsoft to do this: Uniscribe does it, and on recent versions of Windows I believe DirectWrite includes this functionality (though I’ve never used it myself). I imagine OS X provides similar functionality, probably through CoreText, but I’ve never had reason to investigate.

Glyph shaping is not the only part of the layout problem – as Jared Maddox notes, you also have to find word boundaries, and you’ll probably have to cope with bi-directional text. You could look into using ICU [2] to do these things (or FriBiDi [3] to help handle bi-directional text). I think ICU also includes its own glyph shaping engine, but I haven’t used it and I don’t know how it compares to harfbuzz in quality or ease of use.

I currently use harfbuzz myself, but only for very simple text; basically English and other latin script languages; all left-to-right and easy to deal with.

John B

[1] http://freedesktop.org/wiki/Software/HarfBuzz/
[2] http://site.icu-project.org/

[3] http://fribidi.org/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Dear Experts,

Thanks a lot for your comments about Persian font discussion.

but some points about Persian language:

*. It consists of 32 letters.

*. Most of the letters have 2 forms of small and large shape.

*. Large letters are put at the beginning and end letter of words.

*. Small letters are only used in middle part of words.

  • Words are written from write to left.

  • Words are separated by space character.

By knowing above facts l would like to add Persian font support to SDL_ttf
library.

But I have no idea where to start.

Thus I start with the links that John shared.

You really should use HarfBuzz for Persian script.

You can start with this demo:

The guy in charge of the HarfBuzz project is Persian himself if I’m not
mistaken.On Sat, Dec 14, 2013 at 10:33 AM, mahdi monhi <m_monhi at yahoo.com> wrote:

./lxnt