pango r2675 - in trunk: . docs docs/tmpl pango pango-view



Author: behdad
Date: Wed Aug  6 08:39:01 2008
New Revision: 2675
URL: http://svn.gnome.org/viewvc/pango?rev=2675&view=rev

Log:
2008-08-05  Behdad Esfahbod  <behdad gnome org>

        * pango/pango-context.c:
        * pango/pango-context.h:
        Make the following API public:

                pango_context_new()
                pango_context_set_font_map()

        * pango/pango-fontmap.c (pango_font_map_create_context):
        * pango/pango-fontmap.h:
        New public API:

                pango_font_map_create_context()

        * pango/pangocairo-context.c (pango_cairo_create_context):
        * pango/pangocairo-font.c (_pango_cairo_font_get_metrics),
        (_pango_cairo_font_private_get_hex_box_info):
        * pango/pangocairo-fontmap.c (pango_cairo_font_map_create_context):
        * pango/pangocairo.h:
        Deprecate pango_cairo_font_map_create_context().

        * pango/pangofc-font.c (pango_fc_font_get_metrics):
        * pango/pangofc-fontmap.c (pango_fc_font_map_create_context):
        * pango/pangofc-fontmap.h:
        Deprecate pango_fc_font_map_create_context().

        * pango/pangoft2-fontmap.c (pango_ft2_font_map_create_context),
        (pango_ft2_get_context):
        * pango/pangoft2.h:
        Deprecate pango_ft2_font_map_create_context().

        * pango/pangowin32.c (pango_win32_get_context),
        (pango_win32_font_get_metrics):
        * pango/pangowin32.h:
        Deprecate pango_win32_get_context().

        * pango/pangoxft-font.c (_pango_xft_font_get_mini_font):
        * pango/pangoxft-fontmap.c (pango_xft_get_context):
        * pango/pangoxft.h:
        Deprecate pango_xft_get_context().

        * pango/pangox-fontmap.c (pango_x_font_map_for_display):
        * pango/pangox.c (get_context_info), (pango_x_get_context),
        (pango_x_context_set_funcs), (pango_x_render_layout_line):
        Deprecate pango_x_get_context(), again.

        * docs/pango-sections.txt:
        * docs/tmpl/fonts.sgml:
        * pango-view/viewer-pangocairo.c (pangocairo_view_get_context):
        * pango-view/viewer-pangoft2.c (pangoft2_view_get_context):
        * pango-view/viewer-pangox.c (pangox_view_get_context):
        * pango-view/viewer-pangoxft.c (pangoxft_view_get_context):
        * pango/check.defs:
        * pango/pango.def:
        Update.

Modified:
   trunk/ChangeLog
   trunk/docs/pango-sections.txt
   trunk/docs/tmpl/fonts.sgml
   trunk/pango-view/viewer-pangocairo.c
   trunk/pango-view/viewer-pangoft2.c
   trunk/pango-view/viewer-pangox.c
   trunk/pango-view/viewer-pangoxft.c
   trunk/pango/check.defs
   trunk/pango/pango-context.c
   trunk/pango/pango-context.h
   trunk/pango/pango-fontmap.c
   trunk/pango/pango-fontmap.h
   trunk/pango/pango.def
   trunk/pango/pangocairo-context.c
   trunk/pango/pangocairo-font.c
   trunk/pango/pangocairo-fontmap.c
   trunk/pango/pangocairo.h
   trunk/pango/pangofc-font.c
   trunk/pango/pangofc-fontmap.c
   trunk/pango/pangofc-fontmap.h
   trunk/pango/pangoft2-fontmap.c
   trunk/pango/pangoft2.h
   trunk/pango/pangowin32.c
   trunk/pango/pangowin32.h
   trunk/pango/pangox-fontmap.c
   trunk/pango/pangox.c
   trunk/pango/pangoxft-font.c
   trunk/pango/pangoxft-fontmap.c
   trunk/pango/pangoxft.h

Modified: trunk/docs/pango-sections.txt
==============================================================================
--- trunk/docs/pango-sections.txt	(original)
+++ trunk/docs/pango-sections.txt	Wed Aug  6 08:39:01 2008
@@ -243,6 +243,7 @@
 PANGO_FONT_MAP_CLASS
 PANGO_IS_FONT_MAP_CLASS
 PANGO_FONT_MAP_GET_CLASS
+pango_font_map_create_context
 pango_font_map_load_font
 pango_font_map_load_fontset
 pango_font_map_list_families

Modified: trunk/docs/tmpl/fonts.sgml
==============================================================================
--- trunk/docs/tmpl/fonts.sgml	(original)
+++ trunk/docs/tmpl/fonts.sgml	Wed Aug  6 08:39:01 2008
@@ -863,6 +863,15 @@
 @obj: a #PangoFontMap.
 
 
+<!-- ##### FUNCTION pango_font_map_create_context ##### -->
+<para>
+
+</para>
+
+ fontmap:
+ Returns:
+
+
 <!-- ##### FUNCTION pango_font_map_load_font ##### -->
 <para>
 

Modified: trunk/pango-view/viewer-pangocairo.c
==============================================================================
--- trunk/pango-view/viewer-pangocairo.c	(original)
+++ trunk/pango-view/viewer-pangocairo.c	Wed Aug  6 08:39:01 2008
@@ -84,7 +84,7 @@
   CairoViewer *c = (CairoViewer *) instance;
   PangoContext *context;
 
-  context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (c->fontmap));
+  context = pango_font_map_create_context (c->fontmap);
   pango_cairo_context_set_font_options (context, c->font_options);
 
   return context;

Modified: trunk/pango-view/viewer-pangoft2.c
==============================================================================
--- trunk/pango-view/viewer-pangoft2.c	(original)
+++ trunk/pango-view/viewer-pangoft2.c	Wed Aug  6 08:39:01 2008
@@ -65,7 +65,7 @@
 static PangoContext *
 pangoft2_view_get_context (gpointer instance)
 {
-  return pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (instance));
+  return pango_font_map_create_context (PANGO_FONT_MAP (instance));
 }
 
 static gpointer

Modified: trunk/pango-view/viewer-pangox.c
==============================================================================
--- trunk/pango-view/viewer-pangox.c	(original)
+++ trunk/pango-view/viewer-pangox.c	Wed Aug  6 08:39:01 2008
@@ -42,7 +42,7 @@
   PangoContext *context;
   PangoMatrix matrix = {0., 0., 0., 0., 0., 0.};
 
-  context = pango_x_get_context (x->display);
+  context = pango_font_map_create_context (pango_x_font_map_for_display (x->display));
 
   /* We set an all-zero matrix on the context, to negotiate that
    * this backend doesn't support transformations.

Modified: trunk/pango-view/viewer-pangoxft.c
==============================================================================
--- trunk/pango-view/viewer-pangoxft.c	(original)
+++ trunk/pango-view/viewer-pangoxft.c	Wed Aug  6 08:39:01 2008
@@ -72,7 +72,7 @@
 {
   XViewer *x = (XViewer *) instance;
 
-  return pango_xft_get_context (x->display, x->screen);
+  return pango_font_map_create_context (pango_xft_get_font_map (x->display, x->screen));
 }
 
 typedef struct

Modified: trunk/pango/check.defs
==============================================================================
--- trunk/pango/check.defs	(original)
+++ trunk/pango/check.defs	Wed Aug  6 08:39:01 2008
@@ -23,7 +23,7 @@
 	eval $get_pango_syms | sort -u > "$expected"
 	cut -f 2 "$def" | grep -v EXPORTS | sort -u > "$list"
 
-	diff "$list" "$expected" >&2 && rm -f "$list" "$expected" || status=1
+	diff -u "$list" "$expected" >&2 && rm -f "$list" "$expected" || status=1
 done
 
 exit $status

Modified: trunk/pango/pango-context.c
==============================================================================
--- trunk/pango/pango-context.c	(original)
+++ trunk/pango/pango-context.c	Wed Aug  6 08:39:01 2008
@@ -107,19 +107,18 @@
 /**
  * pango_context_new:
  *
- * Creates a new #PangoContext initialized to default value.
+ * Creates a new #PangoContext initialized to default values.
  *
- * This function is only useful when implementing a new backend
- * for Pango, something applications won't do. You should use
- * the context creation function for the backend you are using,
- * for example, pango_cairo_font_map_create_context(), pango_xft_get_context(),
- * pango_win32_get_context() or, pango_ft2_font_map_create_context().
+ * This function is not particularly useful as it should always
+ * be followed by a pango_context_set_font_map() call, and the
+ * function pango_font_map_create_context() does these two steps
+ * together and hence users are recommended to use that.
  *
  * If you are using Pango as part of a higher-level system,
- * that system may have it's own ways of create a #PangoContext.
+ * that system may have it's own way of create a #PangoContext.
  * For instance, the GTK+ toolkit has, among others,
  * gdk_pango_context_get_for_screen(), and
- * gtk_widget_get_pango_context().
+ * gtk_widget_get_pango_context().  Use those instead.
  *
  * Return value: the newly allocated #PangoContext, which should
  *               be freed with g_object_unref().

Modified: trunk/pango/pango-context.h
==============================================================================
--- trunk/pango/pango-context.h	(original)
+++ trunk/pango/pango-context.h	Wed Aug  6 08:39:01 2008
@@ -49,11 +49,9 @@
 
 GType         pango_context_get_type      (void) G_GNUC_CONST;
 
-#ifdef PANGO_ENABLE_BACKEND
 PangoContext *pango_context_new           (void);
 void          pango_context_set_font_map  (PangoContext                 *context,
 					   PangoFontMap                 *font_map);
-#endif /* PANGO_ENABLE_BACKEND */
 PangoFontMap *pango_context_get_font_map  (PangoContext                 *context);
 
 void          pango_context_list_families (PangoContext                 *context,

Modified: trunk/pango/pango-fontmap.c
==============================================================================
--- trunk/pango/pango-fontmap.c	(original)
+++ trunk/pango/pango-fontmap.c	Wed Aug  6 08:39:01 2008
@@ -44,6 +44,37 @@
 }
 
 /**
+ * pango_font_map_create_context:
+ * @fontmap: a #PangoFontMap
+ *
+ * Creates a #PangoContext connected to @fontmap.  This is equivalent
+ * to pango_context_new() followed by pango_context_set_font_map().
+ *
+ * If you are using Pango as part of a higher-level system,
+ * that system may have it's own way of create a #PangoContext.
+ * For instance, the GTK+ toolkit has, among others,
+ * gdk_pango_context_get_for_screen(), and
+ * gtk_widget_get_pango_context().  Use those instead.
+ *
+ * Return value: the newly allocated #PangoContext, which should
+ *               be freed with g_object_unref().
+ *
+ * Since: 1.22
+ **/
+PangoContext *
+pango_font_map_create_context (PangoFontMap *fontmap)
+{
+  PangoContext *context;
+
+  g_return_val_if_fail (fontmap != NULL, NULL);
+
+  context = pango_context_new ();
+  pango_context_set_font_map (context, fontmap);
+
+  return context;
+}
+
+/**
  * pango_font_map_load_font:
  * @fontmap: a #PangoFontMap
  * @context: the #PangoContext the font will be used with

Modified: trunk/pango/pango-fontmap.h
==============================================================================
--- trunk/pango/pango-fontmap.h	(original)
+++ trunk/pango/pango-fontmap.h	Wed Aug  6 08:39:01 2008
@@ -34,6 +34,7 @@
 typedef struct _PangoContext PangoContext;
 
 GType         pango_font_map_get_type       (void) G_GNUC_CONST;
+PangoContext * pango_font_map_create_context (PangoFontMap               *fontmap);
 PangoFont *   pango_font_map_load_font     (PangoFontMap                 *fontmap,
 					    PangoContext                 *context,
 					    const PangoFontDescription   *desc);

Modified: trunk/pango/pango.def
==============================================================================
--- trunk/pango/pango.def	(original)
+++ trunk/pango/pango.def	Wed Aug  6 08:39:01 2008
@@ -148,6 +148,7 @@
 	pango_font_get_glyph_extents
 	pango_font_get_metrics
 	pango_font_get_type
+	pango_font_map_create_context
 	pango_font_map_get_shape_engine_type
 	pango_font_map_get_type
 	pango_font_map_list_families

Modified: trunk/pango/pangocairo-context.c
==============================================================================
--- trunk/pango/pangocairo-context.c	(original)
+++ trunk/pango/pangocairo-context.c	Wed Aug  6 08:39:01 2008
@@ -145,7 +145,7 @@
 /**
  * pango_cairo_update_context:
  * @cr: a Cairo context
- * @context: a #PangoContext, from pango_cairo_font_map_create_context()
+ * @context: a #PangoContext, from a pangocairo font map
  *
  * Updates a #PangoContext previously created for use with Cairo to
  * match the current transformation and target surface of a Cairo
@@ -167,7 +167,7 @@
 
 /**
  * pango_cairo_context_set_resolution:
- * @context: a #PangoContext, from pango_cairo_font_map_create_context()
+ * @context: a #PangoContext, from a pangocairo font map
  * @dpi: the resolution in "dots per inch". (Physical inches aren't actually
  *   involved; the terminology is conventional.) A 0 or negative value
  *   means to use the resolution from the font map.
@@ -189,7 +189,7 @@
 
 /**
  * pango_cairo_context_get_resolution:
- * @context: a #PangoContext, from pango_cairo_font_map_create_context()
+ * @context: a #PangoContext, from a pangocairo font map
  *
  * Gets the resolution for the context. See pango_cairo_context_set_resolution()
  *
@@ -211,7 +211,7 @@
 
 /**
  * pango_cairo_context_set_font_options:
- * @context: a #PangoContext, from pango_cairo_font_map_create_context()
+ * @context: a #PangoContext, from a pangocairo font map
  * @options: a #cairo_font_options_t, or %NULL to unset any previously set
  *           options. A copy is made.
  *
@@ -248,7 +248,7 @@
 
 /**
  * pango_cairo_context_get_font_options:
- * @context: a #PangoContext, from pango_cairo_font_map_create_context()
+ * @context: a #PangoContext, from a pangocairo font map
  *
  * Retrieves any font rendering options previously set with
  * pango_cairo_font_map_set_font_options(). This functions not report options
@@ -306,7 +306,7 @@
 
 /**
  * pango_cairo_context_set_shape_renderer:
- * @context: a #PangoContext, from pango_cairo_font_map_create_context()
+ * @context: a #PangoContext, from a pangocairo font map
  * @func: Callback function for rendering attributes of type
  * %PANGO_ATTR_SHAPE, or %NULL to disable shape rendering.
  * @data: User data that will be passed to @func.
@@ -341,7 +341,7 @@
 
 /**
  * pango_cairo_context_get_shape_renderer:
- * @context: a #PangoContext, from pango_cairo_font_map_create_context()
+ * @context: a #PangoContext, from a pangocairo font map
  * @data: Pointer to #gpointer to return user data
  *
  * Sets callback function for context to use for rendering attributes
@@ -408,7 +408,7 @@
   g_return_val_if_fail (cr != NULL, NULL);
 
   fontmap = pango_cairo_font_map_get_default ();
-  context = pango_cairo_font_map_create_context ((PangoCairoFontMap *) (fontmap));
+  context = pango_font_map_create_context (fontmap);
   pango_cairo_update_context (cr, context);
 
   return context;

Modified: trunk/pango/pangocairo-font.c
==============================================================================
--- trunk/pango/pangocairo-font.c	(original)
+++ trunk/pango/pangocairo-font.c	Wed Aug  6 08:39:01 2008
@@ -233,7 +233,7 @@
 
       info->sample_str = sample_str;
 
-      context = pango_cairo_font_map_create_context ((PangoCairoFontMap *) pango_font_get_font_map (font));
+      context = pango_font_map_create_context (pango_font_get_font_map (font));
       pango_context_set_language (context, language);
       font_options = cairo_font_options_create ();
       cairo_scaled_font_get_font_options (_pango_cairo_font_private_get_scaled_font (cf_priv), font_options);
@@ -388,7 +388,7 @@
 
     /* load mini_font */
 
-    context = pango_cairo_font_map_create_context ((PangoCairoFontMap *) (fontmap));
+    context = pango_font_map_create_context (fontmap);
 
     pango_context_set_matrix (context, &pango_ctm);
     pango_context_set_language (context, pango_script_get_sample_language (PANGO_SCRIPT_LATIN));

Modified: trunk/pango/pangocairo-fontmap.c
==============================================================================
--- trunk/pango/pangocairo-fontmap.c	(original)
+++ trunk/pango/pangocairo-fontmap.c	Wed Aug  6 08:39:01 2008
@@ -252,6 +252,9 @@
  *
  * Create a #PangoContext for the given fontmap.
  *
+ * As of Pango 1.20 this function is deprecated.
+ * Use pango_font_map_create_context() instead.
+ *
  * Return value: the newly created context; free with g_object_unref().
  *
  * Since: 1.10
@@ -259,14 +262,9 @@
 PangoContext *
 pango_cairo_font_map_create_context (PangoCairoFontMap *fontmap)
 {
-  PangoContext *context;
-
   g_return_val_if_fail (PANGO_IS_CAIRO_FONT_MAP (fontmap), NULL);
 
-  context = pango_context_new ();
-  pango_context_set_font_map (context, PANGO_FONT_MAP (fontmap));
-
-  return context;
+  return pango_font_map_create_context (PANGO_FONT_MAP (fontmap));
 }
 
 /**

Modified: trunk/pango/pangocairo.h
==============================================================================
--- trunk/pango/pangocairo.h	(original)
+++ trunk/pango/pangocairo.h	Wed Aug  6 08:39:01 2008
@@ -74,7 +74,9 @@
 void          pango_cairo_font_map_set_resolution (PangoCairoFontMap *fontmap,
 						   double             dpi);
 double        pango_cairo_font_map_get_resolution (PangoCairoFontMap *fontmap);
+#ifndef PANGO_DISABLE_DEPRECATED
 PangoContext *pango_cairo_font_map_create_context (PangoCairoFontMap *fontmap);
+#endif
 
 /*
  * PangoCairoFont

Modified: trunk/pango/pangofc-font.c
==============================================================================
--- trunk/pango/pangofc-font.c	(original)
+++ trunk/pango/pangofc-font.c	Wed Aug  6 08:39:01 2008
@@ -541,7 +541,7 @@
 
       info->sample_str = sample_str;
 
-      context = pango_fc_font_map_create_context (PANGO_FC_FONT_MAP (fcfont->fontmap));
+      context = pango_font_map_create_context (fcfont->fontmap);
       pango_context_set_language (context, language);
 
       info->metrics = pango_fc_font_create_metrics_for_context (fcfont, context);

Modified: trunk/pango/pangofc-fontmap.c
==============================================================================
--- trunk/pango/pangofc-fontmap.c	(original)
+++ trunk/pango/pangofc-fontmap.c	Wed Aug  6 08:39:01 2008
@@ -1415,6 +1415,9 @@
  * needed for correct operation on the #PangoContext after calling
  * this function.
  *
+ * As of Pango 1.20 this function is deprecated.
+ * Use pango_font_map_create_context() instead.
+ *
  * Return value: a new #PangoContext
  *
  * Since: 1.4
@@ -1422,10 +1425,9 @@
 PangoContext *
 pango_fc_font_map_create_context (PangoFcFontMap *fcfontmap)
 {
-  PangoContext *context = pango_context_new ();
-  pango_context_set_font_map (context, PANGO_FONT_MAP (fcfontmap));
+  g_return_val_if_fail (PANGO_IS_FC_FONT_MAP (fcfontmap), NULL);
 
-  return context;
+  return pango_font_map_create_context (PANGO_FONT_MAP (fcfontmap));
 }
 
 static void

Modified: trunk/pango/pangofc-fontmap.h
==============================================================================
--- trunk/pango/pangofc-fontmap.h	(original)
+++ trunk/pango/pangofc-fontmap.h	Wed Aug  6 08:39:01 2008
@@ -143,7 +143,9 @@
   void (*_pango_reserved4) (void);
 };
 
+#ifndef PANGO_DISABLE_DEPRECATED
 PangoContext * pango_fc_font_map_create_context (PangoFcFontMap *fcfontmap);
+#endif
 void           pango_fc_font_map_shutdown       (PangoFcFontMap *fcfontmap);
 
 #endif

Modified: trunk/pango/pangoft2-fontmap.c
==============================================================================
--- trunk/pango/pangoft2-fontmap.c	(original)
+++ trunk/pango/pangoft2-fontmap.c	Wed Aug  6 08:39:01 2008
@@ -217,6 +217,9 @@
  *
  * Create a #PangoContext for the given fontmap.
  *
+ * As of Pango 1.20 this function is deprecated.
+ * Use pango_font_map_create_context() instead.
+ *
  * Return value: the newly created context; free with g_object_unref().
  *
  * Since: 1.2
@@ -226,7 +229,7 @@
 {
   g_return_val_if_fail (PANGO_FT2_IS_FONT_MAP (fontmap), NULL);
 
-  return pango_fc_font_map_create_context (PANGO_FC_FONT_MAP (fontmap));
+  return pango_font_map_create_context (PANGO_FONT_MAP (fontmap));
 }
 
 /**
@@ -238,7 +241,7 @@
  * (see pango_ft2_fontmap_get_for_display()) and sets the resolution
  * for the default fontmap to @dpi_x by @dpi_y.
  *
- * Use of this function is deprecated; see pango_ft2_fontmap_create_context()
+ * Use of this function is deprecated. Use pango_fontmap_create_context()
  * instead.
  *
  * Return value: the new #PangoContext
@@ -251,7 +254,7 @@
   fontmap = pango_ft2_font_map_for_display ();
   pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap), dpi_x, dpi_y);
 
-  return pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap));
+  return pango_font_map_create_context (fontmap);
 }
 
 /**

Modified: trunk/pango/pangoft2.h
==============================================================================
--- trunk/pango/pangoft2.h	(original)
+++ trunk/pango/pangoft2.h	Wed Aug  6 08:39:01 2008
@@ -85,7 +85,9 @@
 							 gpointer                data,
 							 GDestroyNotify          notify);
 void          pango_ft2_font_map_substitute_changed     (PangoFT2FontMap         *fontmap);
+#ifndef PANGO_DISABLE_DEPRECATED
 PangoContext *pango_ft2_font_map_create_context         (PangoFT2FontMap         *fontmap);
+#endif
 
 
 /* API for rendering modules

Modified: trunk/pango/pangowin32.c
==============================================================================
--- trunk/pango/pangowin32.c	(original)
+++ trunk/pango/pangowin32.c	Wed Aug  6 08:39:01 2008
@@ -122,17 +122,16 @@
  *
  * Retrieves a #PangoContext appropriate for rendering with Windows fonts.
   *
+ * As of Pango 1.20 this function is deprecated.
+ * Use pango_win32_font_map_for_display() followed by
+ * pango_font_map_create_context() instead.
+ *
  * Return value: the new #PangoContext
  **/
 PangoContext *
 pango_win32_get_context (void)
 {
-  PangoContext *result;
-
-  result = pango_context_new ();
-  pango_context_set_font_map (result, pango_win32_font_map_for_display ());
-
-  return result;
+  return pango_font_map_create_context (pango_win32_font_map_for_display ());
 }
 
 G_DEFINE_TYPE (PangoWin32Font, _pango_win32_font, PANGO_TYPE_FONT)
@@ -586,7 +585,7 @@
 	      PangoLayout *layout;
 
 	      /*  Get the average width of the chars in "0123456789" */
-	      context = pango_win32_get_context ();
+	      context = pango_font_map_create_context (pango_win32_font_map_for_display ());
 	      pango_context_set_language (context, language);
 	      font_desc = pango_font_describe_with_absolute_size (font);
 	      pango_context_set_font_description (context, font_desc);

Modified: trunk/pango/pangowin32.h
==============================================================================
--- trunk/pango/pangowin32.h	(original)
+++ trunk/pango/pangowin32.h	Wed Aug  6 08:39:01 2008
@@ -41,7 +41,9 @@
 
 /* Calls for applications
  */
+#ifndef PANGO_DISABLE_DEPRECATED
 PangoContext * pango_win32_get_context        (void);
+#endif
 
 void           pango_win32_render             (HDC               hdc,
 					       PangoFont        *font,

Modified: trunk/pango/pangox-fontmap.c
==============================================================================
--- trunk/pango/pangox-fontmap.c	(original)
+++ trunk/pango/pangox-fontmap.c	Wed Aug  6 08:39:01 2008
@@ -34,6 +34,7 @@
 #include "pango-engine-private.h"
 #include "pango-fontmap.h"
 #include "pango-impl-utils.h"
+#include "modules.h"
 
 #undef PANGO_DISABLE_DEPRECATED
 
@@ -278,9 +279,18 @@
   char **xfontnames;
   int num_fonts, i;
   int screen;
+  static gboolean registered_modules = FALSE;
 
   g_return_val_if_fail (display != NULL, NULL);
 
+  if (!registered_modules)
+    {
+      registered_modules = TRUE;
+
+      for (i = 0; _pango_included_x_modules[i].list; i++)
+	pango_module_register (&_pango_included_x_modules[i]);
+    }
+
   /* Make sure that the type system is initialized */
   g_type_init ();
 

Modified: trunk/pango/pangox.c
==============================================================================
--- trunk/pango/pangox.c	(original)
+++ trunk/pango/pangox.c	Wed Aug  6 08:39:01 2008
@@ -26,7 +26,6 @@
 
 #include <X11/Xlib.h>
 #include "pango-impl-utils.h"
-#include "modules.h"
 
 #undef PANGO_DISABLE_DEPRECATED
 
@@ -159,6 +158,30 @@
   g_slice_free (PangoXContextInfo, info);
 }
 
+static PangoXContextInfo *
+get_context_info (PangoContext *context)
+{
+  PangoXContextInfo *info;
+  static quark = 0;
+
+  if (G_UNLIKELY (!quark))
+    quark = g_quark_from_static_string ("pango-x-info");
+
+  info =  g_object_get_qdata (G_OBJECT (context), quark);
+
+  if (G_UNLIKELY (!info))
+    {
+      info = g_slice_new (PangoXContextInfo);
+      info->get_gc_func = NULL;
+      info->free_gc_func = NULL;
+      g_object_set_qdata_full (G_OBJECT (context),
+			       quark,
+			       info, (GDestroyNotify)free_context_info);
+    }
+
+  return info;
+}
+
 /**
  * pango_x_get_context:
  * @display: an X display (As returned by XOpenDisplay().)
@@ -166,38 +189,15 @@
  * Retrieves a #PangoContext appropriate for rendering with X fonts on the
  * given display.
  *
+ * This function is deprecated.  Use pango_x_font_map_for_display() followed
+ * by pango_font_map_create_context() instead.
+ *
  * Return value: the new #PangoContext.
  **/
 PangoContext *
 pango_x_get_context (Display *display)
 {
-  PangoContext *result;
-  PangoXContextInfo *info;
-  int i;
-  static gboolean registered_modules = FALSE;
-
-  g_return_val_if_fail (display != NULL, NULL);
-
-  if (!registered_modules)
-    {
-      registered_modules = TRUE;
-
-      for (i = 0; _pango_included_x_modules[i].list; i++)
-	pango_module_register (&_pango_included_x_modules[i]);
-    }
-
-  result = pango_context_new ();
-
-  info = g_slice_new (PangoXContextInfo);
-  info->get_gc_func = NULL;
-  info->free_gc_func = NULL;
-  g_object_set_qdata_full (G_OBJECT (result),
-			   g_quark_from_static_string ("pango-x-info"),
-			   info, (GDestroyNotify)free_context_info);
-
-  pango_context_set_font_map (result, pango_x_font_map_for_display (display));
-
-  return result;
+  return pango_font_map_create_context (pango_x_font_map_for_display (display));
 }
 
 /**
@@ -218,8 +218,7 @@
 
   g_return_if_fail (context != NULL);
 
-  info = g_object_get_qdata (G_OBJECT (context),
-			     g_quark_from_static_string ("pango-x-info"));
+  info = get_context_info (context);
 
   info->get_gc_func = get_gc_func;
   info->free_gc_func = free_gc_func;
@@ -1497,9 +1496,7 @@
   PangoRectangle logical_rect;
   PangoRectangle ink_rect;
   PangoContext *context = pango_layout_get_context (line->layout);
-  PangoXContextInfo *info =
-    g_object_get_qdata (G_OBJECT (context),
-			g_quark_from_static_string ("pango-x-info"));
+  PangoXContextInfo *info = get_context_info (context);
 
   int x_off = 0;
 

Modified: trunk/pango/pangoxft-font.c
==============================================================================
--- trunk/pango/pangoxft-font.c	(original)
+++ trunk/pango/pangoxft-font.c	Wed Aug  6 08:39:01 2008
@@ -138,7 +138,7 @@
 
       _pango_xft_font_map_get_info (fcfont->fontmap, &display, &screen);
 
-      context = pango_xft_get_context (display, screen);
+      context = pango_font_map_create_context (pango_xft_get_font_map (display, screen));
       pango_context_set_language (context, pango_language_from_string ("en"));
 
       pango_font_description_set_family_static (desc, "monospace");

Modified: trunk/pango/pangoxft-fontmap.c
==============================================================================
--- trunk/pango/pangoxft-fontmap.c	(original)
+++ trunk/pango/pangoxft-fontmap.c	Wed Aug  6 08:39:01 2008
@@ -317,18 +317,19 @@
  * Retrieves a #PangoContext appropriate for rendering with
  * Xft fonts on the given screen of the given display.
  *
+ * As of Pango 1.20 this function is deprecated.
+ * Use pango_xft_get_font_map() followed by
+ * pango_font_map_create_context() instead.
+ *
  * Return value: the new #PangoContext.
  **/
 PangoContext *
 pango_xft_get_context (Display *display,
 		       int      screen)
 {
-  PangoFontMap *fontmap;
-
   g_return_val_if_fail (display != NULL, NULL);
 
-  fontmap = pango_xft_get_font_map (display, screen);
-  return pango_fc_font_map_create_context (PANGO_FC_FONT_MAP (fontmap));
+  return pango_font_map_create_context (pango_xft_get_font_map (display, screen));
 }
 
 /**

Modified: trunk/pango/pangoxft.h
==============================================================================
--- trunk/pango/pangoxft.h	(original)
+++ trunk/pango/pangoxft.h	Wed Aug  6 08:39:01 2008
@@ -50,8 +50,10 @@
  */
 PangoFontMap *pango_xft_get_font_map     (Display *display,
 					  int      screen);
+#ifndef PANGO_DISABLE_DEPRECATED
 PangoContext *pango_xft_get_context      (Display *display,
 					  int      screen);
+#endif
 void          pango_xft_shutdown_display (Display *display,
 					  int      screen);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]