From 977bdcf89b449845f3b9aeb02d02fe1fb4577fcb Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 23 Dec 2008 14:34:16 +0000 Subject: [PATCH] Update the PangoContext on backend changes When the ClutterBackend notifies of changes in the resolution or font options, update the PangoContext stored by Clutter's main context. This allows changing the backend font-related settings at runtime. --- clutter/clutter-main.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 5b6a8d357..50656101f 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -401,12 +401,27 @@ _clutter_do_pick (ClutterStage *stage, return clutter_get_actor_by_gid (id); } +static void +update_pango_context (ClutterBackend *backend, + ClutterMainContext *main_context) +{ + PangoContext *context = main_context->pango_context; + cairo_font_options_t *font_options; + gdouble resolution; + + font_options = clutter_backend_get_font_options (backend); + resolution = clutter_backend_get_resolution (backend); + if (resolution < 0) + resolution = 96.0; /* fall back */ + + pango_cairo_context_set_font_options (context, font_options); + pango_cairo_context_set_resolution (context, resolution); +} + PangoContext * _clutter_context_create_pango_context (ClutterMainContext *self) { PangoContext *context; - gdouble resolution; - cairo_font_options_t *font_options; if (G_LIKELY (self->pango_context != NULL)) context = self->pango_context; @@ -416,13 +431,14 @@ _clutter_context_create_pango_context (ClutterMainContext *self) self->pango_context = context; } - font_options = clutter_backend_get_font_options (self->backend); - resolution = clutter_backend_get_resolution (self->backend); - if (resolution < 0) - resolution = 96.0; /* fall back */ + g_signal_connect (self->backend, "resolution-changed", + G_CALLBACK (update_pango_context), + self); + g_signal_connect (self->backend, "font-changed", + G_CALLBACK (update_pango_context), + self); - pango_cairo_context_set_font_options (context, font_options); - pango_cairo_context_set_resolution (context, resolution); + update_pango_context (self->backend, self); return context; }