[cairo] OpenType font variations and cairo

Matthias Clasen matthias.clasen at gmail.com
Fri Sep 22 11:10:39 UTC 2017

On Fri, Sep 22, 2017 at 1:10 AM, Werner LEMBERG <wl at gnu.org> wrote:

> > One of my tests happens to set the axes to the coords of a named
> > instance.  freetype takes that as a signal to turn the FT_Face into
> > a named instance,
> It sets the named instance index in `face->face_index', that's all.
> > and then the next test that doesn't explicitly sets a weight value
> > gets the named instance coordinate instead of the axis default.
> This part I don't understand.  Please elaborate.  What are you doing
> code-wise, what do you expect, and what does FreeType?
For each test, I create a new cairo_scaled_font instance, using the same
fontconfig pattern and different font options (this is where the test input

    pattern = FcPatternBuild (NULL,
                              FC_FAMILY, FcTypeString, (FcChar8*)"Adobe
Variable Font Prototype",
    font_face = cairo_ft_font_face_create_for_pattern (pattern);
    cairo_font_options_set_variations (options, input);
    scaled_font = cairo_scaled_font_create (font_face, &matrix, &matrix,

and then I pull out the FT_Face, and I find that I get the same one every
time, since
cairo caches them:

    ft_face = cairo_ft_scaled_font_lock_face (scaled_font);

But now, the nature of the cached object changes underneath us (sometimes
it represents a
named instance, and sometimes it doesn't). And the code applying the font
options to
changes its behavior depending on this, which leads to a mess. We need to

a) not cache a changing object
b) take the named instanceness into account for caching
c) ignore the named instanceness when applying font options

Behdad ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170922/42864f70/attachment.html>

More information about the cairo mailing list