WOFF font not included in PDF
See original GitHub issueIf I follow the example below but use a WOFF font.
font-face
is parsed correctly but the actual font file is NOT included in the PDF,
resulting in output with “missing unicode characters” blocks…
Documentation claims any FreeType font format should be supported.
from weasyprint import HTML, CSS
from weasyprint.fonts import FontConfiguration
font_config = FontConfiguration()
html = HTML(string='<h1>The title</h1>')
css = CSS(string='''
@font-face {
font-family: Gentium;
src: url(http://example.com/fonts/Gentium.otf);
}
h1 { font-family: Gentium }''', font_config=font_config)
html.write_pdf(
'/tmp/example.pdf', stylesheets=[css],
font_config=font_config)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
PDF fonts, Adobe Acrobat
Follow these steps in Adobe Acrobat to embed and substitute fonts in PDFs, and preview PDFs without local fonts.
Read more >The Missing Guide to Font Formats: TTF, OTF, WOFF, EOT ...
The Missing Guide to Font Formats: TTF, OTF, WOFF, EOT & SVG ... that specifies if the author allows embedding of the font...
Read more >The Web Open Font Format (WOFF) - Developer guides | MDN
WOFF (the Web Open Font Format) is a web font format developed by Mozilla in concert with Type Supply, LettError, and other organizations....
Read more >Flying saucer does not load font from googleapis font css in ...
The old version of iText used by Flying Saucer doesn't support Web Open Font Format (WOFF) fonts. Support for such fonts was only...
Read more >How to set a font in a PDF document | Piotr Horzycki
The so-called “web fonts” are usually compressed with a WOFF2 format which is not supported by PDF. Google Fonts, a popular web font...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As far as I can remember, WOFF (and now WOFF2) fonts are supported by FreeType, but for some reason they’re not included in the PDF, probably because of Cairo. It’s sad because FreeType doesn’t complain, Cairo doesn’t complain, and everything works as if the font could be embedded. At least when the format is not supported we have a warning and we can get another fallback format if possible…
This will be solved when Cairo is replaced by another library (you can follow #1232 for more news about this topic).
WOFF and WOFF2 support has been disabled for the next release (52), with a clean fallback to other formats if possible. Documentation has been fixed too. Unless someone finds a better solution, we’ll have to wait for version 53 (without Cairo) to have WOFF fonts supported by WeasyPrint.