Text [was Re: [Cairo] Color transforms]
Owen Taylor
otaylor at redhat.com
Fri Jul 18 15:56:13 PDT 2003
On Fri, 2003-07-18 at 18:21, Carl Worth wrote:
> On Jul 18, Owen Taylor wrote:
> > Just remember that any Cairo text API's for applications will be
> > more or less "toy"; for heavy-duty usage, you need a Pango equivalent.
> > So, there is no point in getting too fancy with the part that
> > isn't "draw these glyphs at these positions".
>
> Precisely. And we do not want anything resembling a Pango equivalent
> sneaking into Cairo. So, not too worry, the API will not go beyond
> glyph placement, (with transformation of course).
Presumably you do also want the "toy":
cairo_draw_string (CairoState crs, const char *utf8_string);
as well, so people can have text in their demos.
> Cairo will also build on top of significant libraries such as freetype
> and fontconfig.
>
> So there's not a whole lot left for Cairo to have to do, (running a
> few coordinates through a matrix is trivial enough). But as a
> middleman, Cairo must be careful not to get in the way. A higher-level
> "Pango equivalent" needs access to the metrics, etc. from the
> lower-level libraries. Providing that access in a clean and portable
> way may be the trickiest part of the interface to get right.
Off the top of my head, I think what Pango needs from Cairo is
something along the lines of:
- Load the CairoFont for this fontconfig pattern
- Give me the FT_FACE for this CairoFont set up for the
current display metrics
- Draw these glyphs from this CairoFont at these locations
You might be able to avoid having a "CairoFont" object by
just having "make this fontconfig pattern current", but I'd
worry that the inefficiency from repeated pattern lookups
could be considerable.
The current Xft API generally works fine for Pango; the complete
list of Xft functions that Pango uses is:
XftCharExists XftCharIndex XftCharSpecRender
XftDefaultSubstitute XftDrawCharSpec XftDrawGlyphSpec
XftDrawRect XftFontClose XftFontOpen
XftFontOpenPattern XftGlyphExtents XftGlyphSpecRender
XftLockFace XftTextExtents8 XftUnlockFace
The XftGlyphExtents usage is basically just for convenience
since Pango also pulls metrics from the font directly for
kerning / GPOS/GSUB / etc.
XftTextExtents8, XftDrawCharSpec, XftDrawRect is just
for drawing hex squares.
Beyond what Pango is doing currenntly, I'd actually like to be able
to access both:
- The FT_FACE/metrics hinted for the current scale factor
- The FT_FACE/metrics with no hinting scaled for the current
scale factor
Since I believe that the correct way of handling device-independent
/ device-dependent metrics differences is along the lines of
"lay out words for device-independent metrics, adjust spacing within
words for the
But I'm not really sure how that plays out in the API.
Regards,
Owen
More information about the cairo
mailing list