Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add CAIRO_STATUS_FREETYPE_ERROR for errors returned by libfreetype
  • Loading branch information
Adrian Johnson committed Mar 26, 2016
1 parent 8f67901 commit cdd5c92
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/cairo-device.c
Expand Up @@ -160,6 +160,7 @@ _cairo_device_create_in_error (cairo_status_t status)
case CAIRO_STATUS_DEVICE_FINISHED:
case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
case CAIRO_STATUS_PNG_ERROR:
case CAIRO_STATUS_FREETYPE_ERROR:
default:
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_device_t *) &_nil_device;
Expand Down
1 change: 1 addition & 0 deletions src/cairo-error-private.h
Expand Up @@ -95,6 +95,7 @@ enum _cairo_int_status {
CAIRO_INT_STATUS_DEVICE_FINISHED,
CAIRO_INT_STATUS_JBIG2_GLOBAL_MISSING,
CAIRO_INT_STATUS_PNG_ERROR,
CAIRO_INT_STATUS_FREETYPE_ERROR,

CAIRO_INT_STATUS_LAST_STATUS,

Expand Down
5 changes: 4 additions & 1 deletion src/cairo-ft-font.c
Expand Up @@ -223,7 +223,10 @@ _ft_to_cairo_error (FT_Error error)
* Populate as needed. */
switch (error)
{
default: return CAIRO_STATUS_NO_MEMORY;
case FT_Err_Out_Of_Memory:
return CAIRO_STATUS_NO_MEMORY;
default:
return CAIRO_STATUS_FREETYPE_ERROR;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/cairo-misc.c
Expand Up @@ -160,6 +160,8 @@ cairo_status_to_string (cairo_status_t status)
return "CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID used but no CAIRO_MIME_TYPE_JBIG2_GLOBAL data provided";
case CAIRO_STATUS_PNG_ERROR:
return "error occurred in libpng while reading from or writing to a PNG file";
case CAIRO_STATUS_FREETYPE_ERROR:
return "error occurred in libfreetype";
default:
case CAIRO_STATUS_LAST_STATUS:
return "<unknown error status>";
Expand Down
1 change: 1 addition & 0 deletions src/cairo-region.c
Expand Up @@ -108,6 +108,7 @@ _cairo_region_create_in_error (cairo_status_t status)
case CAIRO_STATUS_DEVICE_FINISHED:
case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
case CAIRO_STATUS_PNG_ERROR:
case CAIRO_STATUS_FREETYPE_ERROR:
default:
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_region_t *) &_cairo_region_nil;
Expand Down
2 changes: 2 additions & 0 deletions src/cairo-spans.c
Expand Up @@ -129,6 +129,7 @@ _cairo_scan_converter_create_in_error (cairo_status_t status)
case CAIRO_STATUS_DEVICE_FINISHED: RETURN_NIL;
case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
case CAIRO_STATUS_PNG_ERROR:
case CAIRO_STATUS_FREETYPE_ERROR:
default:
break;
}
Expand Down Expand Up @@ -243,6 +244,7 @@ _cairo_span_renderer_create_in_error (cairo_status_t status)
case CAIRO_STATUS_DEVICE_FINISHED: RETURN_NIL;
case CAIRO_STATUS_JBIG2_GLOBAL_MISSING: RETURN_NIL;
case CAIRO_STATUS_PNG_ERROR: RETURN_NIL;
case CAIRO_STATUS_FREETYPE_ERROR: RETURN_NIL;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/cairo-surface.c
Expand Up @@ -2726,6 +2726,7 @@ _cairo_surface_create_in_error (cairo_status_t status)
case CAIRO_STATUS_DEVICE_FINISHED:
case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
case CAIRO_STATUS_PNG_ERROR:
case CAIRO_STATUS_FREETYPE_ERROR:
default:
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_surface_t *) &_cairo_surface_nil;
Expand Down
3 changes: 2 additions & 1 deletion src/cairo.c
Expand Up @@ -154,7 +154,8 @@ static const cairo_t _cairo_nil[] = {
DEFINE_NIL_CONTEXT (CAIRO_STATUS_INVALID_MESH_CONSTRUCTION),
DEFINE_NIL_CONTEXT (CAIRO_STATUS_DEVICE_FINISHED),
DEFINE_NIL_CONTEXT (CAIRO_STATUS_JBIG2_GLOBAL_MISSING),
DEFINE_NIL_CONTEXT (CAIRO_STATUS_PNG_ERROR)
DEFINE_NIL_CONTEXT (CAIRO_STATUS_PNG_ERROR),
DEFINE_NIL_CONTEXT (CAIRO_STATUS_FREETYPE_ERROR)

};
COMPILE_TIME_ASSERT (ARRAY_LENGTH (_cairo_nil) == CAIRO_STATUS_LAST_STATUS - 1);
Expand Down
2 changes: 2 additions & 0 deletions src/cairo.h
Expand Up @@ -293,6 +293,7 @@ typedef struct _cairo_user_data_key {
* @CAIRO_STATUS_JBIG2_GLOBAL_MISSING: %CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID has been used on at least one image
* but no image provided %CAIRO_MIME_TYPE_JBIG2_GLOBAL (Since 1.14)
* @CAIRO_STATUS_PNG_ERROR: error occurred in libpng while reading from or writing to a PNG file (Since 1.16)
* @CAIRO_STATUS_FREETYPE_ERROR: error occurred in libfreetype (Since 1.16)
* @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
Expand Down Expand Up @@ -350,6 +351,7 @@ typedef enum _cairo_status {
CAIRO_STATUS_DEVICE_FINISHED,
CAIRO_STATUS_JBIG2_GLOBAL_MISSING,
CAIRO_STATUS_PNG_ERROR,
CAIRO_STATUS_FREETYPE_ERROR,

CAIRO_STATUS_LAST_STATUS
} cairo_status_t;
Expand Down
1 change: 1 addition & 0 deletions util/cairo-gobject/cairo-gobject-enums.c
Expand Up @@ -53,6 +53,7 @@ cairo_gobject_status_get_type (void)
{ CAIRO_STATUS_DEVICE_FINISHED, "CAIRO_STATUS_DEVICE_FINISHED", "device-finished" },
{ CAIRO_STATUS_JBIG2_GLOBAL_MISSING, "CAIRO_STATUS_JBIG2_GLOBAL_MISSING", "jbig2-global_missing" },
{ CAIRO_STATUS_PNG_ERROR, "CAIRO_STATUS_PNG_ERROR", "png-error" },
{ CAIRO_STATUS_FREETYPE_ERROR, "CAIRO_STATUS_FREETYPE_ERROR", "freetype-error" },
{ CAIRO_STATUS_LAST_STATUS, "CAIRO_STATUS_LAST_STATUS", "last-status" },
{ 0, NULL, NULL }
};
Expand Down
2 changes: 2 additions & 0 deletions util/cairo-script/cairo-script-private.h
Expand Up @@ -227,6 +227,8 @@ typedef enum _csi_status {
CSI_STATUS_DEVICE_FINISHED = CAIRO_STATUS_DEVICE_FINISHED,
CSI_STATUS_JBIG2_GLOBAL_MISSING = CAIRO_STATUS_JBIG2_GLOBAL_MISSING,
CSI_STATUS_PNG_ERROR = CAIRO_STATUS_PNG_ERROR,
CSI_STATUS_FREETYPE_ERROR = CAIRO_STATUS_FREETYPE_ERROR,


/* cairo-script-interpreter specific errors */

Expand Down
1 change: 1 addition & 0 deletions util/cairo-trace/trace.c
Expand Up @@ -1583,6 +1583,7 @@ _status_to_string (cairo_status_t status)
f(DEVICE_FINISHED);
f(JBIG2_GLOBAL_MISSING);
f(PNG_ERROR);
f(FREETYPE_ERROR);
case CAIRO_STATUS_LAST_STATUS:
break;
}
Expand Down

0 comments on commit cdd5c92

Please sign in to comment.