Index: app/text/gimptextlayout.c
===================================================================
RCS file: /cvs/gnome/gimp/app/text/gimptextlayout.c,v
retrieving revision 1.21
diff -u -p -r1.21 gimptextlayout.c
--- app/text/gimptextlayout.c	25 Jan 2004 21:06:01 -0000	1.21
+++ app/text/gimptextlayout.c	21 Sep 2004 21:28:24 -0000
@@ -345,6 +345,17 @@ gimp_text_get_pango_context (GimpText *t
   context = pango_ft2_font_map_create_context (fontmap);
   g_object_unref (fontmap);
 
+  /*  Workaround for bug #143542 (PangoFT2Fontmap leak),
+   *  see also bug #148997 (Text layer rendering leaks font file descriptor):
+   *
+   *  Calling pango_ft2_font_map_substitute_changed() causes the
+   *  font_map cache to be flushed, thereby removing the circular
+   *  reference that causes the leak.
+   */
+  g_object_weak_ref (context,
+                     (GWeakNotify) pango_ft2_font_map_substitute_changed,
+                     fontmap);
+
   if (text->language)
     pango_context_set_language (context,
                                 pango_language_from_string (text->language));
