diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2020-06-04 16:14:20 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2020-06-17 09:23:50 +0100 |
commit | 0a4f6d6cb3efda8f0b334c0b04457362b00dac1b (patch) | |
tree | 223fb190e1f0abe652f2cfbfe77898fb1e371cb7 /xps | |
parent | 8384e88e02cefa3de112546838a752d7f0a7a5c1 (diff) | |
download | ghostpdl-0a4f6d6cb3efda8f0b334c0b04457362b00dac1b.tar.gz |
Revisions to FAPI (error handling etc).
A lot of the FAPI methods made no account for errors (i.e. a call to return an
unsigned 16 bit value would return an unsigned short int). In various places
that meant we ended up using unlikely (in practice, impossible, yet still
"valid") values to indicate an error condition.
This commit changes those calls to have a conventional Ghostscript "int"
return value and (mostly) take pointer to the storage into which they should
write their value. We can now return meaninful error codes.
Secondly, in several places, the FAPI methods and code used integers to store
character codes, cids, gids etc. This is less than ideal because we potentially
have to handle 4 byte codes (especially for gids), and we also use some
special 64 bit values (when available) for specific meanings. There were
several workarounds for that, in various places.
This commit also changes the FAPI API and code to the gs_glyph type for all
such values, removing the need for those workarounds
Diffstat (limited to 'xps')
-rw-r--r-- | xps/xpsfapi.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/xps/xpsfapi.c b/xps/xpsfapi.c index 7d66b26cc..bf158dc92 100644 --- a/xps/xpsfapi.c +++ b/xps/xpsfapi.c @@ -25,14 +25,14 @@ #include "xpsfapi.h" /* forward declarations for the pl_ff_stub definition */ -static ulong -xps_fapi_get_long(gs_fapi_font *ff, gs_fapi_font_feature var_id, int index); +static int +xps_fapi_get_long(gs_fapi_font *ff, gs_fapi_font_feature var_id, int index, unsigned long *ret); static int -xps_fapi_get_glyph(gs_fapi_font *ff, int char_code, byte *buf, - ushort buf_length); +xps_fapi_get_glyph(gs_fapi_font *ff, gs_glyph char_code, byte *buf, + int buf_length); -static ushort +static int xps_fapi_serialize_tt_font(gs_fapi_font *ff, void *buf, int buf_size); static int @@ -41,12 +41,12 @@ xps_get_glyphdirectory_data(gs_fapi_font *ff, int char_code, static int xps_fapi_set_cache(gs_text_enum_t *penum, const gs_font_base *pbfont, - const gs_string *char_name, int cid, + const gs_string *char_name, gs_glyph cid, const double pwidth[2], const gs_rect *pbbox, const double Metrics2_sbw_default[4], bool *imagenow); static int -xps_fapi_get_metrics(gs_fapi_font *ff, gs_string *char_name, int cid, +xps_fapi_get_metrics(gs_fapi_font *ff, gs_string *char_name, gs_glyph cid, double *m, bool vertical); static const gs_fapi_font pl_ff_stub = { @@ -92,8 +92,8 @@ static const gs_fapi_font pl_ff_stub = { xps_fapi_set_cache /* fapi_set_cache */ }; -static ulong -xps_fapi_get_long(gs_fapi_font *ff, gs_fapi_font_feature var_id, int index) +static int +xps_fapi_get_long(gs_fapi_font *ff, gs_fapi_font_feature var_id, int index, unsigned long *ret) { ulong value = -1; @@ -101,20 +101,20 @@ xps_fapi_get_long(gs_fapi_font *ff, gs_fapi_font_feature var_id, int index) } static int -xps_fapi_get_glyph(gs_fapi_font *ff, int char_code, byte *buf, - ushort buf_length) +xps_fapi_get_glyph(gs_fapi_font *ff, gs_glyph char_code, byte *buf, + int buf_length) { int size = -1; return (size); } -static ushort +static int xps_fapi_serialize_tt_font(gs_fapi_font *ff, void *buf, int buf_size) { int code = -1; - return ((ushort) code); + return (code); } static int @@ -125,7 +125,7 @@ xps_get_glyphdirectory_data(gs_fapi_font *ff, int char_code, } static int -xps_fapi_get_metrics(gs_fapi_font *ff, gs_string *char_name, int cid, +xps_fapi_get_metrics(gs_fapi_font *ff, gs_string *char_name, gs_glyph cid, double *m, bool vertical) { return (0); @@ -133,7 +133,7 @@ xps_fapi_get_metrics(gs_fapi_font *ff, gs_string *char_name, int cid, static int xps_fapi_set_cache(gs_text_enum_t *penum, const gs_font_base *pbfont, - const gs_string *char_name, int cid, + const gs_string *char_name, gs_glyph cid, const double pwidth[2], const gs_rect *pbbox, const double Metrics2_sbw_default[4], bool *imagenow) { |