diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2018-08-28 14:53:49 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2018-08-28 14:53:49 +0100 |
commit | 21ae2f8d9953ffe8d6c8f1b2bf72a14b54d50e74 (patch) | |
tree | 01602e485d643d6543dc6ddb40eebd14d56568eb | |
parent | 7a702103b4490e370b36587c34b8b549a75ef3a5 (diff) | |
download | ghostpdl-21ae2f8d9953ffe8d6c8f1b2bf72a14b54d50e74.tar.gz |
Bug 699682: Handle text from single "gs_glyph" or "gs_char"
In the FAPI code, when dealing a substituted cidfont, we extract the original
character code, and decode that using the ToUnicode CMap, in order to get a
Unicode code point we can then put through the TTF Unicode cmap table - thus
improving the chances of getting a legible result.
It failed to account for the possiblity that we were dealing with a single
character code stored directly, rather than a string of 1 or more codes in a
buffer - derefencing an invalid pointer.
Add code to handle those cases.
-rw-r--r-- | psi/zfapi.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/psi/zfapi.c b/psi/zfapi.c index 8e1e460a8..6a1c94c0e 100644 --- a/psi/zfapi.c +++ b/psi/zfapi.c @@ -2283,10 +2283,16 @@ ps_get_glyphname_or_cid(gs_text_enum_t *penum, unsigned char uc[4] = {0}; unsigned int cc = 0; int i, l; - byte *c = (byte *)&penum->text.data.bytes[penum->index - penum->bytes_decoded]; - - for (i = 0; i < penum->bytes_decoded ; i++) { - cc |= c[i] << ((penum->bytes_decoded - 1) - i) * 8; + if (penum->text.operation && TEXT_FROM_SINGLE_CHAR) { + cc = penum->text.data.d_char; + } else if (penum->text.operation && TEXT_FROM_SINGLE_GLYPH) { + cc = penum->text.data.d_glyph - GS_MIN_CID_GLYPH; + } + else { + byte *c = (byte *)&penum->text.data.bytes[penum->index - penum->bytes_decoded]; + for (i = 0; i < penum->bytes_decoded ; i++) { + cc |= c[i] << ((penum->bytes_decoded - 1) - i) * 8; + } } l = ((gs_font_base *)gs_rootfont(igs))->procs.decode_glyph(gs_rootfont(igs), cc + GS_MIN_CID_GLYPH, ccode, (unsigned short *)uc, sizeof(uc)); if (l > 0 && l < sizeof(uc)) { |