mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +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:
parent
f9d63201eb
commit
56653e5770
4 changed files with 27 additions and 2 deletions
|
@ -3293,7 +3293,10 @@ class Font {
|
||||||
return builder.toArray();
|
return builder.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
get spaceWidth() {
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
get _spaceWidth() {
|
||||||
// trying to estimate space character width
|
// trying to estimate space character width
|
||||||
const possibleSpaceReplacements = ["space", "minus", "one", "i", "I"];
|
const possibleSpaceReplacements = ["space", "minus", "one", "i", "I"];
|
||||||
let width;
|
let width;
|
||||||
|
@ -3328,7 +3331,7 @@ class Font {
|
||||||
break; // the non-zero width found
|
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
|
// .notdef glyphs should be invisible in non-embedded Type1 fonts, so
|
||||||
// replace them with spaces.
|
// replace them with spaces.
|
||||||
fontCharCode = 0x20;
|
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);
|
fontCharCode = mapSpecialUnicodeValues(fontCharCode);
|
||||||
}
|
}
|
||||||
|
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -56,6 +56,7 @@
|
||||||
!issue17679_2.pdf
|
!issue17679_2.pdf
|
||||||
!issue18030.pdf
|
!issue18030.pdf
|
||||||
!issue18042.pdf
|
!issue18042.pdf
|
||||||
|
!issue18059.pdf
|
||||||
!issue14953.pdf
|
!issue14953.pdf
|
||||||
!issue15367.pdf
|
!issue15367.pdf
|
||||||
!issue15372.pdf
|
!issue15372.pdf
|
||||||
|
|
BIN
test/pdfs/issue18059.pdf
Normal file
BIN
test/pdfs/issue18059.pdf
Normal file
Binary file not shown.
|
@ -2990,6 +2990,20 @@
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "text"
|
"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",
|
"id": "issue11139",
|
||||||
"file": "pdfs/issue11139.pdf",
|
"file": "pdfs/issue11139.pdf",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue