[Cairo] [PATCH] new virtualized font interface

graydon hoare graydon at redhat.com
Sat Oct 4 15:19:35 PDT 2003


attached is a big ugly patch which moves cairo_font_t into a "first
class" object with its own little refcount,
allocator/destructor/copier, and vtable/backend thing. this is on top
of jamey's recent work virtualizing the surface interface.

along the way, it strips out the Xft font code and replaces it with
some (immature and incomplete) FT2 font code, which means in essence
moving the rendering back to client-side for the time being. the
upside being that it can actually render on client surfaces :)

a few other differences are worth noting: 

  - the font model is richer. it now supports (in interface though not
    yet implementation) the stuff discussed in keithp and owen's email
    thread last month: glyph vector rendering, glyph -> path
    conversion, extraction of some precise metrics, etc. the only part
    of this I've really implemented in the FT2 backend is the glyph
    vector rendering, because that's what I immediately needed :)

  - there is both a "font object" and "just cairo_t" way of using the
    font system. if you want you can get/set/change the font object
    itself. if you don't care about fonts much, you can just do simple
    tasks like cairo_show_text(cairo_t *, "hello world"). not every
    font method is exposed this way, and none of the rendering of
    path-conversion methods can be done on fonts alone. maybe this
    separation is a bit messy, maybe it's convenient enough to keep. I
    don't know.

  - I stripped out 2 methods (well.. "failed to port them") which
    mutate state of a font.  these are "scale" and "transform". I kept
    these as parameters for constructing new fonts, and it's certainly
    possible that there's a sensible interpretation for the mutators
    too, but I decided at this early sketch of the code to keep the
    API "value oriented": you want a new font, you make a new font.

  - most importantly: it presents a "split level" API with one set of
    font object interfaces for users who know about their "platform
    font system" and a less detailed one for those who don't. you can
    construct fonts from platform font resources, and fetch them back
    later by downcasting. I have used this in my test application to
    construct a font and glyph vector using pango (under java2d) and
    only pass the FT_Face and coordinates into cairo "at the last
    moment" for drawing. I think this is what "clever" applications

  - I am conditionally-compiling the "know about the platform font
    system" part of the split level interface. like, with
    #ifndef(WIN32), in cairo.h. this is probably a bit tasteless, and
    you're welcome to switch it to something else.

  - probably all the fontconfig-using code is wrong.

anyways, enough talk. incorporate and/or fix what you like :)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-new-font-model.patch.2
Type: application/octet-stream
Size: 57887 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20031004/453b526b/cairo-new-font-model.patch.obj

More information about the cairo mailing list