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

Also update the width/unicode data when replacing missing glyphs in non-embedded Type1 fonts (issue 18059)

*Please note:* This causes a little bit of movement in the `issue2770` test-case, however this matches the rendering in both Adobe Reader and PDFium.
This commit is contained in:
Jonas Jenwald 2024-07-09 09:34:38 +02:00
parent f9d63201eb
commit 56653e5770
4 changed files with 27 additions and 2 deletions

View file

@ -3293,7 +3293,10 @@ class Font {
return builder.toArray();
}
get spaceWidth() {
/**
* @private
*/
get _spaceWidth() {
// trying to estimate space character width
const possibleSpaceReplacements = ["space", "minus", "one", "i", "I"];
let width;
@ -3328,7 +3331,7 @@ class Font {
break; // the non-zero width found
}
}
return shadow(this, "spaceWidth", width || this.defaultWidth);
return shadow(this, "_spaceWidth", width || this.defaultWidth);
}
/**
@ -3376,6 +3379,13 @@ class Font {
// .notdef glyphs should be invisible in non-embedded Type1 fonts, so
// replace them with spaces.
fontCharCode = 0x20;
if (glyphName === "") {
// Ensure that other relevant glyph properties are also updated
// (fixes issue18059.pdf).
width ||= this._spaceWidth;
unicode = String.fromCharCode(fontCharCode);
}
}
fontCharCode = mapSpecialUnicodeValues(fontCharCode);
}