[cairo] On the behaviour of cairo_scaled_font_create with regards to font options

sunmoon1997 sunmoon1997 at gmail.com
Fri Feb 23 03:23:53 PST 2007

On 2/23/07, David Turner <david at freetype.org> wrote:
> 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 ?

This behaviour is intented. The font options comes from FcPattern are
recorded internally and some of them can't be overriden later.
The font options from scale font are awlays a hint for font backend, font
backend may choose to respect them or even completely ignore them. FcPattern
contains all options from user configurations, if we ignore them or overide
them then we can't disable anitialiasing, set subpixel order etc by tuning
fonts.conf..., this is obviously not what we want.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/cairo/attachments/20070223/621b148b/attachment.html

More information about the cairo mailing list