Skip to content

Return ErrorFont in loadFont when the fontRef is undefined #4922

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

Merged
merged 1 commit into from
Jun 12, 2014
Merged

Return ErrorFont in loadFont when the fontRef is undefined #4922

merged 1 commit into from
Jun 12, 2014

Conversation

Snuffleupagus
Copy link
Collaborator

This patch enables loading of: http://www.cruiseshipportal.com/fileadmin/Downloads/CostaConcordia_study.pdf; as reported on IRC: http://logs.glob.uno/?c=mozilla%23pdfjs&s=10+Jun+2014&e=10+Jun+2014#c17609.

The following is an overview of the issues with this particular PDF file:

  • The first page contains a Type3 font (R34 (dict) [id: 34, gen: 0]).
  • In the CharProcs dictionary, for the three character, there is a reference to the font R98 (dict) [id: 98, gen: 0].
    • This particular font isn't available amongst the font resources for the first page.
    • However it does exist in the font resources for the second page.
    • Since the font isn't available, fontRef is undefined which causes an error preventing the first two pages from rendering.
  • This should thus explain why all pages render when the file is opened on the second page, since in that case the missing font has already been loaded by the time it's accessed from the first page.

This patch changes loadFont to return ErrorFont when the fontRef is undefined, thus preventing errors like those described above.
Obviously this isn't a complete solution, but it does reduce the severity of the issue considerably. I'm not even sure if solving this completely is actually feasible (and this kind of issue should be rare), given that it would require waiting for all font resources (hence all pages) to load before attempting to load e.g. Type3 fonts.

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/baf29c1645fd70e/output.txt

@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/079ed930438d053/output.txt

@CodingFabian
Copy link
Contributor

wow fantastic analysis! i was unable to get my head around it.

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/079ed930438d053/output.txt

Total script time: 24.53 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@yurydelendik
Copy link
Contributor

/botio-windows test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @yurydelendik received. Current queue size: 0

Live output at: http://107.22.172.223:8877/b0bfa7ec3a97b4d/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/b0bfa7ec3a97b4d/output.txt

Total script time: 21.56 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@yurydelendik
Copy link
Contributor

Thank you for the pull request

yurydelendik added a commit that referenced this pull request Jun 12, 2014
Return ErrorFont in loadFont when the fontRef is undefined
@yurydelendik yurydelendik merged commit 75859b8 into mozilla:master Jun 12, 2014
@Snuffleupagus Snuffleupagus deleted the undefined-fontRef branch June 12, 2014 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants