[poppler] Branch 'xpdf303merge' - 7 commits - poppler/CMap.cc poppler/CMap.h poppler/GfxFont.cc poppler/JArithmeticDecoder.cc poppler/JArithmeticDecoder.h poppler/XRef.h splash/SplashFontEngine.cc splash/SplashFTFont.cc splash/SplashT1Font.cc utils/ImageOutputDev.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Thu Sep 1 08:32:23 PDT 2011
poppler/CMap.cc | 47 +++++++++++++++++++++++++++---------------
poppler/CMap.h | 8 ++++---
poppler/GfxFont.cc | 6 +++--
poppler/JArithmeticDecoder.cc | 47 +++++++++++++++++++++++++++++++++++-------
poppler/JArithmeticDecoder.h | 4 +++
poppler/XRef.h | 2 -
splash/SplashFTFont.cc | 8 +++----
splash/SplashFontEngine.cc | 2 -
splash/SplashT1Font.cc | 2 -
utils/ImageOutputDev.cc | 21 ++++++++++++------
10 files changed, 105 insertions(+), 42 deletions(-)
New commits:
commit 19204ed5cd5cb64809f1a1f51dd5ffdef2b9417a
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Sep 1 17:28:39 2011 +0200
xpdf303: CMap::getCID signature change
diff --git a/poppler/CMap.cc b/poppler/CMap.cc
index 884b5c5..357b0f0 100644
--- a/poppler/CMap.cc
+++ b/poppler/CMap.cc
@@ -188,6 +188,7 @@ CMap::CMap(GooString *collectionA, GooString *cMapNameA) {
collection = collectionA;
cMapName = cMapNameA;
+ isIdent = gFalse;
wMode = 0;
vector = (CMapVectorEntry *)gmallocn(256, sizeof(CMapVectorEntry));
for (i = 0; i < 256; ++i) {
@@ -203,6 +204,7 @@ CMap::CMap(GooString *collectionA, GooString *cMapNameA) {
CMap::CMap(GooString *collectionA, GooString *cMapNameA, int wModeA) {
collection = collectionA;
cMapName = cMapNameA;
+ isIdent = gTrue;
wMode = wModeA;
vector = NULL;
refCnt = 1;
@@ -216,12 +218,23 @@ void CMap::useCMap(CMapCache *cache, char *useName) {
CMap *subCMap;
useNameStr = new GooString(useName);
- subCMap = cache->getCMap(collection, useNameStr, NULL);
+ // if cache is non-NULL, we already have a lock, and we can use
+ // CMapCache::getCMap() directly; otherwise, we need to use
+ // GlobalParams::getCMap() in order to acqure the lock need to use
+ // GlobalParams::getCMap
+ if (cache) {
+ subCMap = cache->getCMap(collection, useNameStr, NULL);
+ } else {
+ subCMap = globalParams->getCMap(collection, useNameStr);
+ }
delete useNameStr;
if (!subCMap) {
return;
}
- copyVector(vector, subCMap->vector);
+ isIdent = subCMap->isIdent;
+ if (subCMap->vector) {
+ copyVector(vector, subCMap->vector);
+ }
subCMap->decRefCnt();
}
@@ -356,31 +369,33 @@ GBool CMap::match(GooString *collectionA, GooString *cMapNameA) {
return !collection->cmp(collectionA) && !cMapName->cmp(cMapNameA);
}
-CID CMap::getCID(char *s, int len, int *nUsed) {
+CID CMap::getCID(char *s, int len, CharCode *c, int *nUsed) {
CMapVectorEntry *vec;
+ CharCode cc;
int n, i;
- if (!(vec = vector)) {
- // identity CMap
- *nUsed = 2;
- if (len < 2) {
- return 0;
- }
- return ((s[0] & 0xff) << 8) + (s[1] & 0xff);
- }
+ vec = vector;
+ cc = 0;
n = 0;
- while (1) {
- if (n >= len) {
- *nUsed = n;
- return 0;
- }
+ while (vec && n < len) {
i = s[n++] & 0xff;
+ cc = (cc << 8) | i;
if (!vec[i].isVector) {
+ *c = cc;
*nUsed = n;
return vec[i].cid;
}
vec = vec[i].vector;
}
+ if (isIdent && len >= 2) {
+ // identity CMap
+ *nUsed = 2;
+ *c = cc = ((s[0] & 0xff) << 8) + (s[1] & 0xff);
+ return cc;
+ }
+ *nUsed = 1;
+ *c = s[0] & 0xff;
+ return 0;
}
void CMap::setReverseMapVector(Guint startCode, CMapVectorEntry *vec,
diff --git a/poppler/CMap.h b/poppler/CMap.h
index 9de0a87..7803d63 100644
--- a/poppler/CMap.h
+++ b/poppler/CMap.h
@@ -67,9 +67,9 @@ public:
GBool match(GooString *collectionA, GooString *cMapNameA);
// Return the CID corresponding to the character code starting at
- // <s>, which contains <len> bytes. Sets *<nUsed> to the number of
- // bytes used by the char code.
- CID getCID(char *s, int len, int *nUsed);
+ // <s>, which contains <len> bytes. Sets *<c> to the char code, and
+ // *<nUsed> to the number of bytes used by the char code.
+ CID getCID(char *s, int len, CharCode *c, int *nUsed);
// Return the writing mode (0=horizontal, 1=vertical).
int getWMode() { return wMode; }
@@ -91,6 +91,8 @@ private:
GooString *collection;
GooString *cMapName;
+ GBool isIdent; // true if this CMap is an identity mapping,
+ // or is based on one (via usecmap)
int wMode; // writing mode (0=horizontal, 1=vertical)
CMapVectorEntry *vector; // vector for first byte (NULL for
// identity CMap)
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 79b2f0a..d81cf4f 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -1702,6 +1702,7 @@ int GfxCIDFont::getNextChar(char *s, int len, CharCode *code,
Unicode **u, int *uLen,
double *dx, double *dy, double *ox, double *oy) {
CID cid;
+ CharCode c;
double w, h, vx, vy;
int n, a, b, m;
@@ -1712,7 +1713,7 @@ int GfxCIDFont::getNextChar(char *s, int len, CharCode *code,
return 1;
}
- *code = (CharCode)(cid = cMap->getCID(s, len, &n));
+ *code = (CharCode)(cid = cMap->getCID(s, len, &c, &n));
if (ctu) {
if (hasToUnicode) {
int i = 0, c = 0;
@@ -2060,8 +2061,9 @@ double GfxCIDFont::getWidth (char* s, int len) {
int nUsed;
double w;
int a, b, m;
+ CharCode c;
- CID cid = cMap->getCID(s, len, &nUsed);
+ CID cid = cMap->getCID(s, len, &c, &nUsed);
w = widths.defWidth;
if (widths.nExceps > 0 && cid >= widths.exceps[0].first) {
commit 9c74bef77e7e1d7a8464dff43cae16bb1206665e
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Sep 1 17:04:04 2011 +0200
xpdf303: Use splashDist instead of splashSqrt
diff --git a/splash/SplashT1Font.cc b/splash/SplashT1Font.cc
index 536c560..89813de 100644
--- a/splash/SplashT1Font.cc
+++ b/splash/SplashT1Font.cc
@@ -90,7 +90,7 @@ SplashT1Font::SplashT1Font(SplashT1FontFile *fontFileA, SplashCoord *matA,
outlineID = -1;
// compute font size
- size = (float)splashSqrt(mat[2]*mat[2] + mat[3]*mat[3]);
+ size = (float)splashDist(0, 0, mat[2], mat[3]);
// transform the four corners of the font bounding box -- the min
// and max values form the bounding box of the transformed font
commit 0568d0dc3c42b68b715226e5ce0ff98d73a94ac7
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Sep 1 17:01:30 2011 +0200
xpdf303: Do the multiplication the other way around
No idea why :-D
diff --git a/splash/SplashFTFont.cc b/splash/SplashFTFont.cc
index 55a4957..d663d08 100644
--- a/splash/SplashFTFont.cc
+++ b/splash/SplashFTFont.cc
@@ -159,10 +159,10 @@ SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA,
matrix.yx = (FT_Fixed)((mat[1] / size) * 65536);
matrix.xy = (FT_Fixed)((mat[2] / size) * 65536);
matrix.yy = (FT_Fixed)((mat[3] / size) * 65536);
- textMatrix.xx = (FT_Fixed)((textMat[0] / (size * textScale)) * 65536);
- textMatrix.yx = (FT_Fixed)((textMat[1] / (size * textScale)) * 65536);
- textMatrix.xy = (FT_Fixed)((textMat[2] / (size * textScale)) * 65536);
- textMatrix.yy = (FT_Fixed)((textMat[3] / (size * textScale)) * 65536);
+ textMatrix.xx = (FT_Fixed)((textMat[0] / (textScale * size)) * 65536);
+ textMatrix.yx = (FT_Fixed)((textMat[1] / (textScale * size)) * 65536);
+ textMatrix.xy = (FT_Fixed)((textMat[2] / (textScale * size)) * 65536);
+ textMatrix.yy = (FT_Fixed)((textMat[3] / (textScale * size)) * 65536);
#endif
}
commit 3c0da502aa1d5b1acae01cf1e43fb96f5ecc11da
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Sep 1 17:00:31 2011 +0200
xpdf303: Use splashCheckDet isntead of splashAbs
diff --git a/splash/SplashFontEngine.cc b/splash/SplashFontEngine.cc
index aff059d..6e3db3d 100644
--- a/splash/SplashFontEngine.cc
+++ b/splash/SplashFontEngine.cc
@@ -297,7 +297,7 @@ SplashFont *SplashFontEngine::getFont(SplashFontFile *fontFile,
mat[1] = -(textMat[0] * ctm[1] + textMat[1] * ctm[3]);
mat[2] = textMat[2] * ctm[0] + textMat[3] * ctm[2];
mat[3] = -(textMat[2] * ctm[1] + textMat[3] * ctm[3]);
- if (splashAbs(mat[0] * mat[3] - mat[1] * mat[2]) < 0.01) {
+ if (!splashCheckDet(mat[0], mat[1], mat[2], mat[3], 0.01)) {
// avoid a singular (or close-to-singular) matrix
mat[0] = 0.01; mat[1] = 0;
mat[2] = 0; mat[3] = 0.01;
commit 2b4303c66f8de9a267413465898897fd6b0ebb17
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Sep 1 16:51:53 2011 +0200
xpdf303: Bigger fileKey
diff --git a/poppler/XRef.h b/poppler/XRef.h
index 8b77b6c..0fa49ef 100644
--- a/poppler/XRef.h
+++ b/poppler/XRef.h
@@ -154,7 +154,7 @@ private:
CryptAlgorithm encAlgorithm; // encryption algorithm
int keyLength; // length of key, in bytes
int permFlags; // permission bits
- Guchar fileKey[16]; // file decryption key
+ Guchar fileKey[32]; // file decryption key
GBool ownerPasswordOk; // true if owner password is correct
Guint prevXRefOffset; // position of prev XRef section (= next to read)
Guint mainXRefEntriesOffset; // offset of entries in main XRef table
commit 53060857e31a01413936fbe33b7032a0a325b384
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Sep 1 16:50:08 2011 +0200
xpdf303: Merge JArithmeticDecoder.*
diff --git a/poppler/JArithmeticDecoder.cc b/poppler/JArithmeticDecoder.cc
index ec0778e..d23f7ea 100644
--- a/poppler/JArithmeticDecoder.cc
+++ b/poppler/JArithmeticDecoder.cc
@@ -91,6 +91,7 @@ JArithmeticDecoder::JArithmeticDecoder() {
str = NULL;
dataLen = 0;
limitStream = gFalse;
+ nBytesRead = 0;
}
inline Guint JArithmeticDecoder::readByte() {
@@ -100,6 +101,7 @@ inline Guint JArithmeticDecoder::readByte() {
return 0xff;
}
}
+ ++nBytesRead;
return (Guint)str->getChar() & 0xff;
}
@@ -120,14 +122,40 @@ void JArithmeticDecoder::start() {
}
void JArithmeticDecoder::restart(int dataLenA) {
- int oldDataLen;
-
- oldDataLen = dataLen;
- dataLen = dataLenA;
- if (oldDataLen == -1) {
+ Guint cAdd;
+ GBool prevFF;
+ int k, nBits;
+
+ if (dataLen >= 0) {
+ dataLen = dataLenA;
+ } else if (dataLen == -1) {
+ dataLen = dataLenA;
buf1 = readByte();
- } else if (oldDataLen <= -2) {
- buf0 = readByte();
+ } else {
+ k = (-dataLen - 1) * 8 - ct;
+ dataLen = dataLenA;
+ cAdd = 0;
+ prevFF = gFalse;
+ while (k > 0) {
+ buf0 = readByte();
+ if (prevFF) {
+ cAdd += 0xfe00 - (buf0 << 9);
+ nBits = 7;
+ } else {
+ cAdd += 0xff00 - (buf0 << 8);
+ nBits = 8;
+ }
+ prevFF = buf0 == 0xff;
+ if (k > nBits) {
+ cAdd <<= nBits;
+ k -= nBits;
+ } else {
+ cAdd <<= k;
+ ct = nBits - k;
+ k = 0;
+ }
+ }
+ c += cAdd;
buf1 = readByte();
}
}
@@ -306,6 +334,11 @@ Guint JArithmeticDecoder::decodeIAID(Guint codeLen,
void JArithmeticDecoder::byteIn() {
if (buf0 == 0xff) {
if (buf1 > 0x8f) {
+ if (limitStream) {
+ buf0 = buf1;
+ buf1 = readByte();
+ c = c + 0xff00 - (buf0 << 8);
+ }
ct = 8;
} else {
buf0 = buf1;
diff --git a/poppler/JArithmeticDecoder.h b/poppler/JArithmeticDecoder.h
index 0f091b7..3c3e6fe 100644
--- a/poppler/JArithmeticDecoder.h
+++ b/poppler/JArithmeticDecoder.h
@@ -82,6 +82,9 @@ public:
Guint decodeIAID(Guint codeLen,
JArithmeticDecoderStats *stats);
+ void resetByteCounter() { nBytesRead = 0; }
+ Guint getByteCounter() { return nBytesRead; }
+
private:
Guint readByte();
@@ -100,6 +103,7 @@ private:
Guint prev; // for the integer decoder
Stream *str;
+ Guint nBytesRead;
int dataLen;
GBool limitStream;
};
commit 0722960b4cf4ce40b6bd278ac7287d64a1d70bf2
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Sep 1 16:48:31 2011 +0200
xpdf303: Do not crash if imgStr->getLine() is NULL
diff --git a/utils/ImageOutputDev.cc b/utils/ImageOutputDev.cc
index 6ca5ef4..b35869f 100644
--- a/utils/ImageOutputDev.cc
+++ b/utils/ImageOutputDev.cc
@@ -230,13 +230,20 @@ void ImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
for (y = 0; y < height; ++y) {
// write the line
- p = imgStr->getLine();
- for (x = 0; x < width; ++x) {
- colorMap->getRGB(p, &rgb);
- fputc(colToByte(rgb.r), f);
- fputc(colToByte(rgb.g), f);
- fputc(colToByte(rgb.b), f);
- p += colorMap->getNumPixelComps();
+ if ((p = imgStr->getLine())) {
+ for (x = 0; x < width; ++x) {
+ colorMap->getRGB(p, &rgb);
+ fputc(colToByte(rgb.r), f);
+ fputc(colToByte(rgb.g), f);
+ fputc(colToByte(rgb.b), f);
+ p += colorMap->getNumPixelComps();
+ }
+ } else {
+ for (x = 0; x < width; ++x) {
+ fputc(0, f);
+ fputc(0, f);
+ fputc(0, f);
+ }
}
}
imgStr->close();
More information about the poppler
mailing list