[cairo] About cairo_show_text and UTF-8...

Bill Spitzak spitzak at d2.com
Thu Jan 5 13:22:55 PST 2006



Mike Emmel wrote:
> On 1/5/06, Scott Robert Ladd <graphics at coyotegulch.com> wrote:
> 
>>Mike Emmel wrote:
>>
>>>The system font in cairo does not have those glyphs.
>>>Pango uses a collection of fonts to meet the unicode requirements of a string.
>>
>>Hmmm... perhaps this is something that should be clearer in the
>>documentation or Cairo. I assumed that the default Cairo font would be
>>the same as the default GTK+ font (which does include these glyphs).
>>
>>Why the difference in fonts? If Cairo is the rendering agent for GTK+,
>>should they be using the same default fonts?
>>
> 
> 
> Pango marshals a collection of fonts that will handle all the unicode
> chars in a string. cairo is used to draw pieces of the string with the
> font that provides the unicode glyphs.
> In general no font has all the unicode glyphs so to draw a arbitrary
> unicode string you must either have a library like pango or implement
> it yourself.

However I would argue that Cairo *should* do this. Cairo is supposed to 
be supplying an easy-to-use program API. Having to choose the "right" 
font depending on what characters are in your string is *not* user 
friendly. Nor is full-on Pango user friendly, because the api is too 
complex (for necessary reasons. Pango would be used by library text 
editing/display widgets but will NEVER be used directly by a program 
written by a non-expert.)

Pango's font-collection code should be moved to Cairo/FreeType so that 
you can get an entire set of Unicode glyphs trivially (by selecting a 
font by name) and so that sending the same "font name" to Pango and to 
Cairo will produce the exact same glyphs (these different font names is 
currently making people like me *less* likely to use Pango, not more!). 
Pango's behavior should be improved by using a back-up 16x16 bitmapped 
font of all the assigned Unicode glyphs, so you see something, no matter 
what font is chosen. I suspect such a shared backup is more easily 
accomplished in Cairo/FreeType than in Pango.

Cairo should then provide a "I will draw all the glyphs in this UTF-8 
string next to each other" call. (go ahead and call it "toy" as much as 
you want, but this is what *everybody* wants and what 99.5% of the 
programs written with Cairo are going to use).

Cairo should also provide the "draw all these glyphs indicies at these 
x,y positions" that Pango will call. Since Pango needs "alternative 
forms" these should be placed into locations outside the Unicode 
0x10ffff range so that Pango can index them, while still only 
communicating a single font to Cairo.

PS: programmers choose the "symbol" font so that the ascii code for 'a' 
will print an alpha, not because it is some secret incantation so that 
the unicode alpha index will work. The current behavior is useless and 
is incompatable with Windows. Please fix it.


More information about the cairo mailing list