[cairo-commit] 2 commits - doc/public src/cairo.h src/cairo-misc.c src/cairo-surface.c src/cairo-user-font.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed May 6 17:32:22 PDT 2009


 doc/public/tmpl/cairo-status.sgml |    2 +-
 src/cairo-misc.c                  |    2 ++
 src/cairo-surface.c               |    1 +
 src/cairo-user-font.c             |   14 +++++++++++---
 src/cairo.h                       |   25 ++++++++++++++-----------
 5 files changed, 29 insertions(+), 15 deletions(-)

New commits:
commit 428fb58a4c96391f96f48026be49a4533cd12834
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Apr 28 15:03:53 2009 -0400

    [user-font] Add CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED
    
    This is useful for language bindings to signal that a method is not
    implemented.

diff --git a/src/cairo-misc.c b/src/cairo-misc.c
index d4b10e1..20f0ef1 100644
--- a/src/cairo-misc.c
+++ b/src/cairo-misc.c
@@ -123,6 +123,8 @@ cairo_status_to_string (cairo_status_t status)
 	return "invalid value for an input #cairo_font_weight_t";
     case CAIRO_STATUS_INVALID_SIZE:
 	return "invalid value for the size of the input (surface, pattern, etc.)";
+    case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED:
+	return "user-font method not implemented";
     default:
     case CAIRO_STATUS_LAST_STATUS:
 	return "<unknown error status>";
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index a4a7084..42b101a 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2975,6 +2975,7 @@ _cairo_surface_create_in_error (cairo_status_t status)
     case CAIRO_STATUS_INVALID_SLANT:
     case CAIRO_STATUS_INVALID_WEIGHT:
     case CAIRO_STATUS_INVALID_SIZE:
+    case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED:
     default:
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_surface_t *) &_cairo_surface_nil;
diff --git a/src/cairo-user-font.c b/src/cairo-user-font.c
index fe475ab..6b4f0d4 100644
--- a/src/cairo-user-font.c
+++ b/src/cairo-user-font.c
@@ -118,7 +118,7 @@ _cairo_user_scaled_glyph_init (void			 *abstract_font,
 							     _cairo_scaled_glyph_index(scaled_glyph),
 							     cr, &extents);
 	else
-	    status = CAIRO_STATUS_USER_FONT_ERROR;
+	    status = CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED;
 
 	if (status == CAIRO_STATUS_SUCCESS)
 	    status = cairo_status (cr);
@@ -260,12 +260,16 @@ _cairo_user_ucs4_to_index (void	    *abstract_font,
 	status = face->scaled_font_methods.unicode_to_glyph (&scaled_font->base,
 							     ucs4, &glyph);
 
+	if (status == CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED)
+	    goto not_implemented;
+
 	if (status != CAIRO_STATUS_SUCCESS) {
 	    status = _cairo_scaled_font_set_error (&scaled_font->base, status);
 	    glyph = 0;
 	}
 
     } else {
+not_implemented:
 	glyph = ucs4;
     }
 
@@ -300,10 +304,11 @@ _cairo_user_text_to_glyphs (void		      *abstract_font,
 							   glyphs, num_glyphs,
 							   clusters, num_clusters, cluster_flags);
 
-	if (status != CAIRO_STATUS_SUCCESS)
+	if (status != CAIRO_STATUS_SUCCESS &&
+	    status != CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED)
 	    return status;
 
-	if (*num_glyphs < 0) {
+	if (status == CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED || *num_glyphs < 0) {
 	    if (orig_glyphs != *glyphs) {
 		cairo_glyph_free (*glyphs);
 		*glyphs = orig_glyphs;
@@ -434,6 +439,9 @@ _cairo_user_font_face_scaled_font_create (void                        *abstract_
 							  cr,
 							  &font_extents);
 
+	    if (status == CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED)
+		status = CAIRO_STATUS_SUCCESS;
+
 	    if (status == CAIRO_STATUS_SUCCESS)
 		status = cairo_status (cr);
 
diff --git a/src/cairo.h b/src/cairo.h
index 58f1cd0..a92c26c 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -240,6 +240,7 @@ typedef struct _cairo_user_data_key {
  * @CAIRO_STATUS_INVALID_SLANT: invalid value for an input #cairo_font_slant_t (Since 1.8)
  * @CAIRO_STATUS_INVALID_WEIGHT: invalid value for an input #cairo_font_weight_t (Since 1.8)
  * @CAIRO_STATUS_INVALID_SIZE: invalid value (typically too big) for a size (Since 1.10)
+ * @CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: user-font method not implemented (Since 1.10)
  * @CAIRO_STATUS_LAST_STATUS: this is a special value indicating the number of
  *   status values defined in this enumeration.  When using this value, note
  *   that the version of cairo at run-time may have additional status values
@@ -288,6 +289,7 @@ typedef enum _cairo_status {
     CAIRO_STATUS_INVALID_SLANT,
     CAIRO_STATUS_INVALID_WEIGHT,
     CAIRO_STATUS_INVALID_SIZE,
+    CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED,
 
     CAIRO_STATUS_LAST_STATUS
 } cairo_status_t;
@@ -1453,8 +1455,7 @@ cairo_user_font_face_create (void);
  * point and trying to use it for text operations in the callback will result
  * in deadlock.
  *
- * Returns: %CAIRO_STATUS_SUCCESS upon success, or
- * %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
+ * Returns: %CAIRO_STATUS_SUCCESS upon success, or an error status on error.
  *
  * Since: 1.8
  **/
@@ -1555,7 +1556,8 @@ typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t) (cairo_scal
  * will free the allocated cluster array using cairo_text_cluster_free().
  *
  * The callback is optional.  If @num_glyphs is negative upon
- * the callback returning, the unicode_to_glyph callback
+ * the callback returning or if the return value
+ * isCAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, the unicode_to_glyph callback
  * is tried.  See #cairo_user_scaled_font_unicode_to_glyph_func_t.
  *
  * Note: While cairo does not impose any limitation on glyph indices,
@@ -1566,8 +1568,9 @@ typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t) (cairo_scal
  * are advised to use glyph 0 for such purposes and do not use that
  * glyph value for other purposes.
  *
- * Returns: %CAIRO_STATUS_SUCCESS upon success, or
- * %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
+ * Returns: %CAIRO_STATUS_SUCCESS upon success,
+ * CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED if fallback options should be tried,
+ * or %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
  *
  * Since: 1.8
  **/
@@ -1600,8 +1603,9 @@ typedef cairo_status_t (*cairo_user_scaled_font_text_to_glyphs_func_t) (cairo_sc
  * complex scripts can be implemented using this callback.
  *
  * The callback is optional, and only used if text_to_glyphs callback is not
- * set or fails to return glyphs.  If this callback is not set, an identity
- * mapping from Unicode code-points to glyph indices is assumed.
+ * set or fails to return glyphs.  If this callback is not set or if it returns
+ * CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, an identity mapping from Unicode
+ * code-points to glyph indices is assumed.
  *
  * Note: While cairo does not impose any limitation on glyph indices,
  * some applications may assume that a glyph index fits in a 16-bit
@@ -1611,8 +1615,9 @@ typedef cairo_status_t (*cairo_user_scaled_font_text_to_glyphs_func_t) (cairo_sc
  * are advised to use glyph 0 for such purposes and do not use that
  * glyph value for other purposes.
  *
- * Returns: %CAIRO_STATUS_SUCCESS upon success, or
- * %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
+ * Returns: %CAIRO_STATUS_SUCCESS upon success,
+ * CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED if fallback options should be tried,
+ * or %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
  *
  * Since: 1.8
  **/
commit f9573d03dde2c38674d36b783044715ab5104b0a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Mar 17 19:48:12 2009 -0400

    Err, make gtk-doc happy again

diff --git a/doc/public/tmpl/cairo-status.sgml b/doc/public/tmpl/cairo-status.sgml
index b74856f..e8ad969 100644
--- a/doc/public/tmpl/cairo-status.sgml
+++ b/doc/public/tmpl/cairo-status.sgml
@@ -71,7 +71,7 @@ code is required before or after each individual cairo function call.
 @CAIRO_STATUS_INVALID_SLANT: 
 @CAIRO_STATUS_INVALID_WEIGHT: 
 @CAIRO_STATUS_INVALID_SIZE: 
- at _CAIRO_STATUS_LAST_STATUS: 
+ at CAIRO_STATUS_LAST_STATUS:
 
 <!-- ##### FUNCTION cairo_status_to_string ##### -->
 <para>
diff --git a/src/cairo.h b/src/cairo.h
index 1347187..58f1cd0 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -208,7 +208,6 @@ typedef struct _cairo_user_data_key {
 /**
  * cairo_status_t:
  * @CAIRO_STATUS_SUCCESS: no error has occurred
- *
  * @CAIRO_STATUS_NO_MEMORY: out of memory
  * @CAIRO_STATUS_INVALID_RESTORE: cairo_restore() called without matching cairo_save()
  * @CAIRO_STATUS_INVALID_POP_GROUP: no saved group to pop
@@ -241,7 +240,6 @@ typedef struct _cairo_user_data_key {
  * @CAIRO_STATUS_INVALID_SLANT: invalid value for an input #cairo_font_slant_t (Since 1.8)
  * @CAIRO_STATUS_INVALID_WEIGHT: invalid value for an input #cairo_font_weight_t (Since 1.8)
  * @CAIRO_STATUS_INVALID_SIZE: invalid value (typically too big) for a size (Since 1.10)
- *
  * @CAIRO_STATUS_LAST_STATUS: this is a special value indicating the number of
  *   status values defined in this enumeration.  When using this value, note
  *   that the version of cairo at run-time may have additional status values


More information about the cairo-commit mailing list