[cairo] Fwd: Re: Uniform Line Widths

Behdad Esfahbod behdad at behdad.org
Fri Feb 22 14:21:27 PST 2008


On Fri, 2008-02-22 at 16:55 -0500, Bill Spitzak wrote:
> Behdad Esfahbod wrote:
> >> I like the naming idea of using "set/get_pen" for the new API and that
> >> "set/get_line_width" would be convenience functions on top of those.
> > 
> > cairo_[sg]et_pen_matrix (cairo_t        *cr,
> > 			 cairo_matrix_t *pen_matrix);
> > 
> > The translation component of matrix will simply shift the pen, like it
> > does for font_matrix and pattern matrix.
> 
> Or I think it could be ignored, as that is what is done for font matrix,
> right? In any case it should be the same as font matrix.

Font matrix translation shifts the text.  It's done in gstate layer
though.  The scaled-font and surface layer ignore it.


> > Trickier would be dash offsets.  Would be cool to be able to have dash
> > matrix separate from pen matrix, eh?  Not sure, maybe we should lock
> > dash matrix at time of cairo_set_dash() too...  Who knows...
> 
> I was thinking that the dash pattern is drawn in "pen space" and thus
> when you pick a larger pen (using the new pen_matrix calls) you get
> larger dashes as well. For back-compatability the set_line_width would
> rescale the dash pattern.
> 
> I think there could be some advantage in having the stroking algorithim
> work this way in a space where the pen can be assumed to be a 1-unit
> circle, but am not sure. There is a problem in that if the pen is an
> ellipse the dashes would also be unequal in length depending on the
> direction, but I think this is compatible with current Cairo

Yeah, but if separating pen matrix, we should also go ahead and try to
make it possible to have a an ellipse pen but uniform dashes.

> and may be
> desirable if arbitrary end cap shapes are allowed. I suspect also things
> like mitre limit will produce different size points when the pen is an
> ellipse, but again compatible with the current version.
> 
> > Fixing this for text is even trickier.  When do you lock the ctm?!  At
> > cairo_set_font_size(), sure.  At cairo_set_font_matrix() too?!  That
> > kinda doesn't sound right, but makes some sense...  I'll discuss that
> > more when we consider this change...
> 
> I'm pretty certain it would be done at the time of the set_font_matrix.
> I believe font_size should be a convinence wrapper over this, just as
> you are proposing for the pen.

Problem with it is, people expect that sandwiching between
"cairo_save(); cairo_scale(2,2);" and "cairo_restore()" should make it
draw twice bigger text.  If we lock, that wouldn't happen.  Donno.

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list