mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-01 13:47:59 +02:00
[user-font] Add CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED
This is useful for language bindings to signal that a method is not implemented.
This commit is contained in:
parent
f9573d03dd
commit
428fb58a4c
4 changed files with 28 additions and 12 deletions
|
|
@ -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>";
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
23
src/cairo.h
23
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
|
||||
**/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue