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:
commit
58e5f36666
@ -3200,7 +3200,7 @@ var Type1Font = (function Type1FontClosure() {
|
|||||||
var eexecBlock = getEexecBlock(file, eexecBlockLength);
|
var eexecBlock = getEexecBlock(file, eexecBlockLength);
|
||||||
var eexecBlockParser = new Type1Parser(eexecBlock.stream, true,
|
var eexecBlockParser = new Type1Parser(eexecBlock.stream, true,
|
||||||
SEAC_ANALYSIS_ENABLED);
|
SEAC_ANALYSIS_ENABLED);
|
||||||
var data = eexecBlockParser.extractFontProgram();
|
var data = eexecBlockParser.extractFontProgram(properties);
|
||||||
for (var info in data.properties) {
|
for (var info in data.properties) {
|
||||||
properties[info] = data.properties[info];
|
properties[info] = data.properties[info];
|
||||||
}
|
}
|
||||||
|
@ -520,7 +520,7 @@ var Type1Parser = (function Type1ParserClosure() {
|
|||||||
* Returns an object containing a Subrs array and a CharStrings
|
* Returns an object containing a Subrs array and a CharStrings
|
||||||
* array extracted from and eexec encrypted block of data
|
* array extracted from and eexec encrypted block of data
|
||||||
*/
|
*/
|
||||||
extractFontProgram: function Type1Parser_extractFontProgram() {
|
extractFontProgram: function Type1Parser_extractFontProgram(properties) {
|
||||||
var stream = this.stream;
|
var stream = this.stream;
|
||||||
|
|
||||||
var subrs = [], charstrings = [];
|
var subrs = [], charstrings = [];
|
||||||
@ -646,6 +646,16 @@ var Type1Parser = (function Type1ParserClosure() {
|
|||||||
lsb: charString.lsb,
|
lsb: charString.lsb,
|
||||||
seac: charString.seac,
|
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;
|
return program;
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -82,6 +82,7 @@
|
|||||||
!issue10665_reduced.pdf
|
!issue10665_reduced.pdf
|
||||||
!issue11016_reduced.pdf
|
!issue11016_reduced.pdf
|
||||||
!issue11045.pdf
|
!issue11045.pdf
|
||||||
|
!issue11150_reduced.pdf
|
||||||
!bad-PageLabels.pdf
|
!bad-PageLabels.pdf
|
||||||
!decodeACSuccessive.pdf
|
!decodeACSuccessive.pdf
|
||||||
!filled-background.pdf
|
!filled-background.pdf
|
||||||
|
BIN
test/pdfs/issue11150_reduced.pdf
Normal file
BIN
test/pdfs/issue11150_reduced.pdf
Normal file
Binary file not shown.
@ -53,6 +53,13 @@
|
|||||||
"link": false,
|
"link": false,
|
||||||
"type": "text"
|
"type": "text"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue11150",
|
||||||
|
"file": "pdfs/issue11150_reduced.pdf",
|
||||||
|
"md5": "8b86381089a9ec28723791245a9adfa6",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": false,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "issue1293",
|
{ "id": "issue1293",
|
||||||
"file": "pdfs/issue1293r.pdf",
|
"file": "pdfs/issue1293r.pdf",
|
||||||
"md5": "4a098f5051f34fab036f5bbe88f8deef",
|
"md5": "4a098f5051f34fab036f5bbe88f8deef",
|
||||||
|
@ -90,7 +90,7 @@ describe('Type1Parser', function() {
|
|||||||
'/.notdef 1 RD x ND\n' +
|
'/.notdef 1 RD x ND\n' +
|
||||||
'end');
|
'end');
|
||||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||||
var program = parser.extractFontProgram();
|
var program = parser.extractFontProgram({});
|
||||||
expect(program.charstrings.length).toEqual(1);
|
expect(program.charstrings.length).toEqual(1);
|
||||||
expect(program.properties.privateData.ExpansionFactor).toEqual(99);
|
expect(program.properties.privateData.ExpansionFactor).toEqual(99);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user