View Full Version : Cairo can't render Chinese?

June 6th, 2010, 11:02 PM
Cairo doesn't render Chinese at all, have a look at the screenshot.
The string itself is ok, since when I print it to the command line right before issuing "cr->show_text(sFileName);" it prints: "天安門廣場" - thus the string itself is ok.
I'm using gtkmm & Lucid Lynx.

I found other folks talking about similar issues back in 2008:

Anyone familiar with the matter or any suggestions?

I'm not Chinese nor have anything to do with it, I just want my app to work properly.

June 7th, 2010, 03:19 AM
You'll want to use Pango for that.

Cairo has two sets of text rendering capabilities:

The functions with text in their name form cairo's toy text API. The toy API takes UTF-8 encoded text and is limited in its functionality to rendering simple left-to-right text with no advanced features. That means for example that most complex scripts like Hebrew, Arabic, and Indic scripts are out of question. No kerning or correct positioning of diacritical marks either. The font selection is pretty limited too and doesn't handle the case that the selected font does not cover the characters in the text. This set of functions are really that, a toy text API, for testing and demonstration purposes. Any serious application should avoid them.
The functions with glyphs in their name form cairo's low-level text API. The low-level API relies on the user to convert text to a set of glyph indexes and positions. This is a very hard problem and is best handled by external libraries, like the pangocairo (http://library.gnome.org/devel/pango/stable/pango-Cairo-Rendering.html) that is part of the Pango text layout and rendering library. Pango is available from http://www.pango.org/.


June 7th, 2010, 04:09 AM
I searched for "pangomm tutorial" and the only thing I've found is another guy asking for this with no reply:
Anyone aware of any pango(mm) tutorial?

September 21st, 2010, 02:12 AM
There is a little bit of info here: http://cairographics.org/FAQ/#using_pango