diff options
author | Owen Taylor <otaylor@redhat.com> | 2000-06-05 19:36:33 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2000-06-05 19:36:33 +0000 |
commit | 7b428440247958a9c52fe29c4aeeecfd6f43f39b (patch) | |
tree | 586a5c61355a622caab97e583e703e2390dbbf8f /pango/pangox.c | |
parent | 40638f2de292719e3615e5ae77ff5f97d57300bc (diff) | |
download | pango-7b428440247958a9c52fe29c4aeeecfd6f43f39b.tar.gz |
Fix problem with unloading fonts.
Mon Jun 5 15:35:03 2000 Owen Taylor <otaylor@redhat.com>
* pango/pangox-fontcache.c (pango_x_font_cache_unload): Fix
problem with unloading fonts.
* pango/pangox-fontmap.c pango/pangox-private.h pangox/pangox.c:
Add a simple PangoXFont; get rid of the eternal caching of
all fonts.
Diffstat (limited to 'pango/pangox.c')
-rw-r--r-- | pango/pangox.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/pango/pangox.c b/pango/pangox.c index f28a0381..9110ace1 100644 --- a/pango/pangox.c +++ b/pango/pangox.c @@ -69,8 +69,11 @@ struct _PangoXFontClass PangoFontClass parent_class; }; +static PangoFontClass *parent_class; /* Parent class structure for PangoXFont */ + static void pango_x_font_class_init (PangoXFontClass *class); static void pango_x_font_init (PangoXFont *xfont); +static void pango_x_font_shutdown (GObject *object); static void pango_x_font_finalize (GObject *object); static PangoFontDescription *pango_x_font_describe (PangoFont *font); @@ -249,8 +252,12 @@ pango_x_font_class_init (PangoXFontClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); PangoFontClass *font_class = PANGO_FONT_CLASS (class); + + parent_class = g_type_class_peek_parent (class); object_class->finalize = pango_x_font_finalize; + object_class->shutdown = pango_x_font_shutdown; + font_class->describe = pango_x_font_describe; font_class->get_coverage = pango_x_font_get_coverage; font_class->find_shaper = pango_x_font_find_shaper; @@ -901,6 +908,22 @@ pango_x_font_subfont_xlfd (PangoFont *font, } static void +pango_x_font_shutdown (GObject *object) +{ + PangoXFont *xfont = PANGO_X_FONT (object); + + /* If the font is not already in the freed-fonts cache, add it, + * if it is already there, do nothing and the font will be + * freed. + */ + if (!xfont->in_cache) + pango_x_fontmap_cache_add (xfont->fontmap, xfont); + + G_OBJECT_CLASS (parent_class)->shutdown (object); +} + + +static void subfonts_foreach (gpointer key, gpointer value, gpointer data) { g_free (key); @@ -911,6 +934,9 @@ static void pango_x_font_finalize (GObject *object) { PangoXFont *xfont = (PangoXFont *)object; + PangoFontMap *fontmap = pango_x_font_map_for_display (xfont->display); + PangoXFontCache *cache = pango_x_font_map_get_font_cache (fontmap); + int i; for (i=0; i<xfont->n_subfonts; i++) @@ -918,8 +944,9 @@ pango_x_font_finalize (GObject *object) PangoXSubfontInfo *info = xfont->subfonts[i]; g_free (info->xlfd); + if (info->font_struct) - XFreeFont (xfont->display, info->font_struct); + pango_x_font_cache_unload (cache, info->font_struct); g_free (info); } @@ -936,6 +963,8 @@ pango_x_font_finalize (GObject *object) pango_x_font_entry_remove (xfont->entry, (PangoFont *)xfont); g_strfreev (xfont->fonts); + + G_OBJECT_CLASS (parent_class)->finalize (object); } static PangoFontDescription * |