summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-03-10 14:00:09 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-03-13 18:03:50 -0400
commitc84d4e6e068d802cd0fe2b23bee4c611ae9ef89f (patch)
tree3c0cf5d18739b31c2378075496ed5dce63158b73 /pango
parent9305b9a9995e84ace3818a90346820ef8c47a3ce (diff)
downloadpango-c84d4e6e068d802cd0fe2b23bee4c611ae9ef89f.tar.gz
[pangofc] Reuse filename from pattern in coverage key
Diffstat (limited to 'pango')
-rw-r--r--pango/pangofc-fontmap.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index c3786e1d..1cd934a9 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -80,8 +80,12 @@ struct _PangoFcFontMapPrivate
struct _PangoFcCoverageKey
{
+ /* Key */
char *filename;
int id; /* needed to handle TTC files with multiple faces */
+
+ /* Data */
+ FcPattern *pattern; /* Referenced pattern that owns filename */
};
struct _PangoFcFace
@@ -191,9 +195,16 @@ pango_fc_coverage_key_hash (PangoFcCoverageKey *key)
static gboolean
pango_fc_coverage_key_equal (PangoFcCoverageKey *key1,
- PangoFcCoverageKey *key2)
+ PangoFcCoverageKey *key2)
{
- return key1->id == key2->id && strcmp (key1->filename, key2->filename) == 0;
+ return key1->id == key2->id && (key1 == key2 || 0 == strcmp (key1->filename, key2->filename));
+}
+
+static void
+pango_fc_coverage_key_free (PangoFcCoverageKey *key)
+{
+ FcPatternDestroy (key->pattern);
+ g_slice_free (PangoFcCoverageKey, key);
}
/* Fowler / Noll / Vo (FNV) Hash (http://www.isthe.com/chongo/tech/comp/fnv/)
@@ -983,7 +994,7 @@ pango_fc_font_map_init (PangoFcFontMap *fcfontmap)
priv->coverage_hash = g_hash_table_new_full ((GHashFunc)pango_fc_coverage_key_hash,
(GEqualFunc)pango_fc_coverage_key_equal,
- (GDestroyNotify)g_free,
+ (GDestroyNotify)pango_fc_coverage_key_free,
(GDestroyNotify)pango_coverage_unref);
priv->dpi = -1;
}
@@ -1061,7 +1072,7 @@ pango_fc_font_map_add_decoder_find_func (PangoFcFontMap *fcfontmap,
PangoFcFontMapPrivate *priv;
PangoFcFindFuncInfo *info;
- g_return_val_if_fail (PANGO_IS_FC_FONT_MAP (fcfontmap), NULL);
+ g_return_if_fail (PANGO_IS_FC_FONT_MAP (fcfontmap));
priv = fcfontmap->priv;
@@ -1707,10 +1718,9 @@ pango_fc_font_map_set_coverage (PangoFcFontMap *fcfontmap,
PangoFcFontMapPrivate *priv = fcfontmap->priv;
PangoFcCoverageKey *key_dup;
- key_dup = g_malloc (sizeof (PangoFcCoverageKey) + strlen (key->filename) + 1);
- key_dup->id = key->id;
- key_dup->filename = (char *) (key_dup + 1);
- strcpy (key_dup->filename, key->filename);
+ key_dup = g_slice_new (PangoFcCoverageKey);
+ *key_dup = *key;
+ FcPatternReference (key_dup->pattern);
g_hash_table_insert (priv->coverage_hash,
key_dup, pango_coverage_ref (coverage));
@@ -1725,6 +1735,8 @@ _pango_fc_font_map_get_coverage (PangoFcFontMap *fcfontmap,
PangoCoverage *coverage;
FcCharSet *charset;
+ key.pattern = fcfont->font_pattern;
+
/*
* Assume that coverage information is identified by
* a filename/index pair; there shouldn't be any reason