From 38f26634eec3c81d61bb3b88b24563d7e4719f67 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 3 Dec 2009 17:36:03 +0000 Subject: [PATCH] Lazily create the Pango fontmap The Pango fontmap needed by Clutter should be initialized the first time we need a PangoContext, not on initialization. --- clutter/clutter-main.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index c140108..81edc78 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -738,7 +738,7 @@ _clutter_context_get_pango_context (ClutterMainContext *self) { PangoContext *context; - context = cogl_pango_font_map_create_context (self->font_map); + context = _clutter_context_create_pango_context (self); self->pango_context = context; g_signal_connect (self->backend, "resolution-changed", @@ -748,8 +748,8 @@ _clutter_context_get_pango_context (ClutterMainContext *self) G_CALLBACK (update_pango_context), self->pango_context); } - - update_pango_context (self->backend, self->pango_context); + else + update_pango_context (self->backend, self->pango_context); return self->pango_context; } @@ -759,6 +759,19 @@ _clutter_context_create_pango_context (ClutterMainContext *self) { PangoContext *context; + if (self->font_map == NULL) + { + gdouble resolution; + + self->font_map = COGL_PANGO_FONT_MAP (cogl_pango_font_map_new ()); + + resolution = clutter_backend_get_resolution (self->backend); + cogl_pango_font_map_set_resolution (self->font_map, resolution); + + if (G_LIKELY (!clutter_disable_mipmap_text)) + cogl_pango_font_map_set_use_mipmapping (self->font_map, TRUE); + } + context = cogl_pango_font_map_create_context (self->font_map); update_pango_context (self->backend, context); pango_context_set_language (context, pango_language_get_default ()); @@ -1480,7 +1493,6 @@ clutter_init_real (GError **error) { ClutterMainContext *ctx; ClutterActor *stage; - gdouble resolution; ClutterBackend *backend; /* Note, creates backend if not already existing, though parse args will @@ -1522,20 +1534,6 @@ clutter_init_real (GError **error) _clutter_profile_suspend (); #endif - /* - * Resolution requires display to be open, so can only be queried after - * the post_parse hooks run. - * - * NB: cogl_pango requires a Cogl context. - */ - ctx->font_map = COGL_PANGO_FONT_MAP (cogl_pango_font_map_new ()); - - resolution = clutter_backend_get_resolution (ctx->backend); - cogl_pango_font_map_set_resolution (ctx->font_map, resolution); - - if (!clutter_disable_mipmap_text) - cogl_pango_font_map_set_use_mipmapping (ctx->font_map, TRUE); - clutter_text_direction = clutter_get_text_direction (); /* Figure out framebuffer masks used for pick */ @@ -1573,7 +1571,6 @@ clutter_init_real (GError **error) clutter_stage_set_title (CLUTTER_STAGE (stage), g_get_prgname ()); clutter_actor_realize (stage); - if (!CLUTTER_ACTOR_IS_REALIZED (stage)) { if (error) -- 2.7.4