[cairo] First implementation of font Changes
Carl Worth
cworth at redhat.com
Wed Apr 6 08:24:58 PDT 2005
On Wed, 06 Apr 2005 09:41:48 -0400, Owen Taylor wrote:
> Here's a first implementation of the font name changes I proposed a few
> weeks ago.
Great work, Owen! This is looking really good to me.
> - Find a final name for cairo_font_name_t. My suggestion is
> cairo_face_t.
That might be fine, but see an alternate suggestion below.
> * src/cairo.h src/cairo-gstate.c src/cairo-font.c: Add
> a cairo_font_name_t type to hold a description of a font
> face. Replace cairo_set_font() with cairo_set_font_name().
I had expected to also find a cairo_set_font that accepts a
cairo_font_t, but it's not there, (which is fine). I actually really
like the way this cairo_font_t object works now. It's its own object,
which exists only for getting metrics in a way which allows good
performance.
So, there aren't any cairo_t functions that do anything with
cairo_font_t. Instead, a cairo_font_t is only used with its own
cairo_font functions. I like this approach, but I don't like the
naming.
The problem is that we do have cairo_t functions that talk about a
"font", (cairo_select_font, cairo_set_font_size,
cairo_get_font_extents). So there's a disconnect in naming here. And
just switching the cairo_t function to use "face" everywhere doesn't
work well, (set_face_size strikes me as somewhere between ugly and
meaningless).
Owen and I have been talking about this in IRC a bit, and have been
batting around suggestions such as changing cairo_font_t to
cairo_scaled_font_t and/or changing cairo_font_name_t to
cairo_font_face_t. I think Owen shot down my suggestion of changing
cairo_font_name_t to cairo_font_t.
So I don't have a solid proposal yet, but we'll need something here.
> * src/cairo.h src/cairo-font.c src/cairo-ft-font.c
> src/cairo-win32-font.c: Pass in font matrix and CTM separately
> rather than as a composite scale when creating fonts; allows
> removing font_matrix argument to metrics functions.
Fantastic! I really like how much more clear this is. I always found
"cairo_matrix_t *scale" to be a confusing argument. Separate CTM and
font_matrix arguments make this quite clear.
And reducing the number of arguments needed for getting extents is a
nice improvement as well.
Something else I just noticed in the font API, not directly related to
the proposed changes, is that we currently have these three extents
functions on the cairo context:
cairo_get_font_extents
cairo_text_extents
cairo_glyph_extents
and this extents function on cairo_font_t:
cairo_font_extents
The fact that one in four has a "get" in the name seems a misfeature,
(though, obviously, removing it would introduce a name clash with the
cairo_font_t function.
If we had "cairo_font_t *cairo_get_font (cairo_t *cr)" we could drop
cairo_get_font_extents in favor of:
cairo_font_extents (cairo_get_font (cr));
and avoid the problem. But that would re-introduce cairo_font_t into
the cairo_t API and exacerbate the naming problems discussed above.
Beyond these little naming issues, (isn't that always the case?), I
think we're getting close the right API.
Thanks again,
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050406/23d5e49f/attachment.pgp
More information about the cairo
mailing list