[cairo-commit] src/cairo.h src/cairo-scaled-font.c src/cairo-user-font.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Sep 29 08:34:41 PDT 2008


 src/cairo-scaled-font.c |    8 +++++---
 src/cairo-user-font.c   |    5 +++++
 src/cairo.h             |    2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 1310df44edcf0b9fee648c8f8688d4a1177cde68
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Sep 29 11:34:19 2008 -0400

    [text_to_glyphs] Further enhance the docs
    
    The most complex public cairo API deserves more doc love...

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index c548655..caa345f 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -1336,9 +1336,10 @@ slim_hidden_def (cairo_scaled_font_glyph_extents);
  * entries available there.  If the provided glyph array is too short for
  * the conversion, a new glyph array is allocated using cairo_glyph_allocate()
  * and placed in @glyphs.  Upon return, @num_glyphs always contains the
- * number of generated glyphs.  If the value @glyphs points at has changed
+ * number of generated glyphs.  If the value @glyphs points to has changed
  * after the call, the user is responsible for freeing the allocated glyph
- * array using cairo_glyph_free().
+ * array using cairo_glyph_free().  This may happen even if the provided
+ * array was large enough.
  *
  * If @clusters is not %NULL, @num_clusters and @cluster_flags should not be %NULL,
  * and cluster mapping will be computed.
@@ -1351,7 +1352,8 @@ slim_hidden_def (cairo_scaled_font_glyph_extents);
  * and placed in @clusters.  Upon return, @num_clusters always contains the
  * number of generated clusters.  If the value @clusters points at has changed
  * after the call, the user is responsible for freeing the allocated cluster
- * array using cairo_text_cluster_free().
+ * array using cairo_text_cluster_free().  This may happen even if the provided
+ * array was large enough.
  *
  * In the simplest case, @glyphs and @clusters can point to %NULL initially
  * and a suitable array will be allocated.  In code:
diff --git a/src/cairo-user-font.c b/src/cairo-user-font.c
index 4feb0ce..616eff0 100644
--- a/src/cairo-user-font.c
+++ b/src/cairo-user-font.c
@@ -288,6 +288,7 @@ _cairo_user_text_to_glyphs (void		      *abstract_font,
 
     if (face->scaled_font_methods.text_to_glyphs) {
 	int i;
+	cairo_glyph_t *orig_glyphs = *glyphs;
 	int orig_num_glyphs = *num_glyphs;
 
 	status = face->scaled_font_methods.text_to_glyphs (&scaled_font->base,
@@ -299,6 +300,10 @@ _cairo_user_text_to_glyphs (void		      *abstract_font,
 	    return status;
 
 	if (*num_glyphs < 0) {
+	    if (orig_glyphs != *glyphs) {
+		cairo_glyph_free (*glyphs);
+		*glyphs = orig_glyphs;
+	    }
 	    *num_glyphs = orig_num_glyphs;
 	    return CAIRO_INT_STATUS_UNSUPPORTED;
 	}
diff --git a/src/cairo.h b/src/cairo.h
index 0cff8d9..55ea2d6 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -1546,7 +1546,7 @@ typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t) (cairo_scal
  * If the value @clusters points at has changed after the call, the caller
  * will free the allocated cluster array using cairo_text_cluster_free().
  *
- * The callback is optional.  If not set, or if @num_glyphs is negative upon
+ * The callback is optional.  If @num_glyphs is negative upon
  * the callback returning, the unicode_to_glyph callback
  * is tried.  See #cairo_user_scaled_font_unicode_to_glyph_func_t.
  *


More information about the cairo-commit mailing list