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

Add fallback for non-embedded "Century Gothic" CIDFontType2 font (issue 4722 and bug 879561) #5536

Merged
merged 1 commit into from
Dec 18, 2014

Conversation

Snuffleupagus
Copy link
Collaborator

According to practical experiments, falling back to "Helvetica" when we encounter a non-embedded "Century Gothic" CIDFontType2 font seems to work well.
(Also, the section on Wikipedia about "Printer ink usage" might provide some anecdotal evidence that Century Gothic is a fairly standard sans-serif font.)

Obviously this patch doesn't make "Century Gothic" fonts render perfectly, as is often the case with non-embedded fonts, but all the text is now legible in the referenced issues.

Fixes #4722.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=879561.

Edit: Both the issues referenced contains files that were exported from SolidWorks.

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

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

Total script time: 17.14 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/ab685abb1ec06cc/output.txt

Total script time: 22.76 mins

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

@@ -2467,7 +2471,7 @@ var Font = (function FontClosure() {

// if at least one width is present, remeasure all chars when exists
this.remeasure = Object.keys(this.widths).length > 0;
if (isStandardFont && type === 'CIDFontType2' &&
if (type === 'CIDFontType2' && (isStandardFont || stdFontMap[fontName]) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused about logic here, if I'm looking at that with lines above:

 // The file data is not specified. Trying to fix the font name
// to be used with the canvas.font.
var fontName = name.replace(/[,_]/g, '-');
var isStandardFont = fontName in stdFontMap;
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;

Shall we just change: var isStandardFont = (fontName in stdFontMap) || (fontName in nonStdFontMap); ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I'm kind of confused too :-)
(I realized that this was bad after submitting the PR, but figured I'd wait for the review.)

I'd be slightly worried that I might possibly break some weird edge case by changing the isStandardFont check, so I've attempted a slightly different solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be slightly worried that I might possibly break some weird edge case by changing the isStandardFont check

Actually, that I wanted to change that. Below we are using isStandardFont, and looks like we need to apply the same logic for the re-mapped standard fonts.

@yurydelendik yurydelendik self-assigned this Dec 18, 2014
@yurydelendik
Copy link
Contributor

/botio 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/e389537a175c698/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/52ce6c0ec95677e/output.txt

@CodingFabian
Copy link
Contributor

the code falls back to Helvetica, the commit message still says arial. maybe you want to fix that before merging.

@Snuffleupagus
Copy link
Collaborator Author

maybe you want to fix that before merging.

Not really, but I suppose that I can do it anyway ;-)

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

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

Total script time: 17.34 mins

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

…ue 4722 and bug 879561)

According to practical experiments, falling back to "Helvetica" when we encounter a non-embedded "[Century Gothic](http://en.wikipedia.org/wiki/Century_Gothic)" `CIDFontType2` font seems to work well.
(Also, the section on Wikipedia about "Printer ink usage" *might* provide some anecdotal evidence that Century Gothic is a fairly standard sans-serif font.)

Obviously this patch doesn't make "Century Gothic" fonts render perfectly, as is often the case with non-embedded fonts, but all the text is now legible in the referenced issues.

Fixes 4722.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=879561.
@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/52ce6c0ec95677e/output.txt

Total script time: 22.98 mins

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

@yurydelendik
Copy link
Contributor

/botio makeref

Thank you for the fix.

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/868fd213dc5e421/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

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

yurydelendik added a commit that referenced this pull request Dec 18, 2014
Add fallback for non-embedded "Century Gothic" CIDFontType2 font (issue 4722 and bug 879561)
@yurydelendik yurydelendik merged commit a17735d into mozilla:master Dec 18, 2014
@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/868fd213dc5e421/output.txt

Total script time: 17.58 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/afc9ea3ff78f063/output.txt

Total script time: 22.88 mins

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

@Snuffleupagus Snuffleupagus deleted the issue-4722 branch December 18, 2014 23:11
speedplane pushed a commit to speedplane/pdf.js that referenced this pull request Feb 24, 2015
Add fallback for non-embedded "Century Gothic" CIDFontType2 font (issue 4722 and bug 879561)
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.

PDF file showing random characters in place of text
4 participants