Closed Bug 1695727 Opened 3 years ago Closed 2 years ago

PDF renders with letters touching each other

Categories

(Firefox :: PDF Viewer, defect, P3)

Firefox 86
x86_64
Linux
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: plroskin, Unassigned)

Details

Attachments

(7 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0

Steps to reproduce:

I opened a file from https://www.faa.gov/space/additional_information/international_affairs/media/FAA_Protection_Criteria_for_FSSystems_and_Abort_IAC_Washington.pdf
(the file will be attached)

Actual results:

The file is barely readable because of missing or insufficient horizontal space between letters.

Expected results:

The rendering should be similar to that of Evince and Adobe Reader.

Component: Untriaged → PDF Viewer
OS: Unspecified → Linux
Hardware: Unspecified → x86_64

Hi Pavel,
I could not reproduce this on my end but I am on a MacOS 10.15. Is this happening for you on all PDF files or only on this one?
Please try to disable all your addons, restart firefox and see if it is still reproducible.

Flags: needinfo?(plroskin)

Thank you for your quick reply!
I checked several files on my system and I found another one (somebody's resume) that renders incorrectly. It also has letters touching each other. However, there are significant differences in the way it looks. The resume also has issues with Adobe Reader and Inkscape (internal import), so I believe these are different issues that need separate tickets.
I could not find any other PDF file that renders incorrectly in Firefox only. The rendering is correct with Acrobat Reader, Evince, xpdf, gimp and Inkscape (both Poppler/Cairo and internal import).
Disabling all plugins made no difference to the rendering. Neither did the private window.

I have noticed that the font used by Firefox is different. It uses rectangular serifs, whereas the normal rendering uses curved serifs (sorry if I'm using wrong terms, it's not my area of expertise). I suspect Firefox is using a wrong font substitution. I'll post magnified screenshots.

Flags: needinfo?(plroskin)

Could you please also try out a New Profile? Here is how to do that: https://support.mozilla.org/en-US/kb/profile-manager-create-remove-switch-firefox-profiles
I also tried on Ubuntu device but with no luck, let's see how the new profile tryout goes.

Flags: needinfo?(plroskin)

I've tried a new profile, no luck. I even tried a new user. The results are the same.
However, I have found a workaround! The default font in Preferences is DejaVu Serif. If I change it to any other font, that becomes the font used in the PDF. Many other fonts work well, for instance Liberation Serif and FreeSerif. Others give somewhat crowded appearance, e.g. Century Schoolbook L and Noto Serif CJK JP. DejaVu Serif is most crowded of the serif fonts.
I can even select a sans serif font, and Firefox would render that document in that sans serif font.
I checked that document on Windows in PDF-XChange Viewer, as suggested in https://superuser.com/questions/117443/how-to-know-which-fonts-are-used-in-selected-part-of-a-pdf-document
The font name is TimesNewRomanPSMT.
I checked the appearance of DejaVu Serif, it matches the screenshot. The serifs are rectangular.

In any case, all other software does a better job rendering that document by default. I guess Firefox should recognize that the font is of the Times family and should be displayed using a font that claims to be similar. Also maybe there is a better mechanism to select glyph sizes closer to the original document.

Flags: needinfo?(plroskin) → needinfo?(bdahl)
Flags: needinfo?(timea.babos)

Thanks for all the investigation done Pavel!
Although there is a workaround described here for this case, I will set up this bug as an enhancement request to improve browser font detection for PDF files. Not sure how actionable that is at this point, but developers should have better insight into this request.

Status: UNCONFIRMED → NEW
Type: defect → enhancement
Ever confirmed: true
Flags: needinfo?(timea.babos)
Summary: PDF renders with letters touching each other → Improve browser detection for fonts used in PDF files

(Resetting the Summary-field, since the new one doesn't seem entirely appropriate.)

This looks like another case, see also https://github.com/mozilla/pdf.js/pull/12726#issuecomment-789293128, where embedding standard fonts in PDF.js would improve rendering on Linux.

Summary: Improve browser detection for fonts used in PDF files → PDF renders with letters touching each other
Severity: -- → S4
Type: enhancement → defect
Priority: -- → P3

Hi Pavel,

I reported the same bug a yesterday (https://bugzilla.mozilla.org/show_bug.cgi?id=1738609).

"Glad" to know that I'm not the first one and nothing has been done about this in 8 months.

Anyway, there's an add-on for Firefox that forces it to use google's pdf viewer (don't know if you need to have Chrome installed) and that handles pdf's with weird fonts well. Here's the link:

https://addons.mozilla.org/en-US/firefox/addon/google-pdf-viewer/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search

I'm fairly sure that this has to do with fonts substitution, as I've noticed that the pdf's that display this problem have weird fonts (e.g. TimesNewRomanPSMT).

I tried messing around with my fonts.conf file (~/.config/fontconfig/fonts.conf) and that didn't seem to make a difference. Just in case, here are the contents of that file

<?xml version="1.0"?>

<!-- disable embedded bitmaps in fonts to fix Calibri, Cambria, etc. -->
<match target="font">
<edit mode="assign" name="embeddedbitmap"><bool>false</bool></edit>
</match>

<!-- Added 11/01/21 to try to make firefox 93's render pdf's correctly -->
<match>
<test name="family"><string>TimesNewRomanPS</string></test>
<edit name="family" mode="assign" binding="same">
<string>Times New Roman</string>
</edit>
</match>

<match>
<test name="family"><string>TimesNewRomanPSMT</string></test>
<edit name="family" mode="assign" binding="same">
<string>Times New Roman</string>
</edit>
</match>
<!-- end -->

Alex

Actually https://github.com/mozilla/pdf.js/pull/12726 might have fixed this and I might have wrongly duplicated them...
Pavel, can you still reproduce?

Flags: needinfo?(plroskin)

The same problem shows up when visiting https://mozilla.github.io/pdf.js/examples/index.html#interactive-examples with Firefox in Linux Mint 19.

When viewing the above page with Firefox 19 on Windows 10, the "Hello, world!" is rendered correctly.

Alex

The problem seems to be related to pdf.js.

I just attached another image showing the different rendering under Windows 10 vs. Linux Mint 19.

Alex

Brendan Dahl, on bug https://bugzilla.mozilla.org/show_bug.cgi?id=1738609 suggested setting pdfjs.disableFontFace to true in about:config and now pdf's are displayed correctly.

Alex

I confirm the issue is fixed in Firefox 94. I don't know what's the earliest Firefox version where it's fixed. The PDF is showing with a consistent, well-looking Times-like font, even if the default fonts are all set to something different. The behavior is also correct with a newly created profile. This bug can be closed.

Flags: needinfo?(plroskin)

Hi Pavel,

The bug's still there. I just upgraded from 93 to 94 and I still have the same problem.

Unless I set pdfjs.disableFontFace to True, pdf's such as the ones I mentioned before (https://resources.finalsite.net/images/v1560883341/sandyspring/psdflzfbhjvwuasxxcym/AmericanHistory.pdf and https://www.nysd.uscourts.gov/sites/default/files/2018-06/attoneys%20manual_0.pdf) are rendered incorrectly.

Alex

Alex, this bug is about another file (FAA_Protection_Criteria_for_FSSystems_and_Abort_IAC_Washington.pdf). Does it render for you correctly? If not, can you post a screenshot? This bug was never meant to cover all issues with font rendering in PDF files.

Flags: needinfo?(mozillabugs-trk1)
Flags: needinfo?(mozillabugs-trk1)

Hi Pavel,

I didn't know this report was about firefox's behavior with one particular pdf. I thought it was about issues with certain pdf's in general.

Anyway, I have Firefox 94 now and the pdf you mentioned also renders incorrectly unless I set pdfjs.disableFontFace to True. I posted a screenshot. Like I wrote, when I change pdfjs.disableFontFace to True, that pdf displays correctly.

Alex

Attached file bad_pdf_2021-11-15.pdf

This file renders incorrectly on my end (Firefox 94 in Linux Mint 19), as follows:

With pdfjs.disableFontFace set to False: The title ("Retain This 1098 With Your Important Tax Records") renders in a crappy font with characters touching, and the rest of the document renders correctly.

With pdfjs.disableFontFace set to True: The title renders correctly, the rest of the document appears blank.

I was just bitten by this bug again, so I'm reopening the bug.

I uploaded a pdf (bad_pdf_2021-11-15.pdf).

This file renders incorrectly on my end (Firefox 94 in Linux Mint 19), as follows:

With pdfjs.disableFontFace set to False: The title ("Retain This 1098 With Your Important Tax Records") renders in a crappy font with characters touching, and the rest of the document renders correctly.

With pdfjs.disableFontFace set to True: The title renders correctly, the rest of the document appears blank.

Thanks!

Alex

works fine for me on Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0, might be an Linux issue

(In reply to Kenan from comment #24)

works fine for me on Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0, might be an Linux issue

Yes. It is Linux related. I indicated this in my original filing (https://bugzilla.mozilla.org/show_bug.cgi?id=1738609), which was marked as a duplicate of this one:

"Granted, the document is sheer crap and does have a mish-mash of Times Roman variants (thank you Word, possibly), but it displays correctly in Chrome in Linux and in Firefox in Windows 10."

Alex

Let's mark this as fixed and reopen alexwi original bug report, since they seem to be separate bugs after all.

Status: NEW → RESOLVED
Closed: 2 years ago
Flags: needinfo?(bdahl)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: