~ted/cairo/trunk

« back to all changes in this revision

Viewing changes to src/cairo-ft-font.c

  • Committer: Uli Schlachter
  • Date: 2018-04-21 07:37:06 UTC
  • Revision ID: git-v1:7554822dd0b52d33ec7898e81b59e97164b00142
Fix assertion failure in the freetype backend

Fonts are kept in a hash table, so when creating a new font, the code
first checks the hash table for an already-existing entry and only then
is a new instance really created. There is an assert that checks that
the key used for the hash table lookup is the same as the instance that
is created later has, because otherwise the hash table was checked
incorrectly.

This assert failed in some conditions.

Fix this by fixing some places that initialised ft hash keys in a wrong
way.

Patch by Behdad Esfahbod and submitted via bugzilla.

Source: https://bugs.freedesktop.org/show_bug.cgi?id=105746#c4
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=105746
Signed-off-by: Uli Schlachter <psychon@znc.in>

Show diffs side-by-side

added added

removed removed

Lines of Context:
445
445
 
446
446
    if (from_face) {
447
447
        unscaled->from_face = TRUE;
448
 
        _cairo_ft_unscaled_font_init_key (unscaled, TRUE, NULL, face->face_index, face);
 
448
        _cairo_ft_unscaled_font_init_key (unscaled, TRUE, NULL, id, face);
449
449
 
450
450
 
451
451
        unscaled->have_color = FT_HAS_COLOR (face) != 0;
640
640
_cairo_ft_unscaled_font_create_from_face (FT_Face face,
641
641
                                          cairo_ft_unscaled_font_t **out)
642
642
{
643
 
    return _cairo_ft_unscaled_font_create_internal (TRUE, NULL, 0, face, out);
 
643
    return _cairo_ft_unscaled_font_create_internal (TRUE, NULL, face->face_index, face, out);
644
644
}
645
645
 
646
646
static cairo_bool_t