[gnumeric] GUI: create only one pango context.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: create only one pango context.
- Date: Mon, 3 May 2010 18:44:28 +0000 (UTC)
commit f231807bd65197e80f725d277d517c4c86ae73bc
Author: Morten Welinder <terra gnome org>
Date: Mon May 3 14:43:59 2010 -0400
GUI: create only one pango context.
ChangeLog | 4 ++++
src/style.c | 35 +++++++++++++++++++++--------------
2 files changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9ce6be5..984b810 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2010-05-03 Morten Welinder <terra gnome org>
+ * src/style.c (gnm_pango_context_get): Cache the context. (Some
+ pango versions are indeterministic in font selection.)
+ (gnm_font_shutdown): Release the context.
+
* src/sheet.h (struct _Sheet): Drop context field.
* src/rendered-value.c (gnm_rendered_value_new): Add a
diff --git a/src/style.c b/src/style.c
index 34ccdc7..68e56de 100644
--- a/src/style.c
+++ b/src/style.c
@@ -283,6 +283,7 @@ gnm_font_hash (gconstpointer v)
}
static PangoFontMap *fontmap;
+static PangoContext *context;
/**
* gnm_pango_context_get :
@@ -292,25 +293,26 @@ static PangoFontMap *fontmap;
PangoContext *
gnm_pango_context_get (void)
{
- PangoContext *context;
- GdkScreen *screen = gdk_screen_get_default ();
-
- if (screen != NULL) {
- context = gdk_pango_context_get_for_screen (screen);
- } else {
- if (!fontmap)
- fontmap = pango_cairo_font_map_new ();
- pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), 96);
+ if (!context) {
+ GdkScreen *screen = gdk_screen_get_default ();
+
+ if (screen != NULL) {
+ context = gdk_pango_context_get_for_screen (screen);
+ } else {
+ if (!fontmap)
+ fontmap = pango_cairo_font_map_new ();
+ pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), 96);
#ifdef HAVE_PANGO_FONT_MAP_CREATE_CONTEXT
- context = pango_font_map_create_context (PANGO_FONT_MAP (fontmap));
+ context = pango_font_map_create_context (PANGO_FONT_MAP (fontmap));
#else /* deprecated in 1.22.0 */
- context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
+ context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
#endif
+ }
+ pango_context_set_language (context, gtk_get_default_language ());
+ pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);
}
- pango_context_set_language (context, gtk_get_default_language ());
- pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);
- return context;
+ return g_object_ref (context);
}
void
@@ -410,6 +412,11 @@ gnm_font_shutdown (void)
g_hash_table_destroy (style_font_negative_hash);
style_font_negative_hash = NULL;
+ if (context) {
+ g_object_unref (context);
+ context = NULL;
+ }
+
if (fontmap) {
/* Do this late -- see bugs 558100 and 558254. */
/* and not at all on win32, where the life cycle is different */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]