1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #11159 from Snuffleupagus/issue-11150

For Type1 fonts, replace missing font dictionary /Widths entries with ones from the font data (issue 11150)
This commit is contained in:
Tim van der Meij 2019-09-19 13:14:27 +02:00 committed by GitHub
commit 58e5f36666
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 3 deletions

View file

@ -3200,7 +3200,7 @@ var Type1Font = (function Type1FontClosure() {
var eexecBlock = getEexecBlock(file, eexecBlockLength);
var eexecBlockParser = new Type1Parser(eexecBlock.stream, true,
SEAC_ANALYSIS_ENABLED);
var data = eexecBlockParser.extractFontProgram();
var data = eexecBlockParser.extractFontProgram(properties);
for (var info in data.properties) {
properties[info] = data.properties[info];
}

View file

@ -520,7 +520,7 @@ var Type1Parser = (function Type1ParserClosure() {
* Returns an object containing a Subrs array and a CharStrings
* array extracted from and eexec encrypted block of data
*/
extractFontProgram: function Type1Parser_extractFontProgram() {
extractFontProgram: function Type1Parser_extractFontProgram(properties) {
var stream = this.stream;
var subrs = [], charstrings = [];
@ -646,6 +646,16 @@ var Type1Parser = (function Type1ParserClosure() {
lsb: charString.lsb,
seac: charString.seac,
});
// Attempt to replace missing widths, from the font dictionary /Widths
// entry, with ones from the font data (fixes issue11150_reduced.pdf).
if (properties.builtInEncoding) {
const index = properties.builtInEncoding.indexOf(glyph);
if (index > -1 && properties.widths[index] === undefined &&
index >= properties.firstChar && index <= properties.lastChar) {
properties.widths[index] = charString.width;
}
}
}
return program;