diff options
author | Aaron Boxer <aaron.boxer@collabora.com> | 2020-05-28 15:56:40 -0600 |
---|---|---|
committer | Aaron Boxer <boxerab@gmail.com> | 2020-06-08 08:31:54 -0400 |
commit | 475e2d7cc399241441d06a36542bdcb577276ea3 (patch) | |
tree | 48cb39507fe565a947ee1557570ff93d87e7148c /pango/pangowin32-fontmap.c | |
parent | fb2d89845196ac02e2db0dc9ccf40bc9338fea7e (diff) | |
download | pango-475e2d7cc399241441d06a36542bdcb577276ea3.tar.gz |
pangowin32-fontmap: load windows fallbacks and aliases in class init
Currently, because of the g_once_init*, only the very first font map
that is created will get the correct list of aliases. With these changes
the fontmap class loads the aliases once, and this hash table is used
by all fontmap objects.
Diffstat (limited to 'pango/pangowin32-fontmap.c')
-rw-r--r-- | pango/pangowin32-fontmap.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c index ff7a6e94..09de5fa0 100644 --- a/pango/pangowin32-fontmap.c +++ b/pango/pangowin32-fontmap.c @@ -611,19 +611,6 @@ read_windows_fallbacks (GHashTable *ht_aliases) #endif - -static gboolean -load_aliases (GHashTable *ht_aliases) -{ - -#ifdef HAVE_CAIRO_WIN32 - read_windows_fallbacks (ht_aliases); - read_builtin_aliases (ht_aliases); -#endif - - return TRUE; -} - static void lookup_aliases (GHashTable *aliases_ht, const char *fontname, @@ -634,9 +621,6 @@ lookup_aliases (GHashTable *aliases_ht, struct PangoAlias *alias; static gsize aliases_inited = 0; - if (g_once_init_enter (&aliases_inited)) - g_once_init_leave (&aliases_inited, load_aliases (aliases_ht)); - alias_key.alias = g_ascii_strdown (fontname, -1); alias = g_hash_table_lookup (aliases_ht, &alias_key); g_free (alias_key.alias); @@ -775,8 +759,9 @@ pango_win32_font_map_fontset_add_fonts (PangoFontMap *fontmap, int n_aliases; int j; PangoWin32FontMap *win32fontmap = PANGO_WIN32_FONT_MAP (fontmap); + PangoWin32FontMapClass *class = (PangoWin32FontMapClass*)G_OBJECT_GET_CLASS(win32fontmap); - lookup_aliases (win32fontmap->aliases, family, &aliases, &n_aliases); + lookup_aliases (class->aliases, family, &aliases, &n_aliases); if (n_aliases) { for (j = 0; j < n_aliases; j++) @@ -819,6 +804,14 @@ _pango_win32_font_map_class_init (PangoWin32FontMapClass *class) fontmap_class->list_families = pango_win32_font_map_list_families; fontmap_class->shape_engine_type = PANGO_RENDER_TYPE_WIN32; fontmap_class->get_face = pango_win32_font_map_get_face; + class->aliases = g_hash_table_new_full ((GHashFunc)alias_hash, + (GEqualFunc)alias_equal, + (GDestroyNotify)alias_free, + NULL); +#ifdef HAVE_CAIRO_WIN32 + read_windows_fallbacks (class->aliases); + read_builtin_aliases (class->aliases); +#endif _pango_win32_get_display_dc (); } |