1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48: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);
}

View file

@ -56,6 +56,7 @@
!issue17679_2.pdf
!issue18030.pdf
!issue18042.pdf
!issue18059.pdf
!issue14953.pdf
!issue15367.pdf
!issue15372.pdf

BIN
test/pdfs/issue18059.pdf Normal file

Binary file not shown.

View file

@ -2990,6 +2990,20 @@
"rounds": 1,
"type": "text"
},
{
"id": "issue18059",
"file": "pdfs/issue18059.pdf",
"md5": "b70373894edfcd571a41caa1a0776b6f",
"rounds": 1,
"type": "eq"
},
{
"id": "issue18059-text",
"file": "pdfs/issue18059.pdf",
"md5": "b70373894edfcd571a41caa1a0776b6f",
"rounds": 1,
"type": "text"
},
{
"id": "issue11139",
"file": "pdfs/issue11139.pdf",