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

Owen Taylor otaylor at redhat.com
Fri Jan 6 10:26:26 PST 2006


On Thu, 2006-01-05 at 13:22 -0800, Bill Spitzak wrote:
> 
> 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.)

That's a vast exaggeration ... as I demonstrated in my previous 
mail drawing text  with Pango is only a few lines of code. And it
provides many features that non-experts frequently need. Like
line-wrapping text, say.

> 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!). 

This is not remotely possible (I think I've explained this before but
I'll try again)

Pango deals with fonts on a level that is *not* a simple model of
character => glyph. Modern fonts include tables that describe how
the different glyphs in the font interact with each other; this
includes kerning, ligatures, and more sophisticated forms of
combination that are essential to rendering most of the scripts of the
world. (Arabic, Hindi/Devanagari, Thai, etc, etc, etc.)

So, you can't just take two fonts and glom them together into one
big font that has all the characters in either font.

You *could* add fontsetting code into the Cairo toy API. That would
require changes to the Cairo internal interfaces, but is otherwise
not all that hard. But it would be entirely separate from the Pango
fontsetting code, other than they would both use fontconfig to
get the lists of fonts to combine.

Regards,
					Owen




More information about the cairo mailing list