SDL_Pango

Hi,

In the upcoming new version of my SDL-based software, I wanted to
provide nice font rendering and internationalization. So I began using
SDL_ttf. I had to use fontconfig in order to be able to discover a
suitable TTF font for the locale (there is no TTF font which supports
"all" languages including CJK). I was kinda happy until a contributor
proposed to translate into persian (farsi), a language looking like
arabic, since two problem arose: right-to-left and shaping[1]. SDL_ttf
and its backend freetype are unable to behave correctly for these two
items. RTL can be solved by using fribidi (I think this is what
Wesnoth does) but shaping can not.

Incidentally, I discovered SDL_Pango, an SDL binding for the
i18n-oriented very capable font rendering engine “pango”
(http://www.pango.org/). It can very efficiently solve both the RTL
and shaping problems, but also provides transparent access to non-TTF
fonts, can mix several fonts in a single text string, automatically
looks for the best font for content, automatically word-wrap and can
align to the center or to the left, all things SDL_ttf is unable to
do.

http://sdlpango.sourceforge.net/

I’m posting here, to suggest users of SDL_ttf who want to provide
complete/correct i18n to switch to the much better SDL_Pango; and ask
if potential non-switchers had reasons for this choice - the main
disadvantage I can see when using SDL_Pango, will probably be that
it’s slower than SDL_ttf, but I think not many SDL programs need a
high throughput on text rendering (and I got no figure of the actual
slowness: for myself I noticed no problem) (I’m not rendering text on
each frame).

Notice: if some are interested in using SDL_Pango, but are missing a
couple of convenient functions in the SDL_Pango API, drop me a mail as
I’ve already added a little bit for my software’s needs (and sent it
upstream but received no response yet)

[1] in farsi as in arabic, characters need to be visually linked (much
like hand-writing latin-based languages), or else words are
unreadable, and the links “looks” follow kinda complex rules–
Guillaume Cottenceau - http://zarb.org/~gc/

Certainly on my to-do list for Tux Paint. I’d certainly accept help
getting it working, if anyone wants to contribute!

-bill!On Fri, Oct 13, 2006 at 02:26:56PM +0200, Guillaume Cottenceau wrote:

I’m posting here, to suggest users of SDL_ttf who want to provide
complete/correct i18n to switch to the much better SDL_Pango; and ask
if potential non-switchers had reasons for this choice - the main
disadvantage I can see when using SDL_Pango, will probably be that
it’s slower than SDL_ttf, but I think not many SDL programs need a
high throughput on text rendering (and I got no figure of the actual
slowness: for myself I noticed no problem) (I’m not rendering text on
each frame).

Hi Bill,

I’ve seen already some posts by you on google when searching info on
SDL_Pango :slight_smile:

I’ve replaced SDL_ttf by SDL_Pango in my software in very minimal
time. Of course it will depend on how your software is programmed etc.
Well, there is additional time to properly handle real RTL display if
you have to do it for sprites etc but this is another story.

Good luck anyway :)On 10/13/06, Bill Kendrick wrote:

On Fri, Oct 13, 2006 at 02:26:56PM +0200, Guillaume Cottenceau wrote:

I’m posting here, to suggest users of SDL_ttf who want to provide
complete/correct i18n to switch to the much better SDL_Pango; and ask
if potential non-switchers had reasons for this choice - the main
disadvantage I can see when using SDL_Pango, will probably be that
it’s slower than SDL_ttf, but I think not many SDL programs need a
high throughput on text rendering (and I got no figure of the actual
slowness: for myself I noticed no problem) (I’m not rendering text on
each frame).

Certainly on my to-do list for Tux Paint. I’d certainly accept help
getting it working, if anyone wants to contribute!

-bill!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Guillaume Cottenceau - http://zarb.org/~gc/

Guillaume Cottenceau escreveu:

Incidentally, I discovered SDL_Pango, an SDL binding for the
i18n-oriented very capable font rendering engine “pango”
(http://www.pango.org/).

I think you could already do that, with Pango + Cairo + SDL (creating a
Cairo context on a SDL surface, then using the Pango-Cairo API). But
maybe using Pango directly has less overhead (but let’s measure, not
estimate).

Now we only need a SDL_Input library that can handle complex text input.–
Daniel K. O.