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

[api-minor] Use a local font or fallback on an embedded one (if it exists) for non-embedded fonts (bug 1766039) #16363

Merged
merged 1 commit into from
May 10, 2023

Conversation

calixteman
Copy link
Contributor

@calixteman calixteman commented Apr 27, 2023

  • Replace FoxitSans with LiberationSans: LiberationSans is already there (for XFA) and we can use it as a good replacement of FoxitSans.
  • For now we just try to substitue standard fonts, the strategy is the following:
    • we try to find a font locally from a hardcoded list;
    • if it fails then we use Liberation as fallback (only for Helvetica for the moment);
    • else we just fallback on the system serif/sansserif/monospace font.

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

I'd really like us to create a new release before moving forward with this patch (or any other standard-font data related ones).

src/core/evaluator.js Outdated Show resolved Hide resolved
src/core/evaluator.js Outdated Show resolved Hide resolved
src/core/evaluator.js Outdated Show resolved Hide resolved
src/core/evaluator.js Outdated Show resolved Hide resolved
src/display/font_loader.js Outdated Show resolved Hide resolved
src/display/font_loader.js Outdated Show resolved Hide resolved
web/app_options.js Outdated Show resolved Hide resolved
@calixteman calixteman force-pushed the use_local_font branch 2 times, most recently from 264ed84 to 1a39776 Compare May 2, 2023 11:44
src/display/font_loader.js Show resolved Hide resolved
src/display/font_loader.js Outdated Show resolved Hide resolved
src/core/font_substitutions.js Outdated Show resolved Hide resolved
src/core/font_substitutions.js Outdated Show resolved Hide resolved
src/core/fonts.js Outdated Show resolved Hide resolved
src/display/api.js Outdated Show resolved Hide resolved
@Snuffleupagus
Copy link
Collaborator

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/8975d4be50a3ce2/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/6bad623dc1f914a/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/8975d4be50a3ce2/output.txt

Total script time: 27.31 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 615
  different first/second rendering: 1

Image differences available at: http://54.241.84.105:8877/8975d4be50a3ce2/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented May 4, 2023

I've not looked at all of the changes, however one thing that immediately jumped out at me is the movement in the following test-cases:

pdf.js/test/test_manifest.json

Lines 2895 to 2909 in 4931f29

{ "id": "standard_fonts_no_system_fonts",
"file": "pdfs/standard_fonts.pdf",
"md5": "bb3a9ab3322328be983e8b4e8089843a",
"rounds": 1,
"type": "eq",
"useSystemFonts": false
},
{ "id": "standard_fonts_main_thread_fetch",
"file": "pdfs/standard_fonts.pdf",
"md5": "bb3a9ab3322328be983e8b4e8089843a",
"rounds": 1,
"type": "eq",
"useSystemFonts": false,
"useWorkerFetch": false
},

Given that they explicitly set useSystemFonts = false, why is there movement in those cases!?

Edit: Oh, is this perhaps because we've changed from Foxit to LiberationSans fonts?

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/6bad623dc1f914a/output.txt

Total script time: 34.30 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 182

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

@Snuffleupagus
Copy link
Collaborator

Another quick find: Looking at e.g. the artofwar changes I don't think that this patch handles ArialBlack fonts correctly, since "black" fonts should have a larger font-weight than a bold font.

@Snuffleupagus Snuffleupagus changed the title Use a local font or fallback on an embedded one (if it exists) for non-embedded fonts (bug 1766039) [api-minor] Use a local font or fallback on an embedded one (if it exists) for non-embedded fonts (bug 1766039) May 4, 2023
@calixteman
Copy link
Contributor Author

Another quick find: Looking at e.g. the artofwar changes I don't think that this patch handles ArialBlack fonts correctly, since "black" fonts should have a larger font-weight than a bold font.

Interesting case.
ArialBlack is mapped onto Helvetica and the font object will have its property black set to true.
Without the patch, when setting the font in the canvas, it will result into something like 900 sansserif and we'll have a black font, but if I disable fontface we just use the embedded Helvetica which is not black at all. And we could imagine that's possible to have on OS without a black version of its sansserif font.
So I'd say that it isn't really a new bug but this patch is just highlighting it.
That said, I'll try to figure out it in this patch: it's likely a matter of adding some substitution fonts for a black version.

@calixteman
Copy link
Contributor Author

I've not looked at all of the changes, however one thing that immediately jumped out at me is the movement in the following test-cases:

pdf.js/test/test_manifest.json

Lines 2895 to 2909 in 4931f29

{ "id": "standard_fonts_no_system_fonts",
"file": "pdfs/standard_fonts.pdf",
"md5": "bb3a9ab3322328be983e8b4e8089843a",
"rounds": 1,
"type": "eq",
"useSystemFonts": false
},
{ "id": "standard_fonts_main_thread_fetch",
"file": "pdfs/standard_fonts.pdf",
"md5": "bb3a9ab3322328be983e8b4e8089843a",
"rounds": 1,
"type": "eq",
"useSystemFonts": false,
"useWorkerFetch": false
},

Given that they explicitly set useSystemFonts = false, why is there movement in those cases!?

Edit: Oh, is this perhaps because we've changed from Foxit to LiberationSans fonts?

Yep exactly.

@calixteman calixteman force-pushed the use_local_font branch 2 times, most recently from ee9da13 to dffca91 Compare May 4, 2023 14:52
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/bfdc24e68795d89/output.txt

Total script time: 34.24 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 58
  different first/second rendering: 1

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

@Snuffleupagus
Copy link
Collaborator

Looking at the Windows results in #16363 (comment), there seem to be a couple of regressions:

  • firefox-artofwar-page158 is missing a piece of italic text in the middle of the page.
  • firefox-standard_fonts_no_system_fonts-page7 the text now looks both italic and bold, and it should only be italic.
  • firefox-standard_fonts_no_system_fonts-page8 the text is no longer bold (but only italic).

@calixteman
Copy link
Contributor Author

Looking at the Windows results in #16363 (comment), there seem to be a couple of regressions:

* `firefox-artofwar-page158` is missing a piece of italic text in the middle of the page.

I used Italic instead of Oblique when falling back on Helvetica for Arial Black.

* `firefox-standard_fonts_no_system_fonts-page7` the text now looks both italic _and_ bold, and it should _only_ be italic.

* `firefox-standard_fonts_no_system_fonts-page8` the text is no longer bold (but only italic).

Side effects of wrong copy/paste in standard_fonts.js: the fonts path were just permuted.

@calixteman
Copy link
Contributor Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/beebf6b8d68adac/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/0c94ab1284955a5/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/beebf6b8d68adac/output.txt

Total script time: 27.78 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 608
  different first/second rendering: 1

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/0c94ab1284955a5/output.txt

Total script time: 35.39 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 59
  different first/second rendering: 1

Image differences available at: http://54.193.163.58:8877/0c94ab1284955a5/reftest-analyzer.html#web=eq.log

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

Nit: Please fix the typo in the commit message, i.e. replace [api-mninor] -> [api-minor]

Given the huge amount of movement on the Linux-bot I've not really looked in detail at the results, however the test results look reasonable on the Windows-bot so let's do this :-)

r=me, thank you!

@calixteman
Copy link
Contributor Author

I almost looked at all the tests on linux and I didn't notice something really wrong: just few movements because the new used fonts.

…ists) for non-embedded fonts (bug 1766039)

- Replace FoxitSans with LiberationSans: LiberationSans is already there (for XFA) and we can use
it as a good replacement of FoxitSans.
- For now we just try to substitue standard fonts, the strategy is the following:
  * we try to find a font locally from a hardcoded list;
  * if it fails then we use Liberation as fallback (only for Helvetica for the moment);
  * else we just fallback on the system serif/sansserif/monospace font.
@calixteman calixteman merged commit 2d2f7b3 into mozilla:master May 10, 2023
@calixteman
Copy link
Contributor Author

/botio makeref

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/e120d724016526c/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/bda3bd24f15b2e2/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/bda3bd24f15b2e2/output.txt

Total script time: 23.92 mins

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/e120d724016526c/output.txt

Total script time: 24.00 mins

  • Lint: Passed
  • Make references: FAILED

@calixteman
Copy link
Contributor Author

/botio-windows makeref

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/7ee5ee4faedd3b7/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/7ee5ee4faedd3b7/output.txt

Total script time: 23.86 mins

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

@paulmenzel
Copy link

This change regressed font rendering for some PDF files: https://bugzilla.mozilla.org/show_bug.cgi?id=1845551

@calixteman
Copy link
Contributor Author

This change regressed font rendering for some PDF files: https://bugzilla.mozilla.org/show_bug.cgi?id=1845551

This PR is closed now and there is no need to have the same discussion in different places (bugzilla, github, ...)

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