mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
Fixing duplicates in cmap
This commit is contained in:
parent
a1d2c1c6d3
commit
aaad824f77
1 changed files with 18 additions and 6 deletions
24
src/fonts.js
24
src/fonts.js
|
@ -1432,7 +1432,7 @@ var Font = (function Font() {
|
|||
var glyphCode = offsetIndex < 0 ? j :
|
||||
offsets[offsetIndex + j - start];
|
||||
glyphCode = (glyphCode + delta) & 0xFFFF;
|
||||
if (glyphCode == 0)
|
||||
if (glyphCode == 0 || isAdaptedUnicode(j))
|
||||
continue;
|
||||
|
||||
var unicode = adaptUnicode(j);
|
||||
|
@ -1457,6 +1457,9 @@ var Font = (function Font() {
|
|||
for (var j = 0; j < entryCount; j++) {
|
||||
var glyphCode = int16(font.getBytes(2));
|
||||
var code = firstCode + j;
|
||||
if (isAdaptedUnicode(glyphCode))
|
||||
continue;
|
||||
|
||||
var unicode = adaptUnicode(code);
|
||||
glyphs.push({ unicode: unicode, code: code });
|
||||
ids.push(glyphCode);
|
||||
|
@ -2754,14 +2757,23 @@ CFF.prototype = {
|
|||
var reverseMapping = {};
|
||||
var encoding = properties.baseEncoding;
|
||||
var differences = properties.differences;
|
||||
var i, length;
|
||||
var usedIn = [];
|
||||
var i, length, glyphName;
|
||||
for (i = 0, length = encoding.length; i < length; ++i) {
|
||||
if (encoding[i] && !isSpecialUnicode(i))
|
||||
reverseMapping[encoding[i]] = i;
|
||||
glyphName = encoding[i];
|
||||
if (!glyphName || isSpecialUnicode(i))
|
||||
continue;
|
||||
reverseMapping[glyphName] = i;
|
||||
usedIn[i] = glyphName;
|
||||
}
|
||||
for (i = 0, length = differences.length; i < length; ++i) {
|
||||
if (differences[i] && !isSpecialUnicode(i))
|
||||
reverseMapping[differences[i]] = i;
|
||||
glyphName = differences[i];
|
||||
if (!glyphName || isSpecialUnicode(i))
|
||||
continue;
|
||||
if (usedIn[i])
|
||||
delete reverseMapping[usedIn[i]];
|
||||
reverseMapping[glyphName] = i;
|
||||
usedIn[i] = glyphName;
|
||||
}
|
||||
reverseMapping['.notdef'] = 0;
|
||||
var unusedUnicode = kCmapGlyphOffset;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue