poppler/Annot.cc | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
New commits: commit d31080d8195694cef740d4e77484179bb38d1f26 Author: Albert Astals Cid <[email protected]> Date: Sun Sep 20 17:21:13 2009 +0200 CharCodeToUnicode is not mandatory in fonts, don't crash one fonts that do not have it Fixes bug #24036 diff --git a/poppler/Annot.cc b/poppler/Annot.cc index 5832f67..c9b8dcf 100644 --- a/poppler/Annot.cc +++ b/poppler/Annot.cc @@ -2232,8 +2232,6 @@ void AnnotWidget::layoutText(GooString *text, GooString *outBuf, int *i, int uLen, n; double dx, dy, ox, oy; GBool unicode = text->hasUnicodeMarker(); - CharCodeToUnicode *ccToUnicode = font->getToUnicode(); - ccToUnicode->decRefCnt(); GBool spacePrev; // previous character was a space // State for backtracking when more text has been processed than fits within @@ -2297,19 +2295,28 @@ void AnnotWidget::layoutText(GooString *text, GooString *outBuf, int *i, if (noReencode) { outBuf->append(uChar); - } else if (ccToUnicode->mapToCharCode(&uChar, &c, 1)) { - if (font->isCIDFont()) { - // TODO: This assumes an identity CMap. It should be extended to - // handle the general case. - outBuf->append((c >> 8) & 0xff); - outBuf->append(c & 0xff); + } else { + CharCodeToUnicode *ccToUnicode = font->getToUnicode(); + if (!ccToUnicode) { + // This assumes an identity CMap. + outBuf->append((uChar >> 8) & 0xff); + outBuf->append(uChar & 0xff); + } else if (ccToUnicode->mapToCharCode(&uChar, &c, 1)) { + ccToUnicode->decRefCnt(); + if (font->isCIDFont()) { + // TODO: This assumes an identity CMap. It should be extended to + // handle the general case. + outBuf->append((c >> 8) & 0xff); + outBuf->append(c & 0xff); + } else { + // 8-bit font + outBuf->append(c); + } } else { - // 8-bit font - outBuf->append(c); + ccToUnicode->decRefCnt(); + fprintf(stderr, + "warning: layoutText: cannot convert U+%04X\n", uChar); } - } else { - fprintf(stderr, - "warning: layoutText: cannot convert U+%04X\n", uChar); } // If we see a space, then we have a linebreak opportunity. _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
