[cairo] thin antialiased lines

Timothée Lecomte timothee.lecomte at ens.fr
Mon Jul 16 14:21:50 PDT 2007

control H wrote:
>> There _are_ known techniques for drawing very nice non-antialiased
>> lines, (much better than what GDK does I believe). The key idea is to
>> use a specially-created polygon for the pen called a Pen
>> Polygon. This a technique developed by John Hobby for his Ph.D. and
>> then also described much more succinctly here:
>>         [Hobby89] John D. Hobby, Rasterizing Curves of Constant Width,
>>         JACM 36(2), 1
>>         http://cm.bell-labs.com/who/hobby/87_2-04.pdf
> Interesting, thanks for the link. I understand from your remark of
> adding the non AA mode for rendering under duress, that it's not
> likely to be implemented soon, if at all. Unless I can force you to...
> and do it under duress again. Just kidding.
>> So, augmenting cairo to do this well is really as simple as writing a
>> single function that accepts a desired line width and computes a Pen
>> Polygon, (several Pen Polygons for small, common sizes could even be
>> pre-computed and just returned from a table).
> I'm afraid for me as an end user of cairo, it's not that simple... :(
> I'll see if I can find something in the mailing list archives.
> More and more programs are adding support for cairo based output, and
> have the same "problem" of too thick or blurry lines. One example is
> the statistical package R (www.r-project.org). Plotting a normal
> distribution looks very nice, while plotting a survival curve (which
> basically consists of more or less horizontal lines) looks blurry.
> What would you suggest to fix this? If I understand correctly from
> googling around some hours, will auto snapping fix this? And will this
> auto snapping be implemented in future? If yes, then there's no need
> for me anymore to disable AA.

For what is worth, I have implemented something like auto-snapping for 
the cairo-based terminal for gnuplot (called wxt). Since this process is 
called "hinting" for glyphs, I'm calling it "hinting" rather than 
"auto-snapping". It is snapping horizontal and vertical lines to the 
closest integer position. It's quite easy to do, the hardest thing is to 
take care of paths made of more than two points... Here are two screenshots:


Best regards,


More information about the cairo mailing list