[cairo] line width questions

Ian Britten britten at caris.com
Fri Aug 15 09:52:35 PDT 2008

Hi all,
Just a couple of quick questions about set_line_width()
[ Disclaimer - Yes, I read the FAQ.  Those aren't my questions ]

First, is there a quick/easy way to draw a line "as thin as possible"?
With some toolkits, you can simply set the width to zero to achieve
this (And is the idiom our classes are currently using), but it seems
with Cairo, if I set it to zero, the line simply doesn't draw!  :(
[ I guess you could argue it's correct, just maybe not expected ]

Otherwise, it seems like for each line I draw, I'm going to have to:
- Check if it has a zero or non-zero thickness
- If non-zero, simply proceed to set it.
- If zero, then convert one device unit to user units, just to set
   it in user units on the context (Which will presumably then just
   convert it back to device units...)
   [ Strangely though, in this case the lines in my PDF output look
     to be too thick, but I'm still looking into that...  Part of the
     problem is that I'm not sure what 1 device unit is in PDF... ]
It's not a big issue I guess... I'm just always watching for places
to simplify my code and reduce the number of steps I need to do.

Second, wouldn't "as thin as possible" be an apt default thickness,
rather than 2.0 *user* units?
[ Ya, I know you can't change it - Just wondering about the decision ]

Some of our data is normalized, so that my user-space may be
(0,0), (1,1).  Obviously, drawing lines at the default 2 user units
wide in that case resulted in a big blob...  Bletch!

Thanks for any info/suggestions!
PS - There's either a typo in the on-line docs for
Cairo::Context::set_line_width(), or else something doesn't make
sense (to me).  It seems to be talking about cap style, and looks
like it might have just be copied from set_line_cap().

More information about the cairo mailing list