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

JBIG2 symbol offsets #8932

Merged
merged 1 commit into from
Sep 23, 2017
Merged

JBIG2 symbol offsets #8932

merged 1 commit into from
Sep 23, 2017

Conversation

janpe2
Copy link
Contributor

@janpe2 janpe2 commented Sep 19, 2017

JBIG2 text regions have a symbol positioning problem:
symbol_pos_problem
The top pixel row of symbols is missing. The row goes outside the text region because symbols are positioned one pixel too high. Here is another one:
symbol_pos_problem_2
jbig2_symbol_offset.pdf

In JBIG2 the REFCORNER value specifies which of the four corners of a symbol bitmap is positioned at the desired point (x, y). In practice (and in PDF.js) bitmaps are drawn starting from the left-top corner. If REFCORNER is other than left-top, some offsets are needed. Currently the JBIG2 decoder uses offsets that are one pixel too large. Thus the issue appears. Most often REFCORNER is left-bottom, like in my PDFs above, so only the vertical position is wrong.

When symbols are drawn, the correct offsets are one less than the symbol width and height. For example, the vertical offset when REFCORNER is left-bottom:
symbol_offset

Typically JBIG2 images have a high resolution, so one pixel errors in symbol positioning can't be easily seen. (And symbols are rarely so near the edge of the text region that they would be clipped.)

This PR may cause JBIG2-related regression tests to fail because symbols will be moved one pixel. The new rendering is the correct one.

@Snuffleupagus
Copy link
Collaborator

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/7b03522e1835136/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/7b03522e1835136/output.txt

Total script time: 2.31 mins

Published

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Sep 19, 2017

Conflicting files
test/pdfs/.gitignore
test/test_manifest.json

@janpe2 Could you please resolve these merge conflicts, so that we can test this patch? :-)
A small piece of advice (based on experience): To avoid having to rebase patches a lot because of merge conflicts in those two files in particular, try adding new test entries in more "random" positions rather than at the end of those files.

@Snuffleupagus
Copy link
Collaborator

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/6c6931fd5ad846d/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/89fecdff5743b9b/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/6c6931fd5ad846d/output.txt

Total script time: 16.78 mins

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

Image differences available at: http://54.67.70.0:8877/6c6931fd5ad846d/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/89fecdff5743b9b/output.txt

Total script time: 29.46 mins

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

Image differences available at: http://54.215.176.217:8877/89fecdff5743b9b/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_makeref from @timvandermeij received. Current queue size: 1

Live output at: http://54.215.176.217:8877/a1f650355ddcd56/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_makeref from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/d320c13b12ebc42/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/d320c13b12ebc42/output.txt

Total script time: 15.79 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/a1f650355ddcd56/output.txt

Total script time: 27.69 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@timvandermeij timvandermeij merged commit c69a7a8 into mozilla:master Sep 23, 2017
@timvandermeij
Copy link
Contributor

Thank you for fixing this!

@janpe2 janpe2 deleted the jbig2-sym-offset branch December 19, 2017 19:35
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants