Poor font rendering when viewing some documents in pdf.js on Linux
Categories
(Firefox :: PDF Viewer, defect, P1)
Tracking
()
People
(Reporter: botond, Assigned: calixte)
References
(Regression)
Details
(Keywords: regression)
Attachments
(8 files, 1 obsolete file)
STR
Load https://www.tcc-cci.gc.ca/Content/assets/forms/base/general_motion_form65_e.pdf in Firefox Nightly on Linux. Tested using Debian 10.
Actual results
Poor font rendering, with the letters being cramped and in some cases slightly overlapping, as shown in the attached screenshot.
Expected results
PDF renders as it does in a non-browser PDF viewer.
Reporter | ||
Comment 1•3 years ago
|
||
As a point of comparison, here is how the PDF renders in Okular (the default PDF viewer in the KDE desktop environment) on the same system.
Reporter | ||
Updated•3 years ago
|
Reporter | ||
Comment 2•3 years ago
|
||
Finally, here is how the PDF renders in Firefox 78 on the same system. It's still not as nice as Okular (the letters are taller than they should be), but at least they are not overlapping, so the rendering has regressed on the Firefox side since then.
Reporter | ||
Comment 3•3 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #2)
Finally, here is how the PDF renders in Firefox 78 on the same system. It's still not as nice as Okular (the letters are taller than they should be), but at least they are not overlapping, so the rendering has regressed on the Firefox side since then.
Regression range:
I'm guessing "Bug 1686102 - Update pdf.js to version 2.7.510. r=bdahl"?
Reporter | ||
Comment 4•3 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #3)
Regression range:
I'm guessing "Bug 1686102 - Update pdf.js to version 2.7.510. r=bdahl"?
Assuming that's the regressing change, changing component to PDF Viewer. Not sure if there's some way to bisect among pdf.js commits themselves.
Comment 5•3 years ago
•
|
||
The pdf.js rendering is showing a completely different font from the Okular screenshot. This PDF appears to use Times (actually, TimesNewRomanPSMT, which IIRC is the psname of the Times New Roman shipped on Windows, for example), but does not actually embed the font; it relies on the viewer/renderer having support for the "standard" PDF fonts (Times, Helvetica, Courier, etc) built in.
I'm guessing your Debian system doesn't have a Times font, so we get whatever substitution fontconfig offers, and that doesn't work well because it doesn't match the glyph metrics of Times that were used to lay out the text.
Reporter | ||
Comment 6•3 years ago
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #5)
I'm guessing your Debian system doesn't have a Times font,
Hmm, I do get "Times New Roman" as an option when choosing font in e.g. Kate.
Comment 7•3 years ago
|
||
Interesting. In that case it seems surprising that it doesn't get used by pdf.js here, but the glyphs in your screenshots are most definitely not TNR glyphs. Maybe there's an issue with how pdf.js takes the name requested by the PDF and tries to access it on the local system.
What does fc-match -v :family="Times New Roman"
show? Curious what names it exposes.
Reporter | ||
Comment 8•3 years ago
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #7)
What does
fc-match -v :family="Times New Roman"
show? Curious what names it exposes.
Attached the output of this
Comment 9•3 years ago
|
||
Thanks. AFAICS, that looks like exactly the expected font.
I don't know how pdf.js goes about accessing installed fonts, but to check whether there's anything weird about the fontconfig setup that might be interfering, could you try the two examples
data:text/html,<div style="font:40px Times New Roman,monospace">Hello world
data:text/html,<style>@font-face{font-family:x;src:local("TimesNewRomanPSMT")}</style><div style="font:40px x,monospace">Hello world
and see what they render? They should both use your installed TNR.
Note that while the "regression" range in comment 3 is interesting -- it seems something about how pdf.js handles the font has changed there -- the Firefox 78 rendering as shown in comment 2 was not using the correct font either. The glyphs there are definitely not Times; they look to me like they're probably DejaVu Serif or something closely related to that.
Assignee | ||
Comment 10•3 years ago
|
||
The font name is changed to Times
and it's likely the root cause of the issue here.
We should use the name as it is in the pdf and possibly fallback on an embedded standard font when the font cannot be found on the system.
Reporter | ||
Comment 11•3 years ago
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #9)
to check whether there's anything weird about the fontconfig setup that might be interfering, could you try the two examples
data:text/html,<div style="font:40px Times New Roman,monospace">Hello world data:text/html,<style>@font-face{font-family:x;src:local("TimesNewRomanPSMT")}</style><div style="font:40px x,monospace">Hello world
and see what they render? They should both use your installed TNR.
They render the same. Looks like Times to me, but I attached a screenshot to be sure.
Comment 12•3 years ago
|
||
Thanks. Yes, that's Times (New Roman). Good; that confirms there's nothing fundamentally interfering with Firefox finding and using it.
Per comment 10, it sounds pretty clear this is strictly a pdf.js issue; hopefully Calixte can come up with a fix there.
Comment 13•3 years ago
|
||
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Comment 14•3 years ago
|
||
Set release status flags based on info from the regressing bug 1686102
Updated•3 years ago
|
Comment 15•2 years ago
|
||
Unsure whether this is the same bug (viewing https://cscie92.dce.harvard.edu/spring2021/Microsoft%20Extensible%20Firmware%20Initiative%20FAT32%20File%20System%20Specification,%20Version%201.03,%2020001206.pdf), but there seem kind of arbitrary font changes (wrong font being used). PDF creator was Microsoft Word 2002. Some fonts seem to be partially embedded, while others are not.
Comment 16•2 years ago
|
||
When viewing the same portion of the document in Evince, the fonts seem to display correctly.
Comment 17•2 years ago
|
||
the same bug also reported in pdf.js github https://github.com/mozilla/pdf.js/issues/15317
Assignee | ||
Updated•2 years ago
|
Comment 20•2 years ago
|
||
Updated•2 years ago
|
Reporter | ||
Comment 21•2 years ago
|
||
\o/ Thanks very much Calixte & Jonas for your work on this!
Updated•2 years ago
|
Updated•2 years ago
|
Updated•1 years ago
|
Comment 26•1 year ago
|
||
I tried multiple builds 78.0, 86.0a1, 91.11.0esr but I could not reproduce the issue on Ubuntu 20.04.
Reporter, can you please confirm issue is fixed on latest Nightly build 116.0a1 (https://archive.mozilla.org/pub/firefox/nightly/2023/06/2023-06-26-09-42-17-mozilla-central/) and latest Beta build 115.0b9 (https://archive.mozilla.org/pub/firefox/candidates/115.0b9-candidates/build1/linux-x86_64/en-US/). Thank you very much.
Reporter | ||
Comment 27•1 year ago
|
||
Confirmed that the issue is fixed in the builds from comment 26.
Comment 28•1 year ago
|
||
Mark issue as verified based on comment#27.
Description
•