summaryrefslogtreecommitdiff
path: root/pango/pangoxft-fontmap.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-08-06 03:43:16 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-08-06 03:43:16 +0000
commit9629e9e1ffa2f76989c877a2c2e4c0324716100d (patch)
treefebf99a1e4bc4601aed073b4ac5d41fe02036c46 /pango/pangoxft-fontmap.c
parent4b1d623ea4e751b2038588c894a19c0589840f4b (diff)
downloadpango-9629e9e1ffa2f76989c877a2c2e4c0324716100d.tar.gz
Patch from Keith Packard:
Mon Aug 5 23:12:13 2002 Owen Taylor <otaylor@redhat.com> Patch from Keith Packard: * pango/pangoxft-private.h (struct _PangoXftFont): Add some comments. * pango/pangoxft-private.h pango/pangoxft-font.c pango/pangoxft-fontmap.c: Identify coverage by a pair of filename and index within the filename instead of just a filename, to handle TrueType Collection (TTC) fonts. * pango/pangoxft-fontmap.c (pango_xft_make_pattern): Remove some leftover comments.
Diffstat (limited to 'pango/pangoxft-fontmap.c')
-rw-r--r--pango/pangoxft-fontmap.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/pango/pangoxft-fontmap.c b/pango/pangoxft-fontmap.c
index eee35a9b..32926f0a 100644
--- a/pango/pangoxft-fontmap.c
+++ b/pango/pangoxft-fontmap.c
@@ -43,7 +43,7 @@ struct _PangoXftFontMap
PangoFontMap parent_instance;
GHashTable *fontset_hash; /* Maps PangoFontDescription -> PangoXftPatternSet */
- GHashTable *coverage_hash; /* Maps font file name -> PangoCoverage */
+ GHashTable *coverage_hash; /* Maps font file name/id -> PangoCoverage */
GHashTable *fonts; /* Maps XftPattern -> PangoXftFont */
GQueue *freed_fonts; /* Fonts in fonts that has been freed */
@@ -203,6 +203,20 @@ pango_xft_pattern_equal (FcPattern *pattern1,
return FcPatternEqual (pattern1, pattern2);
}
+static guint
+pango_xft_coverage_key_hash (PangoXftCoverageKey *key)
+{
+ return g_str_hash (key->filename) ^ key->id;
+}
+
+static gboolean
+pango_xft_coverage_key_equal (PangoXftCoverageKey *key1,
+ PangoXftCoverageKey *key2)
+{
+ return key1->id == key2->id && strcmp (key1->filename, key2->filename) == 0;
+}
+
+
static void
pango_xft_init_fontset_hash (PangoXftFontMap *xfontmap)
{
@@ -282,8 +296,9 @@ pango_xft_get_font_map (Display *display,
xfontmap->fonts = g_hash_table_new ((GHashFunc)pango_xft_pattern_hash,
(GEqualFunc)pango_xft_pattern_equal);
- pango_xft_init_fontset_hash (xfontmap);
- xfontmap->coverage_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+
+ xfontmap->coverage_hash = g_hash_table_new_full ((GHashFunc)pango_xft_coverage_key_hash,
+ (GEqualFunc)pango_xft_coverage_key_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)pango_coverage_unref);
xfontmap->freed_fonts = g_queue_new ();
@@ -592,9 +607,6 @@ pango_xft_make_pattern (const PangoFontDescription *description)
slant = pango_xft_convert_slant (pango_style);
weight = pango_xft_convert_weight (pango_font_description_get_weight (description));
- /* To fool Xft into not munging glyph indices, we open it as glyphs-fontspecific
- * then set the encoding ourself
- */
pattern = FcPatternBuild (0,
FC_WEIGHT, FcTypeInteger, weight,
FC_SLANT, FcTypeInteger, slant,
@@ -820,23 +832,29 @@ pango_xft_font_map_cache_clear (PangoXftFontMap *xfontmap)
}
void
-_pango_xft_font_map_set_coverage (PangoFontMap *fontmap,
- const char *name,
- PangoCoverage *coverage)
+_pango_xft_font_map_set_coverage (PangoFontMap *fontmap,
+ const PangoXftCoverageKey *key,
+ PangoCoverage *coverage)
{
- PangoXftFontMap *xfontmap = PANGO_XFT_FONT_MAP (fontmap);
+ PangoXftFontMap *xfontmap = PANGO_XFT_FONT_MAP (fontmap);
+ PangoXftCoverageKey *key_dup;
- g_hash_table_insert (xfontmap->coverage_hash, g_strdup (name),
- pango_coverage_ref (coverage));
+ key_dup = g_malloc (sizeof (PangoXftCoverageKey) + strlen (key->filename) + 1);
+ key_dup->id = key->id;
+ key_dup->filename = (char *) (key_dup + 1);
+ strcpy (key_dup->filename, key->filename);
+
+ g_hash_table_insert (xfontmap->coverage_hash,
+ key_dup, pango_coverage_ref (coverage));
}
PangoCoverage *
-_pango_xft_font_map_get_coverage (PangoFontMap *fontmap,
- const char *name)
+_pango_xft_font_map_get_coverage (PangoFontMap *fontmap,
+ const PangoXftCoverageKey *key)
{
PangoXftFontMap *xfontmap = PANGO_XFT_FONT_MAP (fontmap);
- return g_hash_table_lookup (xfontmap->coverage_hash, name);
+ return g_hash_table_lookup (xfontmap->coverage_hash, key);
}
void