[poppler] Branch 'poppler-0.12' - poppler/Annot.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Sun Sep 20 08:22:36 PDT 2009
poppler/Annot.cc | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
New commits:
commit 5df1e583a2349868a0060138d3a184a9a6eb1b58
Author: Albert Astals Cid <aacid at kde.org>
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.
More information about the poppler
mailing list