Bug 4792 - CAIRO_ANTIALIAS_GRAY font option doesn't turn off subpixel rendering
Summary: CAIRO_ANTIALIAS_GRAY font option doesn't turn off subpixel rendering
Status: RESOLVED DUPLICATE of bug 11838
Alias: None
Product: cairo
Classification: Unclassified
Component: freetype font backend (show other bugs)
Version: 1.0.2
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Jinghua Luo
QA Contact: cairo-bugs mailing list
Depends on:
Reported: 2005-10-17 16:55 UTC by Ilmari Heikkinen
Modified: 2008-10-10 15:20 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:

a proposed patch (10.01 KB, patch)
2006-06-17 02:14 UTC, Jinghua Luo
Details | Splinter Review

Description Ilmari Heikkinen 2005-10-17 16:55:28 UTC
Setting context's font_options->antialias to CAIRO_ANTIALIAS_GRAY leaves
FT_LOAD_TARGET_LCD on in cairo-ft-font.c. 

This causes FT to load the glyphs with subpixel antialiasing. 

Manually zeroing the FT_LOAD_TARGET_LCD flag from load_flags in
_cairo_ft_scaled_font_create_toy made it use grayscale antialiasing.

Quick hack workaround is to do something like this before the call to

    if (options->antialias == CAIRO_ANTIALIAS_GRAY)
      load_flags &= !FT_LOAD_TARGET_LCD;

I don't know where the correct place to do the flag zeroing is (ie. what
function is responsible.)
Comment 1 Jinghua Luo 2006-06-17 02:14:45 UTC
Created attachment 5949 [details] [review]
a proposed patch

I just attached a patch that should fix this problem. 
Could you apply this patch to cairo HEAD and see what happens?
Comment 2 Jinghua Luo 2006-06-25 22:18:09 UTC
You can't disable subpixel rendering by setting antialias to 
CAIRO_ANTIALIAS_GRAY in some cases such as you set argb in fontconfig. 
The font options is a hint for font backend, somethings the font backend
may ignore them completely. I think this is expected behavior and user expects 
this, otherwise people will complain fontconfig doesn't work any more which is 

With above commit, the freetype backend uses the font options combined with 
options from font pattern and doesn't set load target to FT_LOAD_TARGET_LCD
[_V] while antialias in combined font options is CAIRO_ANTIALIAS_DEFAULT or 
CAIRO_ANTIALIAS_GRAY. So, I'm going to close this bug. Any further comments?
Comment 3 Carl Worth 2006-06-26 05:01:48 UTC
The interaction of the various font options can get tricky.

I thought at one point that Owen Taylor had written a description of the various
places font options can come from, (fontconfig, per-surface defaults, explicit
calls to cairo_set_font_options, etc.), and also described which options should
override the others.

I can't find the email I was imagining on that subject, but I'd love to add a
paragraph like that to the cairo documentation.

Keith or Owen?

Comment 4 Carl Worth 2006-06-26 05:06:37 UTC
In this specific case of this bug, I think that if code using cairo explicitly
passes ANTIALIAS_GRAY then the font backend should respect that (if it is
capable of doing so, obviously).

If the user of such an application would complain that an "argb" option set
through fontconfig was being overriden then that user should complain to the
author of the program.

That is, the explicit calls to cairo_set_font_options should be the final word
on font options and should override any previous implicit settings.

Comment 5 Keith Packard 2006-06-26 15:24:24 UTC
The default fontconfig settings respect application settings for all rendering
options. User customizations may override these.

That's how it's supposed to work; users should always be able to override
application developers choices as it is imperative that end users be able to
override broken environments (and, frankly, broken applications).
Comment 6 Chris Wilson 2008-10-10 15:20:01 UTC
Forward dup to 11838, as the semantics of applying font options are the same and should be covered in the same review of _ft_font_options().

*** This bug has been marked as a duplicate of bug 11838 ***

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.