[cairo] About cairo_show_text and UTF-8...
mike.emmel at gmail.com
Thu Jan 5 15:49:00 PST 2006
On 1/5/06, Bill Spitzak <spitzak at d2.com> 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.)
> 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).
I agree but the progammer should have and option to manage the fontset.
I'm not sure the library should be in cairo as I mentioned earlier I started
on a library like this that would be a simplified fontconfig specific
library to do these
things on top of cairo.
In addition to simply drawing the chars there is bidi and string
breaking issues esp
with multi-lingual text. Agian a library closely associated with cairo
that manges the complexity of real world text drawing is needed. It
could ship with cairo but I don't think cairo's
current api should be changed to behind the covers creat fontsets when
you ask for a cairo font. In any case I simply don't have the time to
work on this even though I too feel its sorely needed. You may
consider looking at the layout code in one of the web browsers or
even xft may be a good choice.
> 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.
I don't know about this Pango has its own established api. I'd say let
pango and cairo continue as they are. Cairo should always provide
a true simple drawing api with a real font.
> 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