1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

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:
Tim van der Meij 2019-05-15 00:04:39 +02:00 committed by GitHub
commit c8c937c257
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 9 deletions

View file

@ -1830,7 +1830,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
extractDataStructures:
function PartialEvaluator_extractDataStructures(dict, baseDict,
properties) {
var xref = this.xref;
let xref = this.xref, cidToGidBytes;
// 9.10.2
var toUnicode = (dict.get('ToUnicode') || baseDict.get('ToUnicode'));
var toUnicodePromise = toUnicode ?
@ -1849,7 +1849,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var cidToGidMap = dict.get('CIDToGIDMap');
if (isStream(cidToGidMap)) {
properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
cidToGidBytes = cidToGidMap.getBytes();
}
}
@ -1932,8 +1932,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return toUnicodePromise.then((toUnicode) => {
properties.toUnicode = toUnicode;
return this.buildToUnicode(properties);
}).then(function (toUnicode) {
}).then((toUnicode) => {
properties.toUnicode = toUnicode;
if (cidToGidBytes) {
properties.cidToGidMap = this.readCidToGidMap(cidToGidBytes,
toUnicode);
}
return properties;
});
},
@ -2149,18 +2153,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return Promise.resolve(null);
},
readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
readCidToGidMap(glyphsData, toUnicode) {
// Extract the encoding from the CIDToGIDMap
var glyphsData = cidToGidStream.getBytes();
// Set encoding 0 to later verify the font has an encoding
var result = [];
for (var j = 0, jj = glyphsData.length; j < jj; j++) {
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
if (glyphID === 0) {
const code = j >> 1;
if (glyphID === 0 && !toUnicode.has(code)) {
continue;
}
var code = j >> 1;
result[code] = glyphID;
}
return result;