mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Fix Type1 font parsing when .notdef is not at index zero
Fixes #11477 The PDF draws many space characters but the embedded fonts don't have a glyph named `space`, so `.notdef` should be drawn instead. PDF.js assumed that Type1 fonts define `.notdef` as the first glyph (index 0). However, now the fonts have the glyph `A` at index 0 and `.notdef` is the last one, so `A` appears where spaces are expected. Because the rest of the font machinery in `core/fonts.js` assumes `.notdef` is at index zero, it's easiest to modify `core/type1_parser.js` so that it "repairs" fonts and makes sure `.notdef` is at index 0.
This commit is contained in:
parent
52749d1f0d
commit
71e7686950
4 changed files with 15 additions and 2 deletions
|
@ -679,13 +679,19 @@ var Type1Parser = (function Type1ParserClosure() {
|
|||
// here and put an endchar to make the validator happy.
|
||||
output = [14];
|
||||
}
|
||||
program.charstrings.push({
|
||||
const charStringObject = {
|
||||
glyphName: glyph,
|
||||
charstring: output,
|
||||
width: charString.width,
|
||||
lsb: charString.lsb,
|
||||
seac: charString.seac,
|
||||
});
|
||||
};
|
||||
if (glyph === ".notdef") {
|
||||
// Make sure .notdef is at index zero (issue #11477).
|
||||
program.charstrings.unshift(charStringObject);
|
||||
} else {
|
||||
program.charstrings.push(charStringObject);
|
||||
}
|
||||
|
||||
// Attempt to replace missing widths, from the font dictionary /Widths
|
||||
// entry, with ones from the font data (fixes issue11150_reduced.pdf).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue