[Cairo] Why not Xr?

Justin Bradford justin at maxwell.compbio.ucsf.edu
Wed Aug 13 15:27:20 PDT 2003

I think I want to retract my previous concerns, since Keith's email about
platform specific functions for font selection pretty much ends the
problem, as far as I can tell.

As for a platform-independent "convenience" function for font selection,
some cross-platform libraries (like wx) let you pick a generic font
class for the times you don't care enough to write os-specific code,
like "serif", "sans serif", "monospaced", etc.

So perhaps cairo could have a similar set of font mappings. Every
platform would just have a list of specific font names/patterns for that
class. I suppose that doesn't help for non-western languages, though.

But this is a really general problem for cross-platform toolkits, and I
still don't think it's cairo's place to solve it. Unless there are some
really common cases which can be solved in a single, short source file, I
think platform specific only is ok.

Also, I had some questions on the rendering side of font handling.

I assume cairo_font is basically an interface with specific font backends
wrapping a FT_Face (is that the right term?) or LOGFONT, right?

And in the cairo_draw_text function, the specific backend implementation
gets the underlying specifics from the cairo_font wrapper?

So x11/cairo_draw_text looks like:

if (font->type() == "FT_Face") {
 FT_Face native_font = ((cairo_font_ftface_t*) font)->get_ftface();
} else {

And replace FT_Face with LOGFONT for the GDI+ backend?

What goes in the "else", though? Perhaps cairo_font has a generic render
function, too? So it becomes:

} else {
  font->render_generic(state, text, x, y);

And the render_generic function just draws the necessary paths on the
cairo_state or renders a bitmap and blits it onto the state? This would
let you do Freetype on Windows, or write a simple cross-platform font
format/renderer for testing purposes.

Postscript and similar backends just need a "get_glyph_outline" function
on the cairo_font which just returns paths, right? Some formats (like PDF,
I believe) allow embedded glyph info to have hinting and control points,
too (in the form of a t1, or opentype, or whatever format). Any way to do
this nicely? Perhaps a "get_glyph_outline_with_hints" and the backend has
to put it all back together in the right form for output?

Or is this all part of the plan already?


More information about the cairo mailing list