[cairo] On the behaviour of cairo_scaled_font_create with regards
to font options
David Turner
david at freetype.org
Fri Feb 23 01:10:06 PST 2007
Hello everyone,
I'm reaching completion of my changes to Cairo's FreeType/FontConfig backend; The code
runs well but there is a notable difference from the current implementation that I don't
know how to interpret correctly.
In the current implementation, if I use cairo_ft_font_face_create_for_pattern() with a
source pattern that has FC_ANTIALIAS set to FALSE, this setting is recorded internally,
and cannot be overriden later in scaled fonts. What I mean is this:
// create FcPattern without anti-aliasing and the corresponding font face
.. create 'pattern'
FcPatternDel (pattern, FC_ANTIALIAS)
FcPatternAdd (pattern, FC_ANTIALIAS, FC_FALSE);
font_face = cairo_ft_font_face_create_for_pattern (pattern);
// create a scaled font using CAIRO_ANTIALIAS_GRAY as an option
font_options = cairo_font_options_create ();
cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_GRAY);
scaled_font = cairo_scaled_font_create (font_face, &some_matrix, &some_ctm, font_options);
// rendering will NOT be ANTIALIASED !!
I find it very strange since none of the other font backends seem to ignore the
used-provided font options when creating a scaled font.
Is this a bug, or even desirable. I find it extremely confusing, and an un-needed special-case.
It seems the only alternative is to explicitely alter the pattern depending on your
desired font options, *before* creating the font_face itself. This is exactly what the
test "ft-text-antialias-none" does, with something that looks like:
FcConfigSubstitute (NULL, pattern, FcMatchPattern);
cairo_ft_font_options_substitute (font_options, pattern);
FcDefaultSubstitute (pattern);
resolved = FcFontMatch (NULL, pattern, &result);
it also seems that cairo_ft_font_options_substitute's raison-d'être is only to support
this weird special-case.
So, should we keep this behaviour as is, or should we fix it ?
Thanks in advance,
- David Turner
- The FreeType Project (www.freetype.org)
More information about the cairo
mailing list