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

Use FDSelect and FDArray when converting CFF CID font to paths #9501

Merged
merged 1 commit into from
Apr 11, 2018

Conversation

janpe2
Copy link
Contributor

@janpe2 janpe2 commented Feb 20, 2018

Fixes #9355

When text rendering mode Tr specifies that text should produce clipping paths, font's glyphs are converted to canvas paths in font_renderer.js. However, it ignores entries FDSelect and FDArray in CFF CID fonts. Those entries are needed to get the correct FontMatrix (and to execute local subroutines).

The font in issue #9355 has no FontMatrix in the Top DICT, so font_renderer.js uses the default matrix, which is [0.001 0 0 0.001 0 0]. The correct FontMatrix is in the FDArray and it specifies about 50% smaller scaling factors: [.00048828099 0 0 .00048828099 0 0].

I have ignored Top DICT's FontMatrix because CFFParser always removes and copies it to FDArray dictionaries when needed.

if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
let fontDict = this.fdArray[fdIndex];
fontMatrix = fontDict.getByName('FontMatrix') ||
[0.001, 0, 0, 0.001, 0, 0];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use FONT_IDENTITY_MATRIX from src/shared/util.js rather than hard-coding this array here.

@brendandahl
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/5db93e0ca81cae5/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/5db93e0ca81cae5/output.txt

Total script time: 2.14 mins

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

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

Total script time: 3.97 mins

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

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

"file": "pdfs/text_clip_cff_cid.pdf",
"md5": "92d4920586f177cc0e83326e5b5d2ee1",
"rounds": 1,
"type": "eq",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing comma needs to be removed.

@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/9a9d95e9e9087fe/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/37ddc74c598d548/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/9a9d95e9e9087fe/output.txt

Total script time: 18.16 mins

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/37ddc74c598d548/output.txt

Total script time: 24.37 mins

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

@timvandermeij
Copy link
Contributor

@brendandahl Could you take another look at this?

Copy link
Contributor

@brendandahl brendandahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ pending the one little change

if (!code || code.length === 0 || code[0] === 14) {
return noop;
}

let fontMatrix = this.fontMatrix;
if (this.isCFFCIDFont) {
let fdIndex = this.fdSelect.getFDIndex(glyphId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment here about why we ignore the top dict's font matrix (similar to your comment in the PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment.

@brendandahl
Copy link
Contributor

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/37cc81a8f3dd848/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

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

Total script time: 16.93 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/37cc81a8f3dd848/output.txt

Total script time: 22.45 mins

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

@brendandahl
Copy link
Contributor

Thanks for pull request!

@brendandahl brendandahl merged commit 7d7bc80 into mozilla:master Apr 11, 2018
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Use FDSelect and FDArray when converting CFF CID font to paths
@janpe2 janpe2 deleted the text-clip-cff-cid branch March 10, 2020 16:55
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.

5 participants