mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Hide .notdef glyphs in non-embedded Type1 fonts and don't ignore Widths
Fixes #11403 The PDF uses the non-embedded Type1 font Helvetica. Character codes 194 and 160 (`Â` and `NBSP`) are encoded as `.notdef`. We shouldn't show those glyphs because it seems that Acrobat Reader doesn't draw glyphs that are named `.notdef` in fonts like this. In addition to testing `glyphName === ".notdef"`, we must test also `glyphName === ""` because the name `""` is used in `core/encodings.js` for undefined glyphs in encodings like `WinAnsiEncoding`. The solution above hides the `Â` characters but now the replacement character (space) appears to be too wide. I found out that PDF.js ignores font's `Widths` array if the font has no `FontDescriptor` entry. That happens in #11403, so the default widths of Helvetica were used as specified in `core/metrics.js` and `.nodef` got a width of 333. The correct width is 0 as specified by the `Widths` array in the PDF. Thus we must never ignore `Widths`.
This commit is contained in:
parent
40f531ee87
commit
809b96b40c
5 changed files with 125 additions and 8 deletions
|
@ -3392,6 +3392,16 @@ var Font = (function FontClosure() {
|
|||
// back to the char code.
|
||||
fontCharCode = this.toFontChar[charcode] || charcode;
|
||||
if (this.missingFile) {
|
||||
const glyphName =
|
||||
this.differences[charcode] || this.defaultEncoding[charcode];
|
||||
if (
|
||||
(glyphName === ".notdef" || glyphName === "") &&
|
||||
this.type === "Type1"
|
||||
) {
|
||||
// .notdef glyphs should be invisible in non-embedded Type1 fonts, so
|
||||
// replace them with spaces.
|
||||
fontCharCode = 0x20;
|
||||
}
|
||||
fontCharCode = mapSpecialUnicodeValues(fontCharCode);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue