Index: docs/pango-sections.txt
===================================================================
RCS file: /cvs/gnome/pango/docs/pango-sections.txt,v
retrieving revision 1.72
diff -u -p -d -r1.72 pango-sections.txt
--- docs/pango-sections.txt	6 Jun 2006 20:19:56 -0000	1.72
+++ docs/pango-sections.txt	7 Jun 2006 08:10:44 -0000
@@ -17,6 +17,8 @@ pango_item_split
 pango_reorder_items
 <SUBSECTION>
 pango_context_new
+pango_context_changed
+pango_context_get_serial
 pango_context_set_font_map
 pango_context_get_font_map
 pango_context_get_font_description
@@ -231,6 +233,7 @@ pango_font_map_load_font
 pango_font_map_load_fontset
 pango_font_map_list_families
 pango_font_map_get_shape_engine_type
+pango_font_map_get_serial
 <SUBSECTION>
 PangoFontset
 PANGO_TYPE_FONTSET
@@ -411,6 +414,7 @@ pango_layout_copy
 
 pango_layout_get_context
 pango_layout_context_changed
+pango_layout_get_serial
 
 pango_layout_set_text
 pango_layout_get_text
Index: docs/tmpl/fonts.sgml
===================================================================
RCS file: /cvs/gnome/pango/docs/tmpl/fonts.sgml,v
retrieving revision 1.45
diff -u -p -d -r1.45 fonts.sgml
--- docs/tmpl/fonts.sgml	22 May 2006 20:10:07 -0000	1.45
+++ docs/tmpl/fonts.sgml	7 Jun 2006 08:10:44 -0000
@@ -805,11 +805,13 @@ a particular #PangoFontMap implementatio
             pango_font_map_load_font().
 @list_families: A function to list available font families. See
                 pango_font_map_list_families().
-@load_fontset: a function to load a fontset with a given given description
+@load_fontset: a function to load a fontset with a given description
              suitable for a particular language. See
 	     pango_font_map_load_fontset().
 @shape_engine_type: the type of rendering-system-dependent engines that
              can handle fonts of this fonts loaded with this fontmap.
+@get_serial: a function to get the serial number of the fontmap.
+	     See pango_font_map_get_serial().
 
 <!-- ##### MACRO PANGO_FONT_MAP_CLASS ##### -->
 <para>
@@ -869,6 +871,15 @@ Returns the type of a #PangoFontMap.
 
 
 <!-- ##### FUNCTION pango_font_map_get_shape_engine_type ##### -->
+<para>
+
+</para>
+
+@fontmap: 
+@Returns: 
+
+
+<!-- ##### FUNCTION pango_font_map_get_serial ##### -->
 <para>
 
 </para>
Index: docs/tmpl/layout.sgml
===================================================================
RCS file: /cvs/gnome/pango/docs/tmpl/layout.sgml,v
retrieving revision 1.35
diff -u -p -d -r1.35 layout.sgml
--- docs/tmpl/layout.sgml	29 Apr 2006 18:58:28 -0000	1.35
+++ docs/tmpl/layout.sgml	7 Jun 2006 08:10:44 -0000
@@ -97,6 +97,15 @@ has no user-visible fields.
 @layout: 
 
 
+<!-- ##### FUNCTION pango_layout_get_serial ##### -->
+<para>
+
+</para>
+
+@layout: 
+@Returns: 
+
+
 <!-- ##### FUNCTION pango_layout_set_text ##### -->
 <para>
 
Index: docs/tmpl/main.sgml
===================================================================
RCS file: /cvs/gnome/pango/docs/tmpl/main.sgml,v
retrieving revision 1.40
diff -u -p -d -r1.40 main.sgml
--- docs/tmpl/main.sgml	29 Apr 2006 18:58:28 -0000	1.40
+++ docs/tmpl/main.sgml	7 Jun 2006 08:10:44 -0000
@@ -154,6 +154,23 @@ The #GObject type for #PangoDirection.
 @Returns: 
 
 
+<!-- ##### FUNCTION pango_context_changed ##### -->
+<para>
+
+</para>
+
+@context: 
+
+
+<!-- ##### FUNCTION pango_context_get_serial ##### -->
+<para>
+
+</para>
+
+@context: 
+@Returns: 
+
+
 <!-- ##### FUNCTION pango_context_set_font_map ##### -->
 <para>
 
Index: pango/pango-context.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-context.c,v
retrieving revision 1.92
diff -u -p -d -r1.92 pango-context.c
--- pango/pango-context.c	11 May 2006 08:22:19 -0000	1.92
+++ pango/pango-context.c	7 Jun 2006 08:10:45 -0000
@@ -33,6 +33,8 @@
 struct _PangoContext
 {
   GObject parent_instance;
+  int serial;
+  int fontmap_serial;
 
   PangoLanguage *language;
   PangoDirection base_dir;
@@ -49,7 +51,8 @@ struct _PangoContextClass
   
 };
 
-static void pango_context_finalize    (GObject           *object);
+static void pango_context_finalize    (GObject       *object);
+static void context_changed           (PangoContext  *context);
 
 G_DEFINE_TYPE (PangoContext, pango_context, G_TYPE_OBJECT)
 
@@ -94,7 +97,6 @@ pango_context_finalize (GObject *object)
   G_OBJECT_CLASS (pango_context_parent_class)->finalize (object);
 }
 
-
 /**
  * pango_context_new:
  * 
@@ -146,6 +148,9 @@ pango_context_set_matrix (PangoContext  
 {
   g_return_if_fail (PANGO_IS_CONTEXT (context));
 
+  if (context->matrix || matrix)
+    context_changed (context);
+
   if (context->matrix)
     pango_matrix_free (context->matrix);
   if (matrix)
@@ -192,6 +197,9 @@ pango_context_set_font_map (PangoContext
   g_return_if_fail (PANGO_IS_CONTEXT (context));
   g_return_if_fail (!font_map || PANGO_IS_FONT_MAP (font_map));
 
+  if (font_map != context->font_map)
+    context_changed (context);
+
   if (font_map)
     g_object_ref (font_map);
 
@@ -267,6 +275,7 @@ pango_context_load_font (PangoContext   
 			 const PangoFontDescription *desc)
 {
   g_return_val_if_fail (context != NULL, NULL);
+  g_return_val_if_fail (context->font_map != NULL, NULL);
   g_return_val_if_fail (pango_font_description_get_family (desc) != NULL, NULL);
   
   return pango_font_map_load_font (context->font_map, context, desc);
@@ -309,6 +318,8 @@ pango_context_set_font_description (Pang
   g_return_if_fail (context != NULL);
   g_return_if_fail (desc != NULL);
 
+  context_changed (context);
+
   pango_font_description_free (context->font_desc);
   context->font_desc = pango_font_description_copy (desc);
 }
@@ -343,6 +354,9 @@ pango_context_set_language (PangoContext
 {
   g_return_if_fail (context != NULL);
 
+  if (language != context->language)
+    context_changed (context);
+
   context->language = language;
 }
 
@@ -382,6 +396,9 @@ pango_context_set_base_dir (PangoContext
 {
   g_return_if_fail (context != NULL);
 
+  if (direction != context->base_dir)
+    context_changed (context);
+
   context->base_dir = direction;
 }
 
@@ -1399,4 +1416,68 @@ pango_context_get_metrics (PangoContext 
   g_object_unref (current_fonts);
 
   return metrics;
+}
+
+static void
+context_changed  (PangoContext *context)
+{
+  context->serial++;
+}
+
+/**
+ * pango_context_changed:
+ * @context: a #PangoContext
+ * 
+ * Creates a new #PangoContext initialized to default value.
+ *
+ * This function is only useful when implementing a new backend
+ * for Pango, something applications won't do. Backends should
+ * call this function if they have attached extra data to the context
+ * and such data is changed.
+ *
+ * Since: 1.14
+ **/
+void
+pango_context_changed  (PangoContext *context)
+{
+  context_changed (context);
+}
+
+static void
+check_fontmap_changed (PangoContext *context)
+{
+  int old_serial = context->fontmap_serial;
+
+  if (!context->font_map)
+    return;
+
+  context->fontmap_serial = pango_font_map_get_serial (context->font_map);
+  
+  if (old_serial != context->fontmap_serial)
+    context_changed (context);
+}
+
+/**
+ * pango_context_get_serial:
+ * @context: a #PangoContext
+ * 
+ * Returns the current serial number of @context.  The serial number is
+ * initialized to an small number not less than zero when a new context
+ * is created and is increased whenever the context is changed using any
+ * of the setter functions, or the #PangoFontMap it uses to find fonts has
+ * changed.
+ *
+ * This can be used to automatically detect changes to a #PangoContext, and
+ * is only useful when implementing objects that need update when their
+ * #PangoContext changes, like #PangoLayout.
+ * 
+ * Return value: The current serial number of @context.
+ *
+ * Since: 1.14
+ **/
+int
+pango_context_get_serial (PangoContext *context)
+{
+  check_fontmap_changed (context);
+  return context->serial;
 }
Index: pango/pango-context.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-context.h,v
retrieving revision 1.20
diff -u -p -d -r1.20 pango-context.h
--- pango/pango-context.h	10 Jul 2004 21:41:37 -0000	1.20
+++ pango/pango-context.h	7 Jun 2006 08:10:45 -0000
@@ -51,11 +51,12 @@ GType         pango_context_get_type    
 
 #ifdef PANGO_ENABLE_BACKEND
 PangoContext *pango_context_new           (void);
+void          pango_context_changed       (PangoContext                 *context);
 void          pango_context_set_font_map  (PangoContext                 *context,
 					   PangoFontMap                 *font_map);
 #endif /* PANGO_ENABLE_BACKEND */
 PangoFontMap *pango_context_get_font_map  (PangoContext                 *context);
-
+int           pango_context_get_serial    (PangoContext                 *context);
 void          pango_context_list_families (PangoContext                 *context,
 					   PangoFontFamily            ***families,
 					   int                          *n_families);
Index: pango/pango-fontmap.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-fontmap.c,v
retrieving revision 1.24
diff -u -p -d -r1.24 pango-fontmap.c
--- pango/pango-fontmap.c	31 Mar 2006 01:42:54 -0000	1.24
+++ pango/pango-fontmap.c	7 Jun 2006 08:10:45 -0000
@@ -267,3 +267,30 @@ pango_font_map_get_shape_engine_type (Pa
   return PANGO_FONT_MAP_GET_CLASS (fontmap)->shape_engine_type;
 }
 
+/**
+ * pango_font_map_get_serial:
+ * @fontmap: a #PangoFontMap
+ * 
+ * Returns the current serial number of @fontmap.  The serial number is
+ * initialized to an small number not less than zero when a new fontmap
+ * is created and is increased whenever the fontmap is changed.  The fontmap
+ * can only be changed using backend-specific API, like changing fontmap
+ * resolution.
+ *
+ * This can be used to automatically detect changes to a #PangoFontMap, like
+ * in #PangoContext.
+ * 
+ * Return value: The current serial number of @fontmap.
+ *
+ * Since: 1.14
+ **/
+int
+pango_font_map_get_serial (PangoFontMap *fontmap)
+{
+  g_return_val_if_fail (PANGO_IS_FONT_MAP (fontmap), 0);
+  
+  if (PANGO_FONT_MAP_GET_CLASS (fontmap)->get_serial)
+    return PANGO_FONT_MAP_GET_CLASS (fontmap)->get_serial (fontmap);
+  else
+    return 0;
+}
Index: pango/pango-fontmap.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-fontmap.h,v
retrieving revision 1.11
diff -u -p -d -r1.11 pango-fontmap.h
--- pango/pango-fontmap.h	24 Feb 2005 19:52:40 -0000	1.11
+++ pango/pango-fontmap.h	7 Jun 2006 08:10:45 -0000
@@ -44,6 +44,7 @@ PangoFontset *pango_font_map_load_fontse
 void          pango_font_map_list_families (PangoFontMap                 *fontmap,
 					    PangoFontFamily            ***families,
 					    int                          *n_families);
+int           pango_font_map_get_serial    (PangoFontMap                 *fontmap);
 
 #ifdef PANGO_ENABLE_BACKEND
 
@@ -75,7 +76,9 @@ struct _PangoFontMapClass
 				  const PangoFontDescription *desc,
 				  PangoLanguage              *language);
   
-  const char *shape_engine_type;
+  const char   *shape_engine_type;
+
+  int           (*get_serial)    (PangoFontMap               *fontmap);
 
   /*< private >*/
 
@@ -83,10 +86,9 @@ struct _PangoFontMapClass
   void (*_pango_reserved1) (void);
   void (*_pango_reserved2) (void);
   void (*_pango_reserved3) (void);
-  void (*_pango_reserved4) (void);
 };
 
-const char   *pango_font_map_get_shape_engine_type (PangoFontMap *fontmap);
+G_CONST_RETURN char   *pango_font_map_get_shape_engine_type (PangoFontMap *fontmap);
 
 #endif /* PANGO_ENABLE_BACKEND */
 
Index: pango/pango-layout-private.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-layout-private.h,v
retrieving revision 1.1
diff -u -p -d -r1.1 pango-layout-private.h
--- pango/pango-layout-private.h	14 Jul 2004 22:17:35 -0000	1.1
+++ pango/pango-layout-private.h	7 Jun 2006 08:10:45 -0000
@@ -34,6 +34,9 @@ struct _PangoLayout
    * the _copy function
    */
   
+  int serial;
+  int context_serial;
+
   PangoContext *context;
   PangoAttrList *attrs;
   PangoFontDescription *font_desc;
Index: pango/pango-layout.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-layout.c,v
retrieving revision 1.176
diff -u -p -d -r1.176 pango-layout.c
--- pango/pango-layout.c	30 May 2006 04:23:40 -0000	1.176
+++ pango/pango-layout.c	7 Jun 2006 08:10:46 -0000
@@ -139,6 +139,9 @@ check_invalid (PangoLayoutIter *iter,
 }
 #endif
 
+static void check_context_changed  (PangoLayout *layout);
+static void layout_changed  (PangoLayout *layout);
+
 static void pango_layout_clear_lines (PangoLayout *layout);
 static void pango_layout_check_lines (PangoLayout *layout);
 
@@ -239,6 +242,7 @@ pango_layout_new (PangoContext *context)
   layout = g_object_new (PANGO_TYPE_LAYOUT, NULL);
 
   layout->context = context;
+  layout->context_serial = pango_context_get_serial (context);
   g_object_ref (context);
 
   return layout;
@@ -265,6 +269,9 @@ pango_layout_copy (PangoLayout *src)
 
   layout = pango_layout_new (src->context);
 
+  layout->serial = src->serial;
+  layout->context_serial = src->context_serial;
+
   if (src->attrs)
     layout->attrs = pango_attr_list_copy (src->attrs);
 
@@ -324,8 +331,12 @@ pango_layout_set_width (PangoLayout *lay
 {
   g_return_if_fail (layout != NULL);
 
+  if (width < 0)
+    width = -1;
+
   if (width != layout->width)
     {
+      layout_changed (layout);
       layout->width = width;
       pango_layout_clear_lines (layout);
     }
@@ -363,6 +374,7 @@ pango_layout_set_wrap (PangoLayout  *lay
 
   if (layout->wrap != wrap)
     {
+      layout_changed (layout);
       pango_layout_clear_lines (layout);
       layout->wrap = wrap;
     }
@@ -402,6 +414,7 @@ pango_layout_set_indent (PangoLayout *la
 
   if (indent != layout->indent)
     {
+      layout_changed (layout);
       layout->indent = indent;
       pango_layout_clear_lines (layout);
     }
@@ -440,6 +453,7 @@ pango_layout_set_spacing (PangoLayout *l
 
   if (spacing != layout->spacing)
     {
+      layout_changed (layout);
       layout->spacing = spacing;
       pango_layout_clear_lines (layout);
     }
@@ -475,6 +489,8 @@ pango_layout_set_attributes (PangoLayout
   PangoAttrList *old_attrs;
   g_return_if_fail (layout != NULL);
 
+  layout_changed (layout);
+
   old_attrs = layout->attrs;
 
   layout->attrs = attrs;
@@ -521,6 +537,8 @@ pango_layout_set_font_description (Pango
 
   if (desc != layout->font_desc)
     {
+      layout_changed (layout);
+
       if (layout->font_desc)
 	pango_font_description_free (layout->font_desc);
       
@@ -566,7 +584,7 @@ pango_layout_get_font_description (Pango
  * the justification may be done in more complex ways, like extending
  * the characters.
  *
- * Note that as of Pango-1.10, this functionality is not yet implemented.
+ * Note that as of Pango-1.12, this functionality is not yet implemented.
  **/
 void
 pango_layout_set_justify (PangoLayout *layout,
@@ -574,7 +592,12 @@ pango_layout_set_justify (PangoLayout *l
 {
   g_return_if_fail (layout != NULL);
 
-  layout->justify = justify;
+  if (justify != layout->justify)
+    {
+      layout_changed (layout);
+      layout->justify = justify;
+      pango_layout_clear_lines (layout);
+    }
 }
 
 /**
@@ -628,6 +651,7 @@ pango_layout_set_auto_dir (PangoLayout *
 
   if (auto_dir != layout->auto_dir)
     {
+      layout_changed (layout);
       layout->auto_dir = auto_dir;
       pango_layout_clear_lines (layout);
     }
@@ -668,7 +692,11 @@ pango_layout_set_alignment (PangoLayout 
 {
   g_return_if_fail (layout != NULL);
 
-  layout->alignment = alignment;
+  if (alignment != layout->alignment)
+    {
+      layout_changed (layout);
+      layout->alignment = alignment;
+    }
 }
 
 /**
@@ -704,6 +732,9 @@ pango_layout_set_tabs (PangoLayout   *la
 {
   g_return_if_fail (PANGO_IS_LAYOUT (layout));
   
+  if (tabs || layout->tabs)
+    layout_changed (layout);
+
   if (layout->tabs)
     pango_tab_array_free (layout->tabs);
 
@@ -753,8 +784,8 @@ pango_layout_set_single_paragraph_mode (
 
   if (layout->single_paragraph != setting)
     {
+      layout_changed (layout);
       layout->single_paragraph = setting;
-
       pango_layout_clear_lines (layout);
     }
 }
@@ -800,8 +831,8 @@ pango_layout_set_ellipsize (PangoLayout 
 
   if (ellipsize != layout->ellipsize)
     {
+      layout_changed (layout);
       layout->ellipsize = ellipsize;
-      
       pango_layout_clear_lines (layout);
     }
 }
@@ -847,6 +878,8 @@ pango_layout_set_text (PangoLayout *layo
   g_return_if_fail (layout != NULL);
   g_return_if_fail (length == 0 || text != NULL);
 
+  layout_changed (layout);
+    
   old_text = layout->text;
   
   if (length < 0)
@@ -979,6 +1012,23 @@ pango_layout_set_markup_with_accel (Pang
   g_free (text);
 }
 
+static void
+check_context_changed (PangoLayout *layout)
+{
+  int old_serial = layout->context_serial;
+
+  layout->context_serial = pango_context_get_serial (layout->context);
+  
+  if (old_serial != layout->context_serial)
+    pango_layout_context_changed (layout);
+}
+
+static void
+layout_changed (PangoLayout *layout)
+{
+  layout->serial++;
+}
+
 /**
  * pango_layout_context_changed:
  * @layout: a #PangoLayout
@@ -991,11 +1041,38 @@ pango_layout_set_markup_with_accel (Pang
 void
 pango_layout_context_changed (PangoLayout *layout)
 {
+  g_return_if_fail (PANGO_IS_LAYOUT (layout));
+
+  layout_changed (layout);
   pango_layout_clear_lines (layout);
   layout->tab_width = -1;
 }
 
 /**
+ * pango_layout_get_serial:
+ * @layout: a #PangoLayout
+ * 
+ * Returns the current serial number of @layout.  The serial number is
+ * initialized to an small number not less than zero when a new layout
+ * is created and is increased whenever the layout is changed using any
+ * of the setter functions, or the #PangoContext it uses has changed.
+ *
+ * This can be used to automatically detect changes to a #PangoLayout, and
+ * is useful for example to decide whether a layout needs redrawing.
+ * To force the serial to be increased, use pango_layout_context_changed().
+ * 
+ * Return value: The current serial number of @layout.
+ *
+ * Since: 1.14
+ **/
+int
+pango_layout_get_serial (PangoLayout *layout)
+{
+  check_context_changed (layout);
+  return layout->serial;
+}
+
+/**
  * pango_layout_get_log_attrs:
  * @layout: a #PangoLayout
  * @attrs: location to store a pointer to an array of logical attributes
@@ -3252,6 +3329,8 @@ pango_layout_check_lines (PangoLayout *l
   PangoAttrIterator *iter;
   PangoDirection prev_base_dir = PANGO_DIRECTION_NEUTRAL, base_dir = PANGO_DIRECTION_NEUTRAL;
   
+  check_context_changed (layout);
+
   if (layout->lines)
     return;
 
Index: pango/pango-layout.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-layout.h,v
retrieving revision 1.37
diff -u -p -d -r1.37 pango-layout.h
--- pango/pango-layout.h	4 Nov 2005 23:55:37 -0000	1.37
+++ pango/pango-layout.h	7 Jun 2006 08:10:46 -0000
@@ -155,6 +155,7 @@ void               pango_layout_set_elli
 PangoEllipsizeMode pango_layout_get_ellipsize (PangoLayout        *layout);
 
 void           pango_layout_context_changed (PangoLayout    *layout);
+int            pango_layout_get_serial      (PangoLayout    *layout);
 
 void     pango_layout_get_log_attrs (PangoLayout    *layout,
 				     PangoLogAttr  **attrs,
Index: pango/pango.def
===================================================================
RCS file: /cvs/gnome/pango/pango/pango.def,v
retrieving revision 1.42
diff -u -p -d -r1.42 pango.def
--- pango/pango.def	22 May 2006 20:10:08 -0000	1.42
+++ pango/pango.def	7 Jun 2006 08:10:46 -0000
@@ -50,12 +50,14 @@ EXPORTS
 	pango_color_get_type
 	pango_color_parse
 	pango_config_key_get
+	pango_context_changed
 	pango_context_get_base_dir
 	pango_context_get_font_description
 	pango_context_get_font_map
 	pango_context_get_language
 	pango_context_get_matrix
 	pango_context_get_metrics
+	pango_context_get_serial
 	pango_context_get_type
 	pango_context_list_families
 	pango_context_load_font
@@ -133,6 +135,7 @@ EXPORTS
 	pango_font_get_metrics
 	pango_font_get_type
 	pango_font_map_get_shape_engine_type
+	pango_font_map_get_serial
 	pango_font_map_get_type
 	pango_font_map_list_families
 	pango_font_map_load_font
@@ -208,6 +211,7 @@ EXPORTS
 	pango_layout_get_log_attrs
 	pango_layout_get_pixel_extents
 	pango_layout_get_pixel_size
+	pango_layout_get_serial
 	pango_layout_get_single_paragraph_mode
 	pango_layout_get_size
 	pango_layout_get_spacing
Index: pango/pangocairo-fc.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-fc.h,v
retrieving revision 1.7
diff -u -p -d -r1.7 pangocairo-fc.h
--- pango/pangocairo-fc.h	31 Mar 2006 02:20:23 -0000	1.7
+++ pango/pangocairo-fc.h	7 Jun 2006 08:10:46 -0000
@@ -37,6 +37,7 @@ struct _PangoCairoFcFontMap
 {
   PangoFcFontMap parent_instance;
 
+  int serial;
   double dpi;
 
   FT_Library library;
Index: pango/pangocairo-fcfontmap.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-fcfontmap.c,v
retrieving revision 1.8
diff -u -p -d -r1.8 pangocairo-fcfontmap.c
--- pango/pangocairo-fcfontmap.c	11 Apr 2006 08:31:43 -0000	1.8
+++ pango/pangocairo-fcfontmap.c	7 Jun 2006 08:10:46 -0000
@@ -33,12 +33,21 @@ struct _PangoCairoFcFontMapClass
   PangoFcFontMapClass parent_class;
 };
 
+static int
+pango_cairo_fc_font_map_get_serial (PangoFontMap *fontmap)
+{
+  PangoCairoFcFontMap *cffontmap = PANGO_CAIRO_FC_FONT_MAP (fontmap);
+
+  return cffontmap->serial;
+}
+
 static void
 pango_cairo_fc_font_map_set_resolution (PangoCairoFontMap *cfontmap,
 					double             dpi)
 {
   PangoCairoFcFontMap *cffontmap = PANGO_CAIRO_FC_FONT_MAP (cfontmap);
   
+  cffontmap->serial++;
   cffontmap->dpi = dpi;
 
   pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (cfontmap));
@@ -171,9 +180,12 @@ static void
 pango_cairo_fc_font_map_class_init (PangoCairoFcFontMapClass *class)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+  PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class);
   PangoFcFontMapClass *fcfontmap_class = PANGO_FC_FONT_MAP_CLASS (class);
 
   gobject_class->finalize  = pango_cairo_fc_font_map_finalize;
+
+  fontmap_class->get_serial = pango_cairo_fc_font_map_get_serial;
   
   fcfontmap_class->context_substitute = pango_cairo_fc_font_map_context_substitute;
   fcfontmap_class->get_resolution = pango_cairo_fc_font_map_get_resolution_fc;
Index: pango/pangocairo-fontmap.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-fontmap.c,v
retrieving revision 1.23
diff -u -p -d -r1.23 pangocairo-fontmap.c
--- pango/pangocairo-fontmap.c	22 May 2006 03:21:11 -0000	1.23
+++ pango/pangocairo-fontmap.c	7 Jun 2006 08:10:46 -0000
@@ -297,6 +297,8 @@ pango_cairo_update_context (cairo_t     
       cairo_font_options_destroy (info->merged_options);
       info->merged_options = NULL;
     }
+
+  pango_context_changed (context);
 }
 
 /**
@@ -318,6 +320,10 @@ pango_cairo_context_set_resolution (Pang
 				    double        dpi)
 {
   PangoCairoContextInfo *info = get_context_info (context, TRUE);
+
+  if (info->dpi != dpi)
+    pango_context_changed (context);
+
   info->dpi = dpi;
 }
 
@@ -363,6 +369,9 @@ pango_cairo_context_set_font_options (Pa
   
   info  = get_context_info (context, TRUE);
 
+  if (info->set_options || options)
+    pango_context_changed (context);
+
   if (info->set_options)
     cairo_font_options_destroy (info->set_options);
 
@@ -466,9 +475,10 @@ pango_cairo_create_layout  (cairo_t *cr)
 
   fontmap = pango_cairo_font_map_get_default ();
   context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
+  pango_cairo_update_context (cr, context);
+
   layout = pango_layout_new (context);
 
-  pango_cairo_update_context (cr, context);
   g_object_unref (context);
 
   return layout;
@@ -493,6 +503,5 @@ pango_cairo_update_layout (cairo_t     *
   g_return_if_fail (PANGO_IS_LAYOUT (layout));
 
   pango_cairo_update_context (cr, pango_layout_get_context (layout));
-  pango_layout_context_changed (layout);
 }
 
Index: pango/pangoxft-fontmap.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangoxft-fontmap.c,v
retrieving revision 1.46
diff -u -p -d -r1.46 pangoxft-fontmap.c
--- pango/pangoxft-fontmap.c	11 May 2006 08:22:20 -0000	1.46
+++ pango/pangoxft-fontmap.c	7 Jun 2006 08:10:46 -0000
@@ -41,6 +41,8 @@ struct _PangoXftFontMap
 {
   PangoFcFontMap parent_instance;
 
+  int serial;
+
   Display *display;
   int screen;
   
@@ -59,6 +61,7 @@ struct _PangoXftFontMapClass
   PangoFcFontMapClass parent_class;
 };
 
+static int           pango_xft_font_map_get_serial         (PangoFontMap         *fontmap);
 static void          pango_xft_font_map_default_substitute (PangoFcFontMap       *fcfontmap,
 							    FcPattern            *pattern);
 static PangoFcFont * pango_xft_font_map_new_font           (PangoFcFontMap       *fcfontmap,
@@ -73,9 +76,13 @@ static void
 pango_xft_font_map_class_init (PangoXftFontMapClass *class)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+  PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class);
   PangoFcFontMapClass *fcfontmap_class = PANGO_FC_FONT_MAP_CLASS (class);
 
   gobject_class->finalize  = pango_xft_font_map_finalize;
+
+  fontmap_class->get_serial = pango_xft_font_map_get_serial;
+
   fcfontmap_class->default_substitute = pango_xft_font_map_default_substitute;
   fcfontmap_class->new_font = pango_xft_font_map_new_font;
 }
@@ -102,6 +109,14 @@ pango_xft_font_map_finalize (GObject *ob
 }
 
 
+static int
+pango_xft_font_map_get_serial (PangoFontMap *fontmap)
+{
+  PangoXftFontMap *xftfontmap = PANGO_XFT_FONT_MAP (fontmap);
+
+  return xftfontmap->serial;
+}
+
 static PangoFontMap *
 pango_xft_find_font_map (Display *display,
 			 int      screen)
@@ -264,6 +279,8 @@ pango_xft_set_default_substitute (Displa
 {
   PangoXftFontMap *xftfontmap = (PangoXftFontMap *)pango_xft_get_font_map (display, screen);
   
+  xftfontmap->serial++;
+
   if (xftfontmap->substitute_destroy)
     xftfontmap->substitute_destroy (xftfontmap->substitute_data);
 
@@ -293,6 +310,8 @@ pango_xft_substitute_changed (Display *d
 {
   PangoXftFontMap *xftfontmap = (PangoXftFontMap *)pango_xft_get_font_map (display, screen);
   
+  xftfontmap->serial++;
+
   pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (xftfontmap));
 }
 
