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.)
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?
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?
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?
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.
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).
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.