WeasyPrint: Can't load font using local()
Running from the default terminal on Windows 10, if I, after installing a custom font like Google’s Noto Sans JP, use this CSS in my HTML:
@font-face{ font-family: "Noto Sans JP"; src: local("Noto Sans JP") }
WeasyPrint will throw a “WARNING: Font-face “Noto Sans JP” cannot be loaded.”, and if there are a large number of CJK characters, produce a PDF with mojibake like these:

If I reduce the amount of CJK characters enough, the PDF will be rendered okay, but with the default system font (Meiryo).

But if I put url() instead of local() and update my CSS to:
@font-face{ font-family: "Noto Sans JP"; src: url("NotoSansJP-Regular.otf") }
Then the HTML is rendered as it should be, with the custom font.

About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (10 by maintainers)
On CentOS, I think that the fix has been packported into the cairo-1.17.4-3 package. Updating to this latest version will fix the problem.
On Windows, you can use a previous version of GTK+. Version 2020-11-22 includes Cairo 1.17.2 that doesn’t have this bug.