Commit 19204ed5 authored by Albert Astals Cid's avatar Albert Astals Cid

xpdf303: CMap::getCID signature change

parent 9c74bef7
......@@ -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,
......
......@@ -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)
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment