[cairo] Cairo + Pango

Bill Spitzak spitzak at d2.com
Sat Aug 7 15:34:39 PDT 2004


On Saturday 07 August 2004 10:58 am, Jon Smirl wrote:
> If I read the Microsoft docs right Longhown has an API where you pass
> in all of the glyphs and floating point x/y coordinates for them. The
> floating point positioning is used to achive subpixel placement of the
> glyphs.
>
> Pixels on most LCDs look like this:
> RGBRGBRGBRGBRGBRGB
>
> With pixel level positoning the glyph will always start on an R. With
> subpixel positioning the glyph can start on any of RGB. Subpixel
> positioning is different than subpixel smoothing which X currently
> does.

It's a lot more than just that LCD trick. Just plain monochrome antialiasing, 
if done correctly, must produce a different image for different fractional x 
and y cooridinates. Usually the coordinates are rounded to finer fractional 
positions, such as 1/4 pixel.

The LCD hack really means that b&w glyphs are produced at a resolution that 
is 3x higher horizontally. Plus the rendring is adjusted so that vertical 
lines are 3 wide (so they have no color). These b&w glyphs are "positioned" 
by making them mess with the colors, but until this final stage it is best to 
think of the screen as having 3x horizontal resolution. These rules should 
also be used for Cairo's antialiasing so it can antialias the LCD correctly.

Because of this higher fake resolution of LCD screens it may not be necessary 
for the glyphs to have a further 4x horizontal positioning accuracy.

My recommendation:

LCD screens should be treated by Cairo exactly like they have 3x resolution 
in one direction. All transforms, etc, should be done as though this is the 
final output device. The final stage of compositing selects from the r,g,b of 
source and destination images according to x%3. The other trick is that thin 
lines are made 3 pixels wide horizontally, and the font renderer also likes 
to make things 3 pixels thick.

Compelety independendly, the glyph cache has nxm samples of each glyph, for n 
horizontal and m vertical pixel subpositions. For normal screens this should 
probably be 4,4. For an LCD screen maybe it should be 1,4 since the 3x 
sampling of the LCD makes up for it. For very high resolution screens this 
could be reduced to 2,2 and then 1,1.



More information about the cairo mailing list