[cairo] Reworking text handling

Keith Packard keithp at keithp.com
Mon Aug 22 20:02:03 PDT 2005


On Mon, 2005-08-22 at 21:53 -0400, Owen Taylor wrote:

> It's not at all clear from the above that it is a bitfield like this.
> Cairo doesn't have any existing bitfields, so there isn't really
> precendent. What what I'm used to (GTK+ style)
> 
>  typedef enum _cairo_scaled_glyph_shape {
>      CAIRO_SCALED_GLYPH_SHAPE_SURFACE = 1 << 0,
>      CAIRO_SCALED_GLYPH_SHAPE_PATH    = 1 << 1
>  } cairo_scaled_glyph_shape_t;
> 
> and use 0 and 
> (CAIRO_SCALED_GLYPH_SHAPE_SURFACE | CAIRO_SCALED_GLYPH_SHAPE_PATH)
> for the other two values.

I'd like to have CAIRO_SCALED_GLYPH_SHAPE_NONE = 0 as well; that's a
really common value, and using a bare '0' there seems confusing.

> I'm not sure if it's the names or the operations that are confusing
> to me? Can you call ensure_shape() without having called init()
> first? I'd think of init() to be always the first thing you do?

The first time, you use _init. After that, you use _ensure_shape. The
metrics are always in the cache, the shapes are optional. Calling
_ensure_shape without having called _init is an error.

> What if you extended your enum to:
> 
>  typedef enum _cairo_scaled_glyph_shape {
>      CAIRO_SCALED_GLYPH_SHAPE_METRICS = 1 << 0,
>      CAIRO_SCALED_GLYPH_SHAPE_SURFACE = 1 << 1,
>      CAIRO_SCALED_GLYPH_SHAPE_PATH    = 1 << 2
>  } cairo_scaled_glyph_shape_t;
> 
> s/shape/info/ and dropped init()? If that encodes the meaning, then
> it would be a lot clearer to me.

Yeah, that's a whole lot nicer looking. Sold.

-keith

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050822/ac3816d3/attachment-0001.pgp


More information about the cairo mailing list