diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2009-04-28 15:03:53 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2009-05-06 20:31:04 -0400 |
commit | 428fb58a4c96391f96f48026be49a4533cd12834 (patch) | |
tree | 3294eee3aa332bd8d58f0518094663d80221ec8c /src | |
parent | f9573d03dde2c38674d36b783044715ab5104b0a (diff) |
[user-font] Add CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED
This is useful for language bindings to signal that a method is not
implemented.
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-misc.c | 2 | ||||
-rw-r--r-- | src/cairo-surface.c | 1 | ||||
-rw-r--r-- | src/cairo-user-font.c | 14 | ||||
-rw-r--r-- | src/cairo.h | 23 |
4 files changed, 28 insertions, 12 deletions
diff --git a/src/cairo-misc.c b/src/cairo-misc.c index d4b10e1c..20f0ef1b 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 a4a70846..42b101ac 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 fe475ab4..6b4f0d43 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 58f1cd0e..a92c26c4 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 **/ |