[cairo-commit] 6 commits - src/cairo-ft-font.c src/cairo-ft-private.h src/check-doc-syntax.sh test/ft-font-create-for-ft-face.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Apr 29 02:05:35 PDT 2008


 src/cairo-ft-font.c               |   34 +++++++++++++++++++++++++---------
 src/cairo-ft-private.h            |    3 ---
 src/check-doc-syntax.sh           |   10 ++++++++--
 test/ft-font-create-for-ft-face.c |    6 +++++-
 4 files changed, 38 insertions(+), 15 deletions(-)

New commits:
commit afa4ff8df598b60ab75a95ceac9bc0dafedd3b22
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Apr 29 10:02:51 2008 +0100

    [check] Filter programlistings for check-doc-syntax.sh
    
    We do not want to enforce the gtk-doc markup in the preformated
    examples, so run the files through sed to filter out <programlisting>
    before checking with the error detecting regexp.

diff --git a/src/check-doc-syntax.sh b/src/check-doc-syntax.sh
index b70e3c6..1f7cd2a 100755
--- a/src/check-doc-syntax.sh
+++ b/src/check-doc-syntax.sh
@@ -44,7 +44,10 @@ if test "x$SGML_DOCS" = x; then
 else
 	type_regexp='\(.'$type_regexp'\)\|\('$type_regexp'.\)'
 fi
-if grep "$type_regexp" $FILES | grep -v '#####'; then
+
+# We need to filter out gtk-doc markup errors for program listings.
+files=`grep "$type_regexp" $FILES | grep -v '#####' | cut -d: -f1 | sort | uniq`
+if test -n "$files" && sed -e '/<programlisting>/,/<\/programlisting>/d' $files | grep "$type_regexp" | grep -v '#####'; then
 	status=1
 	echo Error: some type names in the docs are not prefixed by hash sign,
 	echo neither are the only token in the doc line followed by colon.
@@ -56,7 +59,10 @@ func_regexp='\([^#]\|^\)\<\(cairo_[][<>/0-9a-z_]*\> \?[^][ <>(]\)'
 if test "x$SGML_DOCS" = x; then
 	func_regexp='^[/ ][*] .*'$func_regexp
 fi
-if grep "$func_regexp" $FILES | grep -v '#####'; then
+
+# We need to filter out gtk-doc markup errors for program listings.
+files=`grep "$func_regexp" $FILES | grep -v '#####' | cut -d: -f1 | sort | uniq`
+if test -n "$files" && sed -e '/<programlisting>/,/<\/programlisting>/d' $files | grep "$func_regexp" | grep -v '#####'; then
 	status=1
 	echo Error: some function names in the docs are not followed by parentheses.
 	echo Fix this by searching for the following regexp in the above files:
commit e94126fb678cecfc61e1b1afb62b8e75e2aec286
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Apr 29 09:20:30 2008 +0100

    [cairo-ft] Add a demonstration of how to handle the lifetime of the FT_Face.
    
    Extend the documentation for cairo_ft_font_face_create_for_ft_face() to
    demonstrate using cairo_font_face_set_user_data() to destroy the FT_Face
    after the final reference to the cairo_font_face_t has been dropped.

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 496f91f..95da10b 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -2535,6 +2535,22 @@ cairo_ft_font_face_create_for_pattern (FcPattern *pattern)
  * also for the FreeType backend and can be used with functions such
  * as cairo_ft_scaled_font_lock_face().
  *
+ * As an example, here is how one might correctly couple the lifetime of
+ * the FreeType face object to the #cairo_font_face_t:
+ *
+ * <informalexample><programlisting>
+ * static const cairo_user_data_key_t key;
+ *
+ * font_face = cairo_ft_font_face_create_for_ft_face (ft_face, 0);
+ * status = cairo_font_face_set_user_data (font_face, &key,
+ *                                ft_face, (cairo_destroy_func_t) FT_Done_Face);
+ * if (status) {
+ *    cairo_font_face_destroy (font_face);
+ *    FT_Done_Face (ft_face);
+ *    return ERROR;
+ * }
+ * </programlisting></informalexample>
+ *
  * Return value: a newly created #cairo_font_face_t. Free with
  *  cairo_font_face_destroy() when you are done using it.
  **/
commit 78cb05a1b7b4160b8914c75479bd60d0b34b0663
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Apr 29 09:10:50 2008 +0100

    [cairo-ft-font] Fixup doc reference to cairo_ft_font_face_create_for_ft_face()
    
    The documentation referred to cairo_ft_font_face_create_for_face().

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index d69992f..496f91f 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -2567,7 +2567,7 @@ cairo_ft_font_face_create_for_ft_face (FT_Face         face,
  * @scaled_font: A #cairo_scaled_font_t from the FreeType font backend. Such an
  *   object can be created by calling cairo_scaled_font_create() on a
  *   FreeType backend font face (see cairo_ft_font_face_create_for_pattern(),
- *   cairo_ft_font_face_create_for_face()).
+ *   cairo_ft_font_face_create_for_ft_face()).
  *
  * cairo_ft_scaled_font_lock_face() gets the #FT_Face object from a FreeType
  * backend font and scales it appropriately for the font. You must
commit f43e5e9ed975f40e4fab06cef89e40a18a5e170e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Apr 29 09:09:22 2008 +0100

    [cairo-ft] Correct the function references in the docs.
    
    The docs reference cairo_ft_font_lock_face() instead of the correct
    cairo_ft_scaled_font_lock_face() (and friends).

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index d574e01..d69992f 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -2481,7 +2481,7 @@ cairo_ft_font_options_substitute (const cairo_font_options_t *options,
  * cairo_set_font_face() or cairo_scaled_font_create(). The
  * #cairo_scaled_font_t returned from cairo_scaled_font_create() is
  * also for the FreeType backend and can be used with functions such
- * as cairo_ft_font_lock_face().
+ * as cairo_ft_scaled_font_lock_face().
  *
  * Font rendering options are represented both here and when you
  * call cairo_scaled_font_create(). Font options that have a representation
@@ -2533,7 +2533,7 @@ cairo_ft_font_face_create_for_pattern (FcPattern *pattern)
  * cairo_set_font_face() or cairo_scaled_font_create(). The
  * #cairo_scaled_font_t returned from cairo_scaled_font_create() is
  * also for the FreeType backend and can be used with functions such
- * as cairo_ft_font_lock_face().
+ * as cairo_ft_scaled_font_lock_face().
  *
  * Return value: a newly created #cairo_font_face_t. Free with
  *  cairo_font_face_destroy() when you are done using it.
@@ -2569,14 +2569,14 @@ cairo_ft_font_face_create_for_ft_face (FT_Face         face,
  *   FreeType backend font face (see cairo_ft_font_face_create_for_pattern(),
  *   cairo_ft_font_face_create_for_face()).
  *
- * cairo_ft_font_lock_face() gets the #FT_Face object from a FreeType
+ * cairo_ft_scaled_font_lock_face() gets the #FT_Face object from a FreeType
  * backend font and scales it appropriately for the font. You must
- * release the face with cairo_ft_font_unlock_face()
+ * release the face with cairo_ft_scaled_font_unlock_face()
  * when you are done using it.  Since the #FT_Face object can be
  * shared between multiple #cairo_scaled_font_t objects, you must not
  * lock any other font objects until you unlock this one. A count is
- * kept of the number of times cairo_ft_font_lock_face() is
- * called. cairo_ft_font_unlock_face() must be called the same number
+ * kept of the number of times cairo_ft_scaled_font_lock_face() is
+ * called. cairo_ft_scaled_font_unlock_face() must be called the same number
  * of times.
  *
  * You must be careful when using this function in a library or in a
commit 5d20479b99c187ee90ebce36b97a9064acff8f0d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Apr 29 09:03:00 2008 +0100

    [test/ft-font-create-for-ft-face] Fix the lifetime issues of FT_Face.
    
    The font_face created from cairo_ft_font_face_create_for_ft_face()
    was being kept alive by a reference from the context beyond the
    lifetime of the parent cairo_scaled_font_t (which owned the FT_Face).
    Correct the example in the test code to remove this errant reference
    before cleaning up the fonts. (To be fair, to actually trigger a bug
    one has to evict the FT_Face from the cache before using the font_face
    - merely creating a cairo_scaled_font_t for every font on the system is
    enough.)

diff --git a/test/ft-font-create-for-ft-face.c b/test/ft-font-create-for-ft-face.c
index 066b175..35cb77d 100644
--- a/test/ft-font-create-for-ft-face.c
+++ b/test/ft-font-create-for-ft-face.c
@@ -50,7 +50,9 @@ draw (cairo_t *cr, int width, int height)
     /* We're trying here to get our hands on _some_ FT_Face but we do
      * not at all care which one. So we start with an empty pattern
      * and do the minimal substitution on it in order to get a valid
-     * pattern. */
+     * pattern.
+     *
+     * Do not use this in production code! */
     pattern = FcPatternCreate ();
     if (! pattern) {
 	cairo_test_log ("FcPatternCreate failed.\n");
@@ -117,8 +119,10 @@ draw (cairo_t *cr, int width, int height)
 
     /* Set the font_face and force cairo to actually use it for
      * something. */
+    cairo_save (cr);
     cairo_set_font_face (cr, font_face);
     cairo_font_extents (cr, &font_extents);
+    cairo_restore (cr);
 
     /* Finally, even more cleanup */
     cairo_font_face_destroy (font_face);
commit 00965edf49a989c56d1236807f5b2901bb157005
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Apr 29 08:59:37 2008 +0100

    [cairo-ft] Remove unused private aliases.
    
    cairo_ft_scaled_font_lock_face() and friends are unused internally
    (instead _cairo_ft_unscaled_font_lock_face() is used directly), so
    remove the unnecessary aliases.

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index cc9adc3..d574e01 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -575,7 +575,7 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled)
 
     return face;
 }
-slim_hidden_def (cairo_ft_scaled_font_lock_face);
+
 
 /* Unlock unscaled font locked with _cairo_ft_unscaled_font_lock_face
  */
@@ -588,7 +588,7 @@ _cairo_ft_unscaled_font_unlock_face (cairo_ft_unscaled_font_t *unscaled)
 
     CAIRO_MUTEX_UNLOCK (unscaled->mutex);
 }
-slim_hidden_def (cairo_ft_scaled_font_unlock_face);
+
 
 static cairo_status_t
 _compute_transform (cairo_ft_font_transform_t *sf,
diff --git a/src/cairo-ft-private.h b/src/cairo-ft-private.h
index 61f21f1..67154b3 100644
--- a/src/cairo-ft-private.h
+++ b/src/cairo-ft-private.h
@@ -67,9 +67,6 @@ _cairo_ft_unscaled_font_unlock_face (cairo_ft_unscaled_font_t *unscaled);
 cairo_private cairo_bool_t
 _cairo_ft_scaled_font_is_vertical (cairo_scaled_font_t *scaled_font);
 
-slim_hidden_proto (cairo_ft_scaled_font_lock_face);
-slim_hidden_proto (cairo_ft_scaled_font_unlock_face);
-
 CAIRO_END_DECLS
 
 #endif /* CAIRO_HAS_FT_FONT */


More information about the cairo-commit mailing list