Merge pull request #10794 from janpe2/cidtogidmap-zero
Fix glyph at index zero in CIDFontType2 that has a CIDToGIDMap stream
This commit is contained in:
commit
c8c937c257
@ -1830,7 +1830,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
extractDataStructures:
|
extractDataStructures:
|
||||||
function PartialEvaluator_extractDataStructures(dict, baseDict,
|
function PartialEvaluator_extractDataStructures(dict, baseDict,
|
||||||
properties) {
|
properties) {
|
||||||
var xref = this.xref;
|
let xref = this.xref, cidToGidBytes;
|
||||||
// 9.10.2
|
// 9.10.2
|
||||||
var toUnicode = (dict.get('ToUnicode') || baseDict.get('ToUnicode'));
|
var toUnicode = (dict.get('ToUnicode') || baseDict.get('ToUnicode'));
|
||||||
var toUnicodePromise = toUnicode ?
|
var toUnicodePromise = toUnicode ?
|
||||||
@ -1849,7 +1849,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
var cidToGidMap = dict.get('CIDToGIDMap');
|
var cidToGidMap = dict.get('CIDToGIDMap');
|
||||||
if (isStream(cidToGidMap)) {
|
if (isStream(cidToGidMap)) {
|
||||||
properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
|
cidToGidBytes = cidToGidMap.getBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1932,8 +1932,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
return toUnicodePromise.then((toUnicode) => {
|
return toUnicodePromise.then((toUnicode) => {
|
||||||
properties.toUnicode = toUnicode;
|
properties.toUnicode = toUnicode;
|
||||||
return this.buildToUnicode(properties);
|
return this.buildToUnicode(properties);
|
||||||
}).then(function (toUnicode) {
|
}).then((toUnicode) => {
|
||||||
properties.toUnicode = toUnicode;
|
properties.toUnicode = toUnicode;
|
||||||
|
if (cidToGidBytes) {
|
||||||
|
properties.cidToGidMap = this.readCidToGidMap(cidToGidBytes,
|
||||||
|
toUnicode);
|
||||||
|
}
|
||||||
return properties;
|
return properties;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -2149,18 +2153,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
},
|
},
|
||||||
|
|
||||||
readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
|
readCidToGidMap(glyphsData, toUnicode) {
|
||||||
// Extract the encoding from the CIDToGIDMap
|
// Extract the encoding from the CIDToGIDMap
|
||||||
var glyphsData = cidToGidStream.getBytes();
|
|
||||||
|
|
||||||
// Set encoding 0 to later verify the font has an encoding
|
// Set encoding 0 to later verify the font has an encoding
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var j = 0, jj = glyphsData.length; j < jj; j++) {
|
for (var j = 0, jj = glyphsData.length; j < jj; j++) {
|
||||||
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
|
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
|
||||||
if (glyphID === 0) {
|
const code = j >> 1;
|
||||||
|
if (glyphID === 0 && !toUnicode.has(code)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var code = j >> 1;
|
|
||||||
result[code] = glyphID;
|
result[code] = glyphID;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1606,7 +1606,8 @@ var Font = (function FontClosure() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeMetrics(font, header, metrics, numGlyphs) {
|
function sanitizeMetrics(font, header, metrics, numGlyphs,
|
||||||
|
dupFirstEntry) {
|
||||||
if (!header) {
|
if (!header) {
|
||||||
if (metrics) {
|
if (metrics) {
|
||||||
metrics.data = null;
|
metrics.data = null;
|
||||||
@ -1649,6 +1650,11 @@ var Font = (function FontClosure() {
|
|||||||
// the use of |numMissing * 2| when initializing the typed array.
|
// the use of |numMissing * 2| when initializing the typed array.
|
||||||
var entries = new Uint8Array(metrics.length + numMissing * 2);
|
var entries = new Uint8Array(metrics.length + numMissing * 2);
|
||||||
entries.set(metrics.data);
|
entries.set(metrics.data);
|
||||||
|
if (dupFirstEntry) {
|
||||||
|
// Set the sidebearing value of the duplicated glyph.
|
||||||
|
entries[metrics.length] = metrics.data[2];
|
||||||
|
entries[metrics.length + 1] = metrics.data[3];
|
||||||
|
}
|
||||||
metrics.data = entries;
|
metrics.data = entries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2366,7 +2372,8 @@ var Font = (function FontClosure() {
|
|||||||
|
|
||||||
// Ensure the hmtx table contains the advance width and
|
// Ensure the hmtx table contains the advance width and
|
||||||
// sidebearings information for numGlyphs in the maxp table
|
// sidebearings information for numGlyphs in the maxp table
|
||||||
sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphsOut);
|
sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphsOut,
|
||||||
|
dupFirstEntry);
|
||||||
|
|
||||||
if (!tables['head']) {
|
if (!tables['head']) {
|
||||||
throw new FormatError('Required "head" table is not found');
|
throw new FormatError('Required "head" table is not found');
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -293,6 +293,7 @@
|
|||||||
!issue5540.pdf
|
!issue5540.pdf
|
||||||
!issue5549.pdf
|
!issue5549.pdf
|
||||||
!issue5475.pdf
|
!issue5475.pdf
|
||||||
|
!issue10519_reduced.pdf
|
||||||
!annotation-border-styles.pdf
|
!annotation-border-styles.pdf
|
||||||
!IdentityToUnicodeMap_charCodeOf.pdf
|
!IdentityToUnicodeMap_charCodeOf.pdf
|
||||||
!PDFJS-9279-reduced.pdf
|
!PDFJS-9279-reduced.pdf
|
||||||
|
BIN
test/pdfs/issue10519_reduced.pdf
Normal file
BIN
test/pdfs/issue10519_reduced.pdf
Normal file
Binary file not shown.
@ -3126,6 +3126,12 @@
|
|||||||
"lastPage": 4,
|
"lastPage": 4,
|
||||||
"type": "load"
|
"type": "load"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue10519",
|
||||||
|
"file": "pdfs/issue10519_reduced.pdf",
|
||||||
|
"md5": "8a2dae43c0ef47b0734bedaaa24f8c09",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "issue3061",
|
{ "id": "issue3061",
|
||||||
"file": "pdfs/issue3061.pdf",
|
"file": "pdfs/issue3061.pdf",
|
||||||
"md5": "696a7cb1b194d095ca3f7861779a606b",
|
"md5": "696a7cb1b194d095ca3f7861779a606b",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user