[SDL] SDL_Pango

Guillaume Cottenceau gcottenc at gmail.com
Fri Oct 13 05:26:56 PDT 2006


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/




More information about the SDL mailing list