summaryrefslogtreecommitdiff
path: root/pango/pangowin32-fontmap.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2005-09-14 04:05:51 +0000
committerTor Lillqvist <tml@src.gnome.org>2005-09-14 04:05:51 +0000
commit76382d08e3a42c8dd425e308d73a6a4f0f49c9d9 (patch)
tree7f2a14733562614b2960aaca88ac9068b4733e13 /pango/pangowin32-fontmap.c
parent74f0a825227c1fe752aa3bb0154f4837370c158f (diff)
downloadpango-76382d08e3a42c8dd425e308d73a6a4f0f49c9d9.tar.gz
Have a list of metrics by language instead of just one metrics.
2005-09-14 Tor Lillqvist <tml@novell.com> * pango/pangocairo-win32font.c (struct _PangoCairoWin32Font): Have a list of metrics by language instead of just one metrics. (pango_cairo_win32_font_get_scaled_font): Use the name cwfont instead of cffont. (free_metrics_info, pango_cairo_win32_font_finalize): Free the metrics by language list. (create_metrics_for_context): New helper function. Approximate the character and digit widths correctly. (#314114) (pango_cairo_win32_font_get_metrics): Use the list of metrics by language. Call create_metrics_for_context() to measure metrics. (_pango_cairo_win32_font_new): Keep the PangoWin32Font objects in the PangoWin32Face::cached_fonts, like the pangowin32 backend does. PangoWin32Face::cached_fonts isn't really a proper cache. It's a list with unbound length, one PangoWin32Font per size. Once there is cacheing in cairo this can be dropped presumably? What does the pangofc backend do? There are too many levels of cacheing going on: we have the stuff in pangowin32-fontcache.c (unused now with cairo), the PangoWin32FontMap::freed_fonts cache, and the PangoWin32::cached_fonts list. * pango/pangowin32-fontmap.c (pango_win32_fontmap_cache_remove, pango_win32_fontmap_cache_clear): Use GQueue API instead of manipulating pointers manually. * pango/pangowin32-private.h * pango/pangowin32.c: Move PangoWin32MetricsInfo to the private header file, as also pangocairo-win32font.c uses it.
Diffstat (limited to 'pango/pangowin32-fontmap.c')
-rw-r--r--pango/pangowin32-fontmap.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 37cb279c..171883fa 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -88,6 +88,8 @@ static void pango_win32_fontmap_cache_clear (PangoWin32FontMap
static void pango_win32_insert_font (PangoWin32FontMap *fontmap,
LOGFONT *lfp);
+static PangoWin32FontMap *default_fontmap = NULL;
+
G_DEFINE_TYPE (PangoWin32FontMap, pango_win32_font_map, PANGO_TYPE_FONT_MAP)
/* A hash function for LOGFONTs that takes into consideration only
@@ -177,7 +179,6 @@ pango_win32_font_map_init (PangoWin32FontMap *win32fontmap)
(LPARAM)win32fontmap, 0);
win32fontmap->resolution = (PANGO_SCALE / (double) GetDeviceCaps (pango_win32_hdc, LOGPIXELSY)) * 72.0;
-
}
static void
@@ -199,8 +200,6 @@ pango_win32_font_map_class_init (PangoWin32FontMapClass *class)
pango_module_register (&_pango_included_win32_modules[i]);
}
-static PangoWin32FontMap *default_fontmap = NULL;
-
/**
* pango_win32_font_map_for_display:
*
@@ -1031,17 +1030,10 @@ pango_win32_fontmap_cache_remove (PangoFontMap *fontmap,
PangoWin32Font *win32font)
{
PangoWin32FontMap *win32fontmap = PANGO_WIN32_FONT_MAP (fontmap);
+ GList *link = g_queue_find (win32fontmap->freed_fonts, win32font);
- GList *link = g_list_find (win32fontmap->freed_fonts->head, win32font);
- if (link == win32fontmap->freed_fonts->tail)
- {
- win32fontmap->freed_fonts->tail = win32fontmap->freed_fonts->tail->prev;
- if (win32fontmap->freed_fonts->tail)
- win32fontmap->freed_fonts->tail->next = NULL;
- }
-
- win32fontmap->freed_fonts->head = g_list_delete_link (win32fontmap->freed_fonts->head, link);
- win32fontmap->freed_fonts->length--;
+ if (link)
+ g_queue_delete_link (win32fontmap->freed_fonts, link);
win32font->in_cache = FALSE;
g_object_unref (win32font);
@@ -1051,8 +1043,6 @@ static void
pango_win32_fontmap_cache_clear (PangoWin32FontMap *win32fontmap)
{
g_list_foreach (win32fontmap->freed_fonts->head, (GFunc)g_object_unref, NULL);
- g_list_free (win32fontmap->freed_fonts->head);
- win32fontmap->freed_fonts->head = NULL;
- win32fontmap->freed_fonts->tail = NULL;
- win32fontmap->freed_fonts->length = 0;
+ g_queue_free (win32fontmap->freed_fonts);
+ win32fontmap->freed_fonts = g_queue_new ();
}