summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2012-02-23 22:56:17 +0100
committerAlbert Astals Cid <aacid@kde.org>2012-02-23 22:56:17 +0100
commit30446bdd7e202eed88d131e04477c76861fd145c (patch)
tree1d54d9c60abbf07761a200ff45ba664ee7ff9c80
parent71104f1ec55d3be999afaa1b62405454b31066a9 (diff)
Use an Identity CharCodeToUnicode for Adobe-Identity and Adobe-UCS collections
Also fix Identity CharCodeToUnicode code Bug #35468
-rw-r--r--poppler/CharCodeToUnicode.cc18
-rw-r--r--poppler/CharCodeToUnicode.h7
-rw-r--r--poppler/GfxFont.cc13
3 files changed, 25 insertions, 13 deletions
diff --git a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc
index e44f3048..076f5ba9 100644
--- a/poppler/CharCodeToUnicode.cc
+++ b/poppler/CharCodeToUnicode.cc
@@ -13,7 +13,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2006, 2008-2010 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006, 2008-2010, 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
@@ -111,7 +111,11 @@ static GBool parseHex(char *s, int len, Guint *val) {
//------------------------------------------------------------------------
CharCodeToUnicode *CharCodeToUnicode::makeIdentityMapping() {
- return new CharCodeToUnicode();
+ CharCodeToUnicode *ctu = new CharCodeToUnicode();
+ ctu->isIdentity = gTrue;
+ ctu->mapLen = 1;
+ ctu->map = (Unicode *)gmallocn(ctu->mapLen, sizeof(Unicode));
+ return ctu;
}
CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(GooString *fileName,
@@ -468,6 +472,7 @@ CharCodeToUnicode::CharCodeToUnicode() {
sMap = NULL;
sMapLen = sMapSize = 0;
refCnt = 1;
+ isIdentity = gFalse;
#if MULTITHREADED
gInitMutex(&mutex);
#endif
@@ -485,6 +490,7 @@ CharCodeToUnicode::CharCodeToUnicode(GooString *tagA) {
sMap = NULL;
sMapLen = sMapSize = 0;
refCnt = 1;
+ isIdentity = gFalse;
#if MULTITHREADED
gInitMutex(&mutex);
#endif
@@ -506,6 +512,7 @@ CharCodeToUnicode::CharCodeToUnicode(GooString *tagA, Unicode *mapA,
sMapLen = sMapLenA;
sMapSize = sMapSizeA;
refCnt = 1;
+ isIdentity = gFalse;
#if MULTITHREADED
gInitMutex(&mutex);
#endif
@@ -557,7 +564,7 @@ GBool CharCodeToUnicode::match(GooString *tagA) {
void CharCodeToUnicode::setMapping(CharCode c, Unicode *u, int len) {
int i, j;
- if (!map) {
+ if (!map || isIdentity) {
return;
}
if (len == 1) {
@@ -590,8 +597,9 @@ void CharCodeToUnicode::setMapping(CharCode c, Unicode *u, int len) {
int CharCodeToUnicode::mapToUnicode(CharCode c, Unicode **u) {
int i;
- if (!map) {
- *u[0] = (Unicode)c;
+ if (isIdentity) {
+ map[0] = (Unicode)c;
+ *u = map;
return 1;
}
if (c >= mapLen) {
diff --git a/poppler/CharCodeToUnicode.h b/poppler/CharCodeToUnicode.h
index 66417a14..1672105a 100644
--- a/poppler/CharCodeToUnicode.h
+++ b/poppler/CharCodeToUnicode.h
@@ -17,7 +17,7 @@
//
// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
-// Copyright (C) 2008, 2011 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2008, 2011, 2012 Albert Astals Cid <aacid@kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -86,7 +86,9 @@ public:
// Set the mapping for <c>.
void setMapping(CharCode c, Unicode *u, int len);
- // Map a CharCode to Unicode.
+ // Map a CharCode to Unicode. Returns a pointer in u to internal storage
+ // so never store the pointers it returns, just the data, otherwise
+ // your pointed values might get changed by future calls
int mapToUnicode(CharCode c, Unicode **u);
// Map a Unicode to CharCode.
@@ -113,6 +115,7 @@ private:
CharCodeToUnicodeString *sMap;
int sMapLen, sMapSize;
int refCnt;
+ GBool isIdentity;
#if MULTITHREADED
GooMutex mutex;
#endif
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index cc0f0926..0f3d248e 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -13,7 +13,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2005, 2006, 2008-2010 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2005, 2006, 2008-2010, 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
@@ -1785,11 +1785,12 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA,
if (!(ctu = readToUnicodeCMap(fontDict, 16, NULL))) {
ctuUsesCharCode = gFalse;
- // the "Adobe-Identity" and "Adobe-UCS" collections don't have
- // cidToUnicode files
- if (collection->cmp("Adobe-Identity") &&
- collection->cmp("Adobe-UCS")) {
-
+ // use an identity mapping for the "Adobe-Identity" and
+ // "Adobe-UCS" collections
+ if (!collection->cmp("Adobe-Identity") ||
+ !collection->cmp("Adobe-UCS")) {
+ ctu = CharCodeToUnicode::makeIdentityMapping();
+ } else {
// look for a user-supplied .cidToUnicode file
if (!(ctu = globalParams->getCIDToUnicode(collection))) {
// I'm not completely sure that this is the best thing to do