Creating font names using hyphens causes problems with some other applications
Hi,
I have a small project where I'm exporting a blog to PDF to make a book and I'm really impressed by how well Weasyprint handles this!
The next step is to layout the book using Affinity (and other applications) and, unfortunately, this complains that it can't find the fonts. I've managed to track this down to the fact that Weasyprint replaces spaces in font names with hyphens:
https://github.com/Kozea/WeasyPrint/blob/main/weasyprint/pdf/fonts.py#L65
I can work around some of this in the CSS but it also happens to system fonts such as Apple Color Emoji which are being automatically used. It seems that the standard might be simply to remove the spaces. Would that be an option? Hyphens were obviously chosen with a reason, so I'm not sure of the best way of adding a workaround for this except using some kind of configuration file. And obviously I can monkey patch my installation.
Slightly related is the fact that the default style of the font, ie. regular, is not included in the name. In my case I've managed to fix LeMondeJournalStd-Bold and LeMondeJournalStd-Italic in CSS, but the default is being stored as LeMondeJournalStd where it should be LeMondeJournalStd-Regular.
This is using Weasyprint 70.0 on Python 14 on MacOS 15.8.
Source: Kozea/WeasyPrint