Bug 13431 - Gamma not taken into account, white on black hard to read
Summary: Gamma not taken into account, white on black hard to read
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: 2.4
Hardware: All All
: medium enhancement
Assignee: Keith Packard
QA Contact:
Depends on:
Reported: 2007-11-28 13:05 UTC by Nicolas George
Modified: 2008-01-13 16:55 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas George 2007-11-28 13:05:58 UTC
When doing antialiasing, fontconfig-based renderers do not take gamma into account and assume a linear color space. This make black on white text difficult to read at small font sizez.

For example, with the font spec "FreeMono:pixelsize=10:autohint:hintstyle=3:rgba=none", used in the following test case:

xterm -fa $fa -geometry 20x2 -bg black -fg white -e 'echo foobar; sleep 10000'
xterm -fa $fa -geometry 20x2 -bg white -fg black -e 'echo foobar; sleep 10000'

The black on white version is quite readable on my screen, while the white on black version is almost unreadable.

The reason is that the stems of the glyphs are thinner than a whole pixel. Therefore, they get a fractionnal value. For example, the pixels on the lower part of the stem of the 'f' get the pixel value 151/255 in black on white, and 104/255 in white on black (and 104+151=255). With the usual 2.2 gamma, this makes respectively 32% and 14%, which gives a contrast of 68% for black on white, and 14% for white on black.

Obviously, the problem is not in fontconfig itself, but components that should do gamma correction need a gamma value, and this is fontconfig task to provide it.


  Nicolas George
Comment 1 Keith Packard 2008-01-13 16:55:16 UTC
Fontconfig has nothing to do with presenting the glyphs to the user, it simply selects the fonts. The bug you are seeing (and, yes, I agree that it is a bug even if white text on a black background is wrong) is due to limitations in various rendering libraries, like Xrender, cairo et al.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.