summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--ChangeLog.pre-1-1017
-rw-r--r--ChangeLog.pre-1-217
-rw-r--r--ChangeLog.pre-1-417
-rw-r--r--ChangeLog.pre-1-617
-rw-r--r--ChangeLog.pre-1-817
-rw-r--r--pango/pangofc-fontmap.c42
-rw-r--r--pango/pangofc-fontmap.cI42
-rw-r--r--pango/pangoft2-fontmap.c6
-rw-r--r--pango/pangoxft-font.c51
-rw-r--r--pango/pangoxft-fontmap.c6
11 files changed, 215 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index 662dab15..4fb282a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Mon Aug 19 14:07:02 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangofc-fontmap.cI (pango_fc_font_map_get_patterns):
+ Delete the FC_PATTERN out of the result of FcFontRenderPrepare(),
+ because it makes identical fonts look like not identical fonts.
+
+ * pango/pangofc-fontmap.cI (uniquify_pattern): pango/pangoft-fontmap.c
+ pango/pangoxft-fontmap.c: Use a hash table to uniquify the patterns
+ we cache to save memory and speed lookups.
+
+ * pango/pangoxft-font.c (pango_xft_font_get_font): Split into
+ a public wrappper (with g_return_if_fail()) around a static
+ internal function (without check).
+
+ * pango/pangoxft-fontmap.c (_pango_xft_font_map_get_info): Remove
+ checked cast, since it was showing up high on profiles.
+
Fri Aug 16 17:49:38 2002 Owen Taylor <otaylor@redhat.com>
* pango/pangofc-fontmap.cI pango/pangoxft-fontmap.c
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 662dab15..4fb282a5 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,20 @@
+Mon Aug 19 14:07:02 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangofc-fontmap.cI (pango_fc_font_map_get_patterns):
+ Delete the FC_PATTERN out of the result of FcFontRenderPrepare(),
+ because it makes identical fonts look like not identical fonts.
+
+ * pango/pangofc-fontmap.cI (uniquify_pattern): pango/pangoft-fontmap.c
+ pango/pangoxft-fontmap.c: Use a hash table to uniquify the patterns
+ we cache to save memory and speed lookups.
+
+ * pango/pangoxft-font.c (pango_xft_font_get_font): Split into
+ a public wrappper (with g_return_if_fail()) around a static
+ internal function (without check).
+
+ * pango/pangoxft-fontmap.c (_pango_xft_font_map_get_info): Remove
+ checked cast, since it was showing up high on profiles.
+
Fri Aug 16 17:49:38 2002 Owen Taylor <otaylor@redhat.com>
* pango/pangofc-fontmap.cI pango/pangoxft-fontmap.c
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index 662dab15..4fb282a5 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,20 @@
+Mon Aug 19 14:07:02 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangofc-fontmap.cI (pango_fc_font_map_get_patterns):
+ Delete the FC_PATTERN out of the result of FcFontRenderPrepare(),
+ because it makes identical fonts look like not identical fonts.
+
+ * pango/pangofc-fontmap.cI (uniquify_pattern): pango/pangoft-fontmap.c
+ pango/pangoxft-fontmap.c: Use a hash table to uniquify the patterns
+ we cache to save memory and speed lookups.
+
+ * pango/pangoxft-font.c (pango_xft_font_get_font): Split into
+ a public wrappper (with g_return_if_fail()) around a static
+ internal function (without check).
+
+ * pango/pangoxft-fontmap.c (_pango_xft_font_map_get_info): Remove
+ checked cast, since it was showing up high on profiles.
+
Fri Aug 16 17:49:38 2002 Owen Taylor <otaylor@redhat.com>
* pango/pangofc-fontmap.cI pango/pangoxft-fontmap.c
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 662dab15..4fb282a5 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,20 @@
+Mon Aug 19 14:07:02 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangofc-fontmap.cI (pango_fc_font_map_get_patterns):
+ Delete the FC_PATTERN out of the result of FcFontRenderPrepare(),
+ because it makes identical fonts look like not identical fonts.
+
+ * pango/pangofc-fontmap.cI (uniquify_pattern): pango/pangoft-fontmap.c
+ pango/pangoxft-fontmap.c: Use a hash table to uniquify the patterns
+ we cache to save memory and speed lookups.
+
+ * pango/pangoxft-font.c (pango_xft_font_get_font): Split into
+ a public wrappper (with g_return_if_fail()) around a static
+ internal function (without check).
+
+ * pango/pangoxft-fontmap.c (_pango_xft_font_map_get_info): Remove
+ checked cast, since it was showing up high on profiles.
+
Fri Aug 16 17:49:38 2002 Owen Taylor <otaylor@redhat.com>
* pango/pangofc-fontmap.cI pango/pangoxft-fontmap.c
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 662dab15..4fb282a5 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,20 @@
+Mon Aug 19 14:07:02 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangofc-fontmap.cI (pango_fc_font_map_get_patterns):
+ Delete the FC_PATTERN out of the result of FcFontRenderPrepare(),
+ because it makes identical fonts look like not identical fonts.
+
+ * pango/pangofc-fontmap.cI (uniquify_pattern): pango/pangoft-fontmap.c
+ pango/pangoxft-fontmap.c: Use a hash table to uniquify the patterns
+ we cache to save memory and speed lookups.
+
+ * pango/pangoxft-font.c (pango_xft_font_get_font): Split into
+ a public wrappper (with g_return_if_fail()) around a static
+ internal function (without check).
+
+ * pango/pangoxft-fontmap.c (_pango_xft_font_map_get_info): Remove
+ checked cast, since it was showing up high on profiles.
+
Fri Aug 16 17:49:38 2002 Owen Taylor <otaylor@redhat.com>
* pango/pangofc-fontmap.cI pango/pangoxft-fontmap.c
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 662dab15..4fb282a5 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,20 @@
+Mon Aug 19 14:07:02 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pangofc-fontmap.cI (pango_fc_font_map_get_patterns):
+ Delete the FC_PATTERN out of the result of FcFontRenderPrepare(),
+ because it makes identical fonts look like not identical fonts.
+
+ * pango/pangofc-fontmap.cI (uniquify_pattern): pango/pangoft-fontmap.c
+ pango/pangoxft-fontmap.c: Use a hash table to uniquify the patterns
+ we cache to save memory and speed lookups.
+
+ * pango/pangoxft-font.c (pango_xft_font_get_font): Split into
+ a public wrappper (with g_return_if_fail()) around a static
+ internal function (without check).
+
+ * pango/pangoxft-fontmap.c (_pango_xft_font_map_get_info): Remove
+ checked cast, since it was showing up high on profiles.
+
Fri Aug 16 17:49:38 2002 Owen Taylor <otaylor@redhat.com>
* pango/pangofc-fontmap.cI pango/pangoxft-fontmap.c
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 13b5c1cd..86cdfbf9 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -140,9 +140,7 @@ pango_fc_font_map_init (PangoFcFontMap *fcfontmap)
{
fcfontmap->n_families = -1;
- fcfontmap->fonts = g_hash_table_new ((GHashFunc)pango_fc_pattern_hash,
- (GEqualFunc)pango_fc_pattern_equal);
-
+ fcfontmap->fonts = g_hash_table_new ((GHashFunc)g_direct_hash, NULL);
fcfontmap->coverage_hash = g_hash_table_new_full ((GHashFunc)pango_fc_coverage_key_hash,
(GEqualFunc)pango_fc_coverage_key_equal,
(GDestroyNotify)g_free,
@@ -307,6 +305,9 @@ pango_fc_font_map_finalize (GObject *object)
if (fcfontmap->fonts)
g_hash_table_destroy (fcfontmap->fonts);
+ if (fcfontmap->pattern_hash)
+ g_hash_table_destroy (fcfontmap->pattern_hash);
+
pango_fc_do_finalize (fcfontmap);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -525,6 +526,33 @@ pango_fc_font_map_new_font (PangoFontMap *fontmap,
return (PangoFont *)_pango_fc_font_new (fontmap, match);
}
+static FcPattern *
+uniquify_pattern (PangoFcFontMap *fcfontmap,
+ FcPattern *pattern)
+{
+ FcPattern *old_pattern;
+
+ if (!fcfontmap->pattern_hash)
+ fcfontmap->pattern_hash =
+ g_hash_table_new_full ((GHashFunc)pango_fc_pattern_hash,
+ (GEqualFunc)pango_fc_pattern_equal,
+ (GDestroyNotify)FcPatternDestroy, NULL);
+
+ old_pattern = g_hash_table_lookup (fcfontmap->pattern_hash, pattern);
+ if (old_pattern)
+ {
+ FcPatternDestroy (pattern);
+ FcPatternReference (old_pattern);
+ return old_pattern;
+ }
+ else
+ {
+ FcPatternReference (pattern);
+ g_hash_table_insert (fcfontmap->pattern_hash, pattern, pattern);
+ return pattern;
+ }
+}
+
static PangoFcPatternSet *
pango_fc_font_map_get_patterns (PangoFontMap *fontmap,
PangoContext *context,
@@ -566,9 +594,13 @@ pango_fc_font_map_get_patterns (PangoFontMap *fontmap,
{
font_pattern = FcFontRenderPrepare (NULL, pattern,
font_patterns->fonts[f]);
-
+ /* The FC_PATTERN element, which points back to our the original patterm
+ * defeats our hash tables.
+ */
+ FcPatternDel (font_pattern, FC_PATTERN);
+
if (font_pattern)
- patterns->patterns[patterns->n_patterns++] = font_pattern;
+ patterns->patterns[patterns->n_patterns++] = uniquify_pattern (fcfontmap, font_pattern);
}
FcPatternDestroy (pattern);
diff --git a/pango/pangofc-fontmap.cI b/pango/pangofc-fontmap.cI
index 13b5c1cd..86cdfbf9 100644
--- a/pango/pangofc-fontmap.cI
+++ b/pango/pangofc-fontmap.cI
@@ -140,9 +140,7 @@ pango_fc_font_map_init (PangoFcFontMap *fcfontmap)
{
fcfontmap->n_families = -1;
- fcfontmap->fonts = g_hash_table_new ((GHashFunc)pango_fc_pattern_hash,
- (GEqualFunc)pango_fc_pattern_equal);
-
+ fcfontmap->fonts = g_hash_table_new ((GHashFunc)g_direct_hash, NULL);
fcfontmap->coverage_hash = g_hash_table_new_full ((GHashFunc)pango_fc_coverage_key_hash,
(GEqualFunc)pango_fc_coverage_key_equal,
(GDestroyNotify)g_free,
@@ -307,6 +305,9 @@ pango_fc_font_map_finalize (GObject *object)
if (fcfontmap->fonts)
g_hash_table_destroy (fcfontmap->fonts);
+ if (fcfontmap->pattern_hash)
+ g_hash_table_destroy (fcfontmap->pattern_hash);
+
pango_fc_do_finalize (fcfontmap);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -525,6 +526,33 @@ pango_fc_font_map_new_font (PangoFontMap *fontmap,
return (PangoFont *)_pango_fc_font_new (fontmap, match);
}
+static FcPattern *
+uniquify_pattern (PangoFcFontMap *fcfontmap,
+ FcPattern *pattern)
+{
+ FcPattern *old_pattern;
+
+ if (!fcfontmap->pattern_hash)
+ fcfontmap->pattern_hash =
+ g_hash_table_new_full ((GHashFunc)pango_fc_pattern_hash,
+ (GEqualFunc)pango_fc_pattern_equal,
+ (GDestroyNotify)FcPatternDestroy, NULL);
+
+ old_pattern = g_hash_table_lookup (fcfontmap->pattern_hash, pattern);
+ if (old_pattern)
+ {
+ FcPatternDestroy (pattern);
+ FcPatternReference (old_pattern);
+ return old_pattern;
+ }
+ else
+ {
+ FcPatternReference (pattern);
+ g_hash_table_insert (fcfontmap->pattern_hash, pattern, pattern);
+ return pattern;
+ }
+}
+
static PangoFcPatternSet *
pango_fc_font_map_get_patterns (PangoFontMap *fontmap,
PangoContext *context,
@@ -566,9 +594,13 @@ pango_fc_font_map_get_patterns (PangoFontMap *fontmap,
{
font_pattern = FcFontRenderPrepare (NULL, pattern,
font_patterns->fonts[f]);
-
+ /* The FC_PATTERN element, which points back to our the original patterm
+ * defeats our hash tables.
+ */
+ FcPatternDel (font_pattern, FC_PATTERN);
+
if (font_pattern)
- patterns->patterns[patterns->n_patterns++] = font_pattern;
+ patterns->patterns[patterns->n_patterns++] = uniquify_pattern (fcfontmap, font_pattern);
}
FcPatternDestroy (pattern);
diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c
index ad15e6d1..23e7a812 100644
--- a/pango/pangoft2-fontmap.c
+++ b/pango/pangoft2-fontmap.c
@@ -54,7 +54,11 @@ struct _PangoFT2FontMap
/* We have one map from PangoFontDescription -> PangoXftPatternSet
* per language tag.
*/
- GList *fontset_hash_list;
+ GList *fontset_hash_list;
+ /* pattern_hash is used to make sure we only store one copy of
+ * each identical pattern. (Speeds up lookup).
+ */
+ GHashTable *pattern_hash;
GHashTable *coverage_hash; /* Maps font file name -> PangoCoverage */
GHashTable *fonts; /* Maps XftPattern -> PangoFT2Font */
diff --git a/pango/pangoxft-font.c b/pango/pangoxft-font.c
index bd388787..2d072757 100644
--- a/pango/pangoxft-font.c
+++ b/pango/pangoxft-font.c
@@ -69,6 +69,7 @@ static void pango_xft_font_get_glyph_extents (PangoFont
static PangoFontMetrics * pango_xft_font_get_metrics (PangoFont *font,
PangoLanguage *language);
+static XftFont *xft_font_get_font (PangoFont *font);
GType
pango_xft_font_get_type (void)
@@ -171,7 +172,7 @@ get_mini_font (PangoFont *font)
xfont->mini_font = pango_font_map_load_font (xfont->fontmap, NULL, desc);
pango_font_description_free (desc);
- mini_xft = pango_xft_font_get_font (xfont->mini_font);
+ mini_xft = xft_font_get_font (xfont->mini_font);
for (i = 0 ; i < 16 ; i++)
{
@@ -257,7 +258,7 @@ pango_xft_real_render (Display *display,
gint y)
{
PangoXftFont *xfont = PANGO_XFT_FONT (font);
- XftFont *xft_font = pango_xft_font_get_font (font);
+ XftFont *xft_font = xft_font_get_font (font);
int i;
int x_off = 0;
#define N_XFT_LOCAL 1024
@@ -301,7 +302,7 @@ pango_xft_real_render (Display *display,
int j, k;
PangoFont *mini_font = get_mini_font (font);
- XftFont *mini_xft = pango_xft_font_get_font (mini_font);
+ XftFont *mini_xft = xft_font_get_font (mini_font);
glyph &= ~PANGO_XFT_UNKNOWN_FLAG;
@@ -450,7 +451,7 @@ pango_xft_font_get_metrics (PangoFont *font,
if (xfont->fontmap)
{
- xft_font = pango_xft_font_get_font (font);
+ xft_font = xft_font_get_font (font);
_pango_xft_font_map_get_info (xfont->fontmap, &display, NULL);
context = pango_xft_get_context (display, 0);
@@ -562,7 +563,7 @@ pango_xft_font_get_glyph_extents (PangoFont *font,
PangoRectangle *logical_rect)
{
PangoXftFont *xfont = (PangoXftFont *)font;
- XftFont *xft_font = pango_xft_font_get_font (font);
+ XftFont *xft_font = xft_font_get_font (font);
XGlyphInfo extents;
Display *display;
@@ -700,24 +701,14 @@ load_fallback_font (PangoXftFont *xfont)
xfont->xft_font = xft_font;
}
-/**
- * pango_xft_font_get_font:
- * @font: a #PangoFont.
- *
- * Returns the XftFont of a font.
- *
- * Returns: the XftFont associated to @font.
- **/
-XftFont *
-pango_xft_font_get_font (PangoFont *font)
+static XftFont *
+xft_font_get_font (PangoFont *font)
{
PangoXftFont *xfont;
Display *display;
int screen;
- g_return_val_if_fail (PANGO_XFT_IS_FONT (font), NULL);
-
- xfont = PANGO_XFT_FONT (font);
+ xfont = (PangoXftFont *)font;
if (xfont->xft_font == NULL)
{
@@ -738,6 +729,22 @@ pango_xft_font_get_font (PangoFont *font)
}
/**
+ * pango_xft_font_get_font:
+ * @font: a #PangoFont.
+ *
+ * Returns the XftFont of a font.
+ *
+ * Returns: the XftFont associated to @font.
+ **/
+XftFont *
+pango_xft_font_get_font (PangoFont *font)
+{
+ g_return_val_if_fail (PANGO_XFT_IS_FONT (font), NULL);
+
+ return xft_font_get_font (font);
+}
+
+/**
* pango_xft_font_get_display:
* @font: a #PangoFont.
*
@@ -793,7 +800,7 @@ pango_xft_font_lock_face (PangoFont *font)
g_return_val_if_fail (PANGO_XFT_IS_FONT (font), NULL);
- xft_font = pango_xft_font_get_font (font);
+ xft_font = xft_font_get_font (font);
return XftLockFace (xft_font);
}
@@ -813,7 +820,7 @@ pango_xft_font_unlock_face (PangoFont *font)
g_return_if_fail (PANGO_XFT_IS_FONT (font));
- xft_font = pango_xft_font_get_font (font);
+ xft_font = xft_font_get_font (font);
XftUnlockFace (xft_font);
}
@@ -838,7 +845,7 @@ pango_xft_font_get_glyph (PangoFont *font,
g_return_val_if_fail (PANGO_XFT_IS_FONT (font), 0);
- xft_font = pango_xft_font_get_font (font);
+ xft_font = xft_font_get_font (font);
return XftCharIndex (NULL, xft_font, wc);
}
@@ -860,7 +867,7 @@ pango_xft_font_has_char (PangoFont *font,
g_return_val_if_fail (PANGO_XFT_IS_FONT (font), 0);
- xft_font = pango_xft_font_get_font (font);
+ xft_font = xft_font_get_font (font);
return XftCharExists (NULL, xft_font, wc);
}
diff --git a/pango/pangoxft-fontmap.c b/pango/pangoxft-fontmap.c
index a49cf797..16d480b5 100644
--- a/pango/pangoxft-fontmap.c
+++ b/pango/pangoxft-fontmap.c
@@ -44,6 +44,10 @@ struct _PangoXftFontMap
* per language tag.
*/
GList *fontset_hash_list;
+ /* pattern_hash is used to make sure we only store one copy of
+ * each identical pattern. (Speeds up lookup).
+ */
+ GHashTable *pattern_hash;
GHashTable *coverage_hash; /* Maps font file name/id -> PangoCoverage */
GHashTable *fonts; /* Maps XftPattern -> PangoXftFont */
@@ -309,7 +313,7 @@ _pango_xft_font_map_get_info (PangoFontMap *fontmap,
Display **display,
int *screen)
{
- PangoXftFontMap *xftfontmap = PANGO_XFT_FONT_MAP (fontmap);
+ PangoXftFontMap *xftfontmap = (PangoXftFontMap *)fontmap;
if (display)
*display = xftfontmap->display;