[cairo] Write ups on Microsoft Avalon

Bill Spitzak spitzak at d2.com
Mon May 17 10:02:14 PDT 2004

On Sunday 16 May 2004 08:19 pm, Peter Dennis Bartok wrote:
> There are a few situations where the ability to 'turn off anti-aliasing'
> is required. For example, when drawing fonts smaller than a certain size,
> in order to keep it actually readable and not 'smudged' it is important.
> I'm working on Mono (SWF) and one of the sample apps I use brings this
> difference out quite strong, when I compare the output of MS with the
> output of Mono through Cairo, the Mono version is much harder to read with
> a 6pt font.
> Also, for situations like drawing a Hotkey marker or an underline for
> text, anti-aliasing is really defeating the purpose, it simply will look
> off if you have a blurry line underlining the hotkey character or the text
> line.

Neither of these are good examples of "need to turn off antialiasing". Both 
of them may indicate that the rasterization is not producing the most 
beautiful pictures possible, but that means the rasterization should be 
fixed, not that we need an option to change the algorithim. Such options lock 
the algorithim, for instance on Windows it prevents use of the lcd rgb 
shifting even though that can be done in a "non-antialiased" way, due to the 
fact that programs assumme other effects of turning off antialiasing.

The font renderer certainly can change how it renders the glyphs to make them 
as nice as possible. This does not mean "turn off antialiasing", what it 
means is to shift and adjust lines in the letters so they are 1 pixel wide 
and aligned to 1 pixel vertically, and 1 or 1/3 pixel horizontally. Curves in 
the glyphs can and should still be antialiased.

Character widths are a much bigger problem. I am pretty convinced that we 
cannot have character widths depend on the current transform and the font 
renderer. If the renderer produces glyphs renderered at several different 
fractional positions the output looks quite good despite this, the only 
problem is when a character or pattern is repeated, for instance "iiiiiiii" 
will look irregular even if the antialiasing was perfect. The only solution I 
can see for this is for Cairo's low-level renderer to accept strings of 
glyphs and for it to be allowed to adjust the positions of the internal ones 
so the string is about the same width but more regular looking (somebody else 
here posted some documentation on these algorithims). This may not sit very 
well with the Pango people, however.

Line widths could be solved by special-casing '0' line width to mean the 
nearest multiple of pixels to 1/96 inch, and that the line centers are 
adjusted to be in the middle of pixels. This would be the default line width. 
The reason for this special case is to discourage the many programmers who 
try to "fix" it by adjusting the CTM so that the integers are at the centers 
of the pixels rather than the corners, which makes predictable results for 
integer rectangles impossible (this is a personal peeve of mine, the NeWS 
guys completely broke the renderer in an attempt to "fix" integer rectangles, 
because they thought the default had to center integers in the pixels so that 
1-pixel lines would draw right).

The only real reason for no-anti-aliasing is so that you can predicatably 
"erase" an image by drawing it again in the background color. This can either 
be ignored, or handled by a new compositing mode that replaces the alpha a 
with (a>0)?1:0

                   ,~,~,~,~ ~ ~ ~ ~
     /\_       _|_========___         Bill Spitzak
 ~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com

More information about the cairo mailing list