mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.3k stars 9.97k forks source link

Unicode code chart PDF renders incorrectly in Firefox native viewer #16339

Open brianary opened 1 year ago

brianary commented 1 year ago

Attach (recommended) or Link to PDF file here:

Configuration:

Steps to reproduce the problem:

  1. Open https://www.unicode.org/charts/PDF/U0000.pdf

What is the expected behavior? (add screenshot) What went wrong? (add screenshot) screenshot showing rendering in Firefox and SumatraPDF

Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):

brianary commented 1 year ago

Redirected from webcompat/web-bugs#121314

brianary commented 1 year ago

The code chart PDF renders correctly in Chrome, Edge, and SumatraPDF.

Snuffleupagus commented 1 year ago

Interestingly it works with disableFontFace=true set, and the glyphs look reasonable in FontForge, so I wonder if this could perhaps indicate a bug in the Windows font-renderer?

@calixteman Can you reproduce this in non-Windows operating systems?

calixteman commented 1 year ago

I can reproduce on windows 11 either but it's fine on mac os 13.3.1 and on Fedora 37.

calixteman commented 1 year ago

And the rendering is wrong (the same as in Firefox) in Acrobat on Windows and on Mac.

calixteman commented 1 year ago

On Windows, the right leg of the X in STX is wrongly rendered in Chrome viewer (it depends on the zoom level) and in the new Edge one (where SOH is correct)

calixteman commented 1 year ago

I extracted the font in using the debugger and I used ttx to convert it into an xml format. In the glyph 0067 I removed all the instructions and then compiled the ttx into a ttf: SOH is correctly displayed. Those instructions are used to help to correctly rescale glyphs (https://learn.microsoft.com/en-us/typography/opentype/spec/ttch01#what-are-instructions). If Firefox on Windows, if the pdf is rescaled with a low zoom value, then the rendering of SOH is still wrong but different. It's working correctly in Fontforge or with disableFontFace=true because I think only the contours are used here and not the instructions. So my feeling is that the font itself is buggy and I don't really know what we could do.

calixteman commented 1 year ago

Few glyphs (like the SOH) contains some contours with only 1 point and it doesn't really make sense. I'm a bit reluctant to just strip them out because if the instructions take them into account then the rendering will be wrong, hence my idea is just to remove the hints in such a case: the potential negative side effect could be to have some "not nice" glyphs when they're rescaled. Let's try a patch and we'll see if they're some regressions...