[cairo] Locking font / pen space

Bill Spitzak spitzak at gmail.com
Fri Aug 27 13:37:44 PDT 2010



Behdad Esfahbod wrote:
> It occured to me last night that instead of changing the behavior of font /
> pen space locking at the they are set, we can add two new calls:
> 
>   cairo_lock_font_space()
>   cairo_lock_pen_space()
> 
> These two will record the ctm at the time of the call to be used for text /
> stroke until the font-space / pen-space is set again (perhaps implicitly by
> cairo_restore()).
> 
> May want to add the unlock() versions too.  I don't like the fact that the
> unlock is not mandatory, but I think I can live with this API and have more
> confidence in it than I have in changing the semantics of existing API.

This sounds like it would work.

I would prefer it to not be reset by changing the font/pen. The reason 
is for consistency with "pattern space" which is "locked" all the time 
and is not "unlocked" when you change the pattern transform. The whole 
point is to make all the transforms consistent (and IMHO usable).

For the same reason, I see no need to separate the pen and font, just 
have one call lock both. This is then simply a "mode" to change cairo's 
behavior. restore() will put it back, and there can be an unlock() too.

If this is a "mode" it means a lot of other api can switch behavior and 
this would avoid a lot of incompatibility problems or tricky emulation. 
In this mode dash patterns are in "pen space", and font metrics returned 
in "font space". Glyph positions would also be given in "font space", 
relative to either 0,0 or the current point in the CTM.

I think there is no way around adding a new api to get/set the pen space 
as 4 numbers.


More information about the cairo mailing list