Linear blending for glyphs

Søren Sandmann sandmann at cs.au.dk
Wed Nov 6 18:46:12 CET 2013


Markus Trippelsdorf <markus at trippelsdorf.de> writes:

> There is an interesting discussion on the FreeType mailing-list about
> the necessity to use linear blending for glyphs:
> http://thread.gmane.org/gmane.comp.fonts.freetype.devel/9105
> http://thread.gmane.org/gmane.comp.fonts.freetype.devel/9117
>
> Currently Linux performs the blending in non-linear space (without gamma
> correction). The issue could be fixed by using the following steps (to quote
> Dave Arnold):
>
> 1. get the background pixel and convert to a linear space
> 2. get the foreground pixel (text color) and convert to a linear space
> 3. combine the two colors in linear proportion to the text density 
>    (alpha value) for the pixel
> 4. convert the result back to the system color space
>
> Steps 1,2 and 4 can be done with lookup tables,
>
> I'm not familiar with the Xorg source, so my question is where in the Xorg code
> path should this conversion take place?

It depends on what you are trying to accomplish. If you are looking for
a hack so that you personally can see what it looks like, then you can
do the following:

   - Patch pixman (the function pixman_image_create_bits()) so that
     whenever someone requests the format PIXMAN_a8r8g8b8, you actually
     give them PIXMAN_a8r8g8b8_sRGB.

   - Make sure X doesn't use hardware acceleration, either by using some
     xorg.conf option, or by using the vesa driver (or running Xephyr)

I think this would give you linear blending for glyphs, though it will
also make things that use alpha values for translucency (as opposed to
antialiasing) turn out wrong. And it will be very, very slow.

If you are looking to add real support for blending in linear light, you
would need to extend the Render extension to offer this feature,
probably as a new format that mirrors PIXMAN_a8r8g8b8_sRGB, and then
speed up compositing of this format in pixman.


Søren


More information about the xorg-devel mailing list