[cairo] [RFC] Cairo operators expressed in shader syntax

Bill Spitzak spitzak at thefoundry.co.uk
Tue May 15 02:59:52 PDT 2007

Daniel Amelang wrote:
> On 5/14/07, Vladimir Vukicevic <vladimir at pobox.com> wrote:
>> Behdad Esfahbod wrote:
>>> Do PDF/AVG support component alpha masking?  PS, Quartz, Win32?
>> Win32 does not (but then, it supports very little, so that's ok); Quartz
>> also does not, AFAIK.
> Doesn't MS cleartype work by using component alpha masking? Is that
> just not exposed through the Win32 API?

Actually no. Subpixel antialiasing is somewhat different than 
per-component alpha, although Cairo and FreeType and maybe Microsoft all 
seem confused by this.

A subpixel mask is translated horizontally by 1/3 by the correct 
shuffling of the colors, while translating a colored mask by 1/3 
horizontally requires resampling of the colors (for linear interpolation 
each becomes 2/3 of the left and 1/3 of the pixel to the right).

Letters are drawn with a solid fill so often that it is likely Microsoft 
(and X, I hope) special-case this. In fact I would not be suprised if 
the subpixel antialiasing is ignored if anything other than solid fill 
is done (it is possible that the filtered subpixel image is a *worse* 
mask than a gray scale antialiased image, depending on the image being 
masked). Thus the call you desire may not be implemented at all.

The ideal way to do subpixel is to actually render the entire image at a 
higher horizontal resolution(*). Then you somehow filter this down to 
the output display. A colored mask can still be useful in this form of 
rendering, while the letters are just 1-channel masks (though stretched 
horzontally), which is also an indication that they are different.

(*)Not necessarily 3x, either. It looks like 2x, where one "subpixel" is 
green, and the other is magenta, may work better by requiring less 

More information about the cairo mailing list