Skip to content
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

Type3 font is not rendered #12705

Closed
JanSlabon opened this issue Dec 8, 2020 · 6 comments · Fixed by #12718
Closed

Type3 font is not rendered #12705

JanSlabon opened this issue Dec 8, 2020 · 6 comments · Fixed by #12718

Comments

@JanSlabon
Copy link

Attach (recommended) or Link to PDF file here: issue.pdf

Configuration:

  • Web browser and its version: Firefox (83.0)
  • Operating system and its version: Win 10 Pro
  • PDF.js version: 2.7.345

Steps to reproduce the problem:

  1. Open attached PDF
  2. You see a white page

What is the expected behavior? (add screenshot)
grafik

What went wrong? (add screenshot)
Nothing is rendered but the text layer (selected for demonstration only):
grafik

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

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Dec 8, 2020

The Type3-glyphs look slightly "weird" as far as I can tell, see one example below (using http://brendandahl.github.io/pdf.js.utils/browser/ to extract the data), since each one sets the fill-color to white initially (the 1 1 1 rg operator) which is then applied at the end (the f operator).
Provided that I'm not misunderstanding the operatorLists of the glyphs, we thus end up painting them completely white. What I don't see, off the top of my head, is an easy way to fix this since I can't imagine that just ignoring a white-fill operator for Type3-glyphs is correct in general.

iSQP0031 (stream) [id: 27, gen: 0]

    Length = 143
    Filter = /FlateDecode
    <view contents> download

    546 0 110 0 465 730 d1
    0 0 0 RG
    1 1 1 rg
    1 w
    [] 0 d
    465 0 m
    110 0 l
    110 74 l
    242 74 l
    242 562 l
    110 562 l
    110 628 l
    159.87 628 196.62 635.1 220.25 649.32 c
    243.88 663.54 257.17 690.43 260.1 730 c
    336 730 l
    336 74 l
    465 74 l
    h
    f

@JanSlabon
Copy link
Author

It become more hard to decide who's wrong when the Type3 example in PDF 2.0 explicitly uses colors in the glyph description:
grafik
[...]
grafik

@janpe2
Copy link
Contributor

janpe2 commented Dec 8, 2020

The spec says:
A glyph description that begins with the d1 operator should not execute any operators that set the colour (or other colour-related parameters) in the graphics state; any use of such operators shall
be ignored.

@JanSlabon
Copy link
Author

@janpe2 you are right! I didn't noticed that when I skim through the specs.

So then it shouldn't be hard to be fixed. For reference this information can be found in "Table 113 – Type 3 font operators" in PDF 32000-1:2008.

@janpe2
Copy link
Contributor

janpe2 commented Dec 8, 2020

The forbidden operators are listed at the end of chapter "8.6.8 Colour Operators".

@timvandermeij
Copy link
Contributor

Fixed by the PR above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants