Closed Bug 1749563 Opened 3 years ago Closed 3 years ago

Some chars are rendered incorrectly in some documents

Categories

(Firefox :: PDF Viewer, defect, P1)

Firefox 91
defect

Tracking

()

VERIFIED FIXED
98 Branch
Tracking Status
firefox-esr91 --- wontfix
firefox96 --- wontfix
firefox97 --- wontfix
firefox98 --- verified

People

(Reporter: michel, Assigned: calixte)

References

Details

Attachments

(5 files)

Hello,
I noticed that the PDF Viewer renders some chars in some documents incorrectly. Please see the attached screenshots. The : in the URL in the footer is rendered differently in Firefox PDF Viewer than in Evince.

Document source: https://cert.pl/uploads/2022/01/hasla/resources/plakaty_informacyjne_hasla_a4.pdf

Attached image Firefox.png
Attached image Evince.png

This isn't the "normal" kind of font conversion bug, since it's connected to the specific text rendering mode being used (in this case 7); please see https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G8.1772271

Hence the bug would, most likely, be found in https://github.com/mozilla/pdf.js/blob/master/src/core/font_renderer.js

:Snuffleupagus, thanks for the tip :).

So I looked in font_renderer.js what could be wrong and I think I found.
The : is a composite glyph (two .) and there is something wrong here:
https://github.com/mozilla/pdf.js/blob/236c8d47864e8ebf593bae21576670b59a7d4988/src/core/font_renderer.js#L202
If I understand correctly, if flags & 0x01 then we get two int16 else we get two uint8.

But according to the specs:
https://docs.microsoft.com/en-us/typography/opentype/spec/glyf
if flags & 0x02 (i.e. ARGS_ARE_XY_VALUES) then these two numbers must be treated as signed.

So I just handled the uint8 => int8 case and it works.
I think we could fix this TODO too:
https://github.com/mozilla/pdf.js/blob/236c8d47864e8ebf593bae21576670b59a7d4988/src/core/font_renderer.js#L214

:Snuffleupagus, if you began to work on a fix, feel free to take the bug.

Assignee: nobody → cdenizet
Severity: -- → S3
Priority: -- → P1
Commit merged into master by GitHub Authored by calixteman (calixteman)
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 98 Branch
QA Whiteboard: [qa-98b-p2]

Reproduced with 2022-01-11-09-38-27 build of Nightly.

Issue is no longer reproducible on 98.0b8 beta if Firefox.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: