-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide .notdef glyphs in non-embedded Type1 fonts and don't ignore Widths #11528
Conversation
I'll happily defer the actual review to @brendandahl, however one small suggestion: |
Fixes mozilla#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 mozilla#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`.
0374656
to
809b96b
Compare
To justify my solution, see the source code of Apache PDFBox: |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/42d3fcfd1c1d9b0/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/42d3fcfd1c1d9b0/output.txt Total script time: 1.75 mins Published |
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 0 Live output at: http://54.67.70.0:8877/a62bf82a06278dc/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 0 Live output at: http://54.215.176.217:8877/a56426189b59dae/output.txt |
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/a56426189b59dae/output.txt Total script time: 25.88 mins
Image differences available at: http://54.215.176.217:8877/a56426189b59dae/reftest-analyzer.html#web=eq.log |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/a62bf82a06278dc/output.txt Total script time: 60.00 mins |
/botio-linux test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/30280676c1b342b/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/30280676c1b342b/output.txt Total script time: 19.45 mins
Image differences available at: http://54.67.70.0:8877/30280676c1b342b/reftest-analyzer.html#web=eq.log |
/botio makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @brendandahl received. Current queue size: 0 Live output at: http://54.215.176.217:8877/27e92d59e1425b4/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_makeref from @brendandahl received. Current queue size: 0 Live output at: http://54.67.70.0:8877/ee00492c6233b67/output.txt |
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/27e92d59e1425b4/output.txt Total script time: 2.54 mins
|
/botio-windows makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @brendandahl received. Current queue size: 0 Live output at: http://54.215.176.217:8877/b8f3f2f91e6fc29/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/ee00492c6233b67/output.txt Total script time: 17.99 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/b8f3f2f91e6fc29/output.txt Total script time: 25.09 mins
|
Fixes #11403
The PDF uses the non-embedded Type1 font Helvetica. Character codes 194 and 160 (
Â
andNBSP
) 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 alsoglyphName === ""
because the name""
is used incore/encodings.js
for undefined glyphs in encodings likeWinAnsiEncoding
.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'sWidths
array if the font has noFontDescriptor
entry. That happens in #11403, so the default widths of Helvetica were used as specified incore/metrics.js
and.nodef
got a width of 333. The correct width is 0 as specified by theWidths
array in the PDF. Thus we must never ignoreWidths
.In local testing the rendering of test
bug1443140
has now changed. The PDF uses non-embedded fonts like Times-Roman and they haveWidths
but noFontDescriptor
.Even though the issue is labeled
4-printing
, the problems appear also when rendered on-screen.