diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-08-20 21:23:35 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-08-20 21:23:35 +0000 |
commit | c87e246944bfc8bcba532c3f6cdaced945e300a9 (patch) | |
tree | 356919169c8146e4a37dca2ef7ce7a4ff73ecf53 /pango | |
parent | 265c4e50d29d58c0e07c0db26805220c7b878f5c (diff) | |
parent | 81904ad171bc58feefa1718f7f8895cc24021b1e (diff) | |
download | pango-c87e246944bfc8bcba532c3f6cdaced945e300a9.tar.gz |
Merge branch 'issue-482' into 'master'
Fixes pango_win32_font_map_load_font when font contains fallback families
Closes #482
See merge request GNOME/pango!217
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pangowin32-fontmap.c | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c index b43685c7..8d7e0c06 100644 --- a/pango/pangowin32-fontmap.c +++ b/pango/pangowin32-fontmap.c @@ -1016,44 +1016,49 @@ pango_win32_font_map_load_font (PangoFontMap *fontmap, const PangoFontDescription *description) { PangoWin32FontMap *win32fontmap = (PangoWin32FontMap *)fontmap; - PangoWin32Family *win32family; + PangoWin32Face *best_match = NULL; PangoFont *result = NULL; GSList *tmp_list; const char *family; + char **families; + int i; g_return_val_if_fail (description != NULL, NULL); family = pango_font_description_get_family (description); - family = family ? family : ""; - PING (("name=%s", family)); + families = g_strsplit (family ? family : "", ",", -1); - win32family = g_hash_table_lookup (win32fontmap->families, family); - if (win32family) + for (i = 0; families[i] && !best_match; ++i) { - PangoWin32Face *best_match = NULL; - - PING (("got win32family")); - tmp_list = win32family->faces; - while (tmp_list) + PING (("name=%s", families[i])); + PangoWin32Family *win32family = g_hash_table_lookup (win32fontmap->families, families[i]); + if (win32family) { - PangoWin32Face *face = tmp_list->data; + PING (("got win32family")); + tmp_list = win32family->faces; + while (tmp_list) + { + PangoWin32Face *face = tmp_list->data; - if (pango_font_description_better_match (description, - best_match ? best_match->description : NULL, - face->description)) - best_match = face; + if (pango_font_description_better_match (description, + best_match ? best_match->description : NULL, + face->description)) + best_match = face; - tmp_list = tmp_list->next; + tmp_list = tmp_list->next; + } } + } + + g_strfreev (families); - if (best_match) - result = PANGO_WIN32_FONT_MAP_GET_CLASS (win32fontmap)->find_font (win32fontmap, context, - best_match, - description); + if (best_match) + result = PANGO_WIN32_FONT_MAP_GET_CLASS (win32fontmap)->find_font (win32fontmap, context, + best_match, + description); /* TODO: Handle the case that result == NULL. */ - else - PING (("no best match!")); - } + else + PING (("no best match!")); return result; } |