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

Support Type1 font files with incomplete /CharStrings definitions (issue 14462)

Please refer to https://www.pdfa.org/norm-refs/Type1Fonts.pdf#page=15 for the expected format for the /CharStrings entries.
In the referenced PDF document the /CharStrings are missing the expected end-token, which causes us to swallow the start of the next glyph name.
This commit is contained in:
Jonas Jenwald 2022-01-17 18:53:03 +01:00
parent f955b0e20c
commit a13ae5d97d
4 changed files with 16 additions and 0 deletions

View file

@ -512,6 +512,11 @@ const Type1Parser = (function Type1ParserClosure() {
return (this.currentChar = this.stream.getByte());
}
prevChar() {
this.stream.skip(-2);
return (this.currentChar = this.stream.getByte());
}
getToken() {
// Eat whitespace and comments.
let comment = false;
@ -604,6 +609,10 @@ const Type1Parser = (function Type1ParserClosure() {
token = this.getToken(); // read in 'ND' or '|-'
if (token === "noaccess") {
this.getToken(); // read in 'def'
} else if (token === "/") {
// The expected 'ND' or '|-' token is missing, avoid swallowing
// the start of the next glyph (fixes issue14462_reduced.pdf).
this.prevChar();
}
charstrings.push({
glyph,