chromium: [BUG] System fonts are not loaded

I just migrated:

Before, I was able to install the fonts system-wide in the Dockerfile with apt-get install fonts-roboto fonts-open-sans fonts-liberation, and they were automatically and successfully loaded by Chromium. After the migration, however, the fonts seem not to be loaded.

Is there any identified reason why this is happening or any suggestion on how to fix it?

I’m not using this (nor I was using it) in AWS, but rather in Google Cloud Run, so https://github.com/Sparticuz/chromium/issues/33 does not seem to help.

BTW: Loading with await chromium.font() cannot be used since is not a solution for headers/footers.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 16 (4 by maintainers)

Most upvoted comments

@Peque my team loads fonts as base64 encoded data to get around the header/footer issue:

@font-face {
  font-weight: 400;
  font-family: 'Nunito Sans';
  font-style: normal;
  src: url('data:application/x-font-woff;charset=utf-8;base64,BASE64_BLOB_HERE') format('woff2');
  font-display: swap;
}

This has worked for us for years and still works on the latest @sparticuz/chromium version

@Sparticuz I am eager to try the v122 release when available if it fixes this issue! 🥳 😊

PS: Is there any estimated release date or not yet?

A few minutes

I got webfonts working by adding chromium.args.concat(['--font-render-hinting=none']) to options.

See https://github.com/puppeteer/puppeteer/issues/2410#issuecomment-560573612

@aldenquimby Thanks for sharing your workaround. 😊

It would still be great to be able to load them from the system as with @sparticuz/chrome-aws-lambda (and as with any non-headless browser). This way you can use common fonts like Roboto and Open Sans without having to load multiple individual blobs “by hand” and without having to declare them once for the signature and another once for the actual web content.