[pango: 5/7] pangowin32-fontmap: load windows fallbacks and aliases in class init
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango: 5/7] pangowin32-fontmap: load windows fallbacks and aliases in class init
- Date: Mon, 8 Jun 2020 13:18:12 +0000 (UTC)
commit 475e2d7cc399241441d06a36542bdcb577276ea3
Author: Aaron Boxer <aaron boxer collabora com>
Date: Thu May 28 15:56:40 2020 -0600
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.
pango/pangowin32-fontmap.c | 27 ++++++++++-----------------
pango/pangowin32-private.h | 2 +-
2 files changed, 11 insertions(+), 18 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 ();
}
diff --git a/pango/pangowin32-private.h b/pango/pangowin32-private.h
index f5620b87..1c9c1c09 100644
--- a/pango/pangowin32-private.h
+++ b/pango/pangowin32-private.h
@@ -113,7 +113,7 @@ struct _PangoWin32FontMapClass
PangoContext *context,
PangoWin32Face *face,
const PangoFontDescription *desc);
-
+ GHashTable *aliases;
};
struct _PangoWin32Font
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]