[cairo] Cairo and ISO C++

Bill Spitzak spitzak at gmail.com
Thu Jan 16 12:39:28 PST 2014


Emmanuel PACAUD wrote:

>> You cannot adjust all the strokes to the nearest pixel because this will 
>> either cause identical objects to vary in size, or identical gaps 
>> between objects to vary in size. Both look much uglier than 
>> antialiasing. 
> 
> Well, that is more or less what we do in goffice, the graphing library
> of gnumeric, and it's not that ugly. All layout measurements are done in
> points, and we get crisp rendering whatever the zoom level is.

I just feel that it is better to have the application do this. For 
instance in your sample output it might be better to preserve the 
thickness of the bars when they don't touch. I also notice that you did 
not adjust the vertical lines in the first sample and rendered them with 
antialiasing instead.

In any case you are right, a cairo backend could adjust all paths before 
rendering. An application doing something more intelligent would have no 
problem taking this into account and may want to use it.

A scheme I think may work is to adjust paths by moving horizontal and 
vertical tangents to the nearest integer, and all other parts by an 
interpolation between the movement of the nearest two snapped parts. It 
would also have to round line widths to an integer and offset strokes by 
.5,.5 for odd integers. The biggest trick is to not add gaps or overlaps 
when programs try to draw touching objects or place strokes inside or 
outside objects, I think if you assume the program knows the line width 
is 1 or larger that this can be made to work.

And it probably wants to adjust the transform of source images to the 
nearest integer. It should do this even if there is rotation or scale, 
because otherwise the image may jump slightly if it is animated.


More information about the cairo mailing list