summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2005-11-22 21:38:41 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2005-11-22 21:38:41 +0000
commit0f91602a3719ad4344712910a0cd825c58497a2b (patch)
treef7875f364b22bd12389e5cb363910e12ebd81584
parent550026ab7e2d2cfeeacd1cd68ecb1ac31a4733e4 (diff)
downloadpango-0f91602a3719ad4344712910a0cd825c58497a2b.tar.gz
Fixes #322174:
2005-11-22 Federico Mena Quintero <federico@ximian.com> Fixes #322174: * pango/pangofc-font.h (struct _PangoFcFont): Replace the "gpointer context_key" field with "gpointer priv". This way we can access the private data quickly, instead of using g_type_instance_get_private(). * pango/pangofc-private.h: Added prototypes for _pango_fc_font_{get,set}_context_key(). * pango/pangofc-font.c (struct _PangoFcFontPrivate): Moved the "context_key" field to here. (PANGO_FC_FONT_GET_PRIVATE): Use the "priv" field instead of GType private data. (pango_fc_font_class_init): Don't register GType private data. (pango_fc_font_init): Initialize the private data here. (pango_fc_font_finalize): Free the private data. (_pango_fc_font_get_context_key): Implement. (_pango_fc_font_set_context_key): Implement. (pango_fc_font_get_glyph): Remove the g_return_val_if_fail(); it was appearing quite high in the profile. * pango/pangofc-fontmap.c (pango_fc_font_map_add): Call _pango_fc_font_set_context_key() instead of setting the fcfont->context_key directly. (_pango_fc_font_map_remove): Likewise; also use _pango_fc_font_get_context_key() instead of accessing the field directly.
-rw-r--r--ChangeLog31
-rw-r--r--pango/pangofc-font.c31
-rw-r--r--pango/pangofc-font.h2
-rw-r--r--pango/pangofc-fontmap.c6
-rw-r--r--pango/pangofc-private.h4
5 files changed, 64 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index de8eb7f9..cc760176 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2005-11-22 Federico Mena Quintero <federico@ximian.com>
+
+ Fixes #322174:
+
+ * pango/pangofc-font.h (struct _PangoFcFont): Replace the
+ "gpointer context_key" field with "gpointer priv". This way we
+ can access the private data quickly, instead of using
+ g_type_instance_get_private().
+
+ * pango/pangofc-private.h: Added prototypes for
+ _pango_fc_font_{get,set}_context_key().
+
+ * pango/pangofc-font.c (struct _PangoFcFontPrivate): Moved the
+ "context_key" field to here.
+ (PANGO_FC_FONT_GET_PRIVATE): Use the "priv" field instead of GType
+ private data.
+ (pango_fc_font_class_init): Don't register GType private data.
+ (pango_fc_font_init): Initialize the private data here.
+ (pango_fc_font_finalize): Free the private data.
+ (_pango_fc_font_get_context_key): Implement.
+ (_pango_fc_font_set_context_key): Implement.
+ (pango_fc_font_get_glyph): Remove the g_return_val_if_fail(); it
+ was appearing quite high in the profile.
+
+ * pango/pangofc-fontmap.c (pango_fc_font_map_add): Call
+ _pango_fc_font_set_context_key() instead of setting the
+ fcfont->context_key directly.
+ (_pango_fc_font_map_remove): Likewise; also use
+ _pango_fc_font_get_context_key() instead of accessing the field
+ directly.
+
2005-11-22 Behdad Esfahbod <behdad@gnome.org>
* pango/pangoxft-font.c (_pango_xft_font_get_mini_font): Load a font
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 882e77e4..fe01a5b7 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -37,11 +37,12 @@ enum {
typedef struct _PangoFcFontPrivate PangoFcFontPrivate;
-#define PANGO_FC_FONT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PANGO_TYPE_FC_FONT, PangoFcFontPrivate))
+#define PANGO_FC_FONT_GET_PRIVATE(obj) ((PangoFcFontPrivate *) ((PangoFcFont *) obj)->priv)
struct _PangoFcFontPrivate
{
PangoFcDecoder *decoder;
+ gpointer context_key;
};
static gboolean pango_fc_font_real_has_char (PangoFcFont *font,
@@ -95,13 +96,15 @@ pango_fc_font_class_init (PangoFcFontClass *class)
"Pattern",
"The fontconfig pattern for this font",
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-
- g_type_class_add_private (object_class, sizeof (PangoFcFontPrivate));
}
static void
pango_fc_font_init (PangoFcFont *fcfont)
{
+ PangoFcFontPrivate *priv;
+
+ priv = g_new0 (PangoFcFontPrivate, 1);
+ fcfont->priv = priv;
}
static void
@@ -129,6 +132,8 @@ pango_fc_font_finalize (GObject *object)
if (priv->decoder)
_pango_fc_font_set_decoder (fcfont, NULL);
+ g_free (priv);
+
G_OBJECT_CLASS (pango_fc_font_parent_class)->finalize (object);
}
@@ -606,11 +611,8 @@ pango_fc_font_get_glyph (PangoFcFont *font,
{
PangoFcFontPrivate *priv;
- g_return_val_if_fail (PANGO_IS_FC_FONT (font), 0);
-
priv = PANGO_FC_FONT_GET_PRIVATE (font);
-
/* Replace NBSP with a normal space; it should be invariant that
* they shape the same other than breaking properties.
*/
@@ -746,6 +748,23 @@ _pango_fc_font_set_decoder (PangoFcFont *font,
g_object_ref (priv->decoder);
}
+gpointer
+_pango_fc_font_get_context_key (PangoFcFont *fcfont)
+{
+ PangoFcFontPrivate *priv = PANGO_FC_FONT_GET_PRIVATE (fcfont);
+
+ return priv->context_key;
+}
+
+void
+_pango_fc_font_set_context_key (PangoFcFont *fcfont,
+ gpointer context_key)
+{
+ PangoFcFontPrivate *priv = PANGO_FC_FONT_GET_PRIVATE (fcfont);
+
+ priv->context_key = context_key;
+}
+
static FT_Glyph_Metrics *
get_per_char (FT_Face face,
FT_Int32 load_flags,
diff --git a/pango/pangofc-font.h b/pango/pangofc-font.h
index 404f6ad3..afc5e96b 100644
--- a/pango/pangofc-font.h
+++ b/pango/pangofc-font.h
@@ -71,7 +71,7 @@ struct _PangoFcFont
FcPattern *font_pattern; /* fully resolved pattern */
PangoFontMap *fontmap; /* associated map */
- gpointer context_key; /* used internally */
+ gpointer priv; /* used internally */
PangoMatrix matrix; /* used internally */
PangoFontDescription *description;
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 1b8f74e3..05362e27 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -553,7 +553,7 @@ pango_fc_font_map_add (PangoFcFontMap *fcfontmap,
key.pattern = fcfont->font_pattern;
key_copy = font_hash_key_copy (&key);
- fcfont->context_key = key_copy->context_key;
+ _pango_fc_font_set_context_key (fcfont, key_copy->context_key);
fcfont->matrix = key.matrix;
g_hash_table_insert (priv->font_hash, key_copy, fcfont);
@@ -584,11 +584,11 @@ _pango_fc_font_map_remove (PangoFcFontMap *fcfontmap,
key.fontmap = fcfontmap;
key.matrix = fcfont->matrix;
key.pattern = fcfont->font_pattern;
- key.context_key = fcfont->context_key;
+ key.context_key = _pango_fc_font_get_context_key (fcfont);
g_hash_table_remove (priv->font_hash, &key);
fcfont->fontmap = NULL;
- fcfont->context_key = NULL;
+ _pango_fc_font_set_context_key (fcfont, NULL);
g_object_unref (fcfontmap);
}
diff --git a/pango/pangofc-private.h b/pango/pangofc-private.h
index c0be7648..a8f3c23c 100644
--- a/pango/pangofc-private.h
+++ b/pango/pangofc-private.h
@@ -54,6 +54,10 @@ PangoFcDecoder *_pango_fc_font_get_decoder (PangoFcFont *font);
void _pango_fc_font_set_decoder (PangoFcFont *font,
PangoFcDecoder *decoder);
+gpointer _pango_fc_font_get_context_key (PangoFcFont *font);
+void _pango_fc_font_set_context_key (PangoFcFont *font,
+ gpointer context_key);
+
void pango_fc_font_get_raw_extents (PangoFcFont *font,
FT_Int32 load_flags,
PangoGlyph glyph,