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

Better error message for the non-support of WOFF fonts #1259

Closed
vpoulailleau opened this issue Dec 2, 2020 · 4 comments
Closed

Better error message for the non-support of WOFF fonts #1259

vpoulailleau opened this issue Dec 2, 2020 · 4 comments

Comments

@vpoulailleau
Copy link

Thanks for WeasyPrint, I love it!

I lost 1 hour trying to use my @font-face and trying several options (local files, remote files, absolute and relative paths…). I finally discovered that WOFF and WOFF2 fonts are not supported (18010a1) and this is totally OK, I know you're working on removal of cairo and better support.

In the meantime, I think that the following error message:

WARNING: Font-face "Open Sans" cannot be loaded

may be replaced with

WARNING: Font-face "Open Sans" cannot be loaded because WOFF and WOFF2 fonts are not currently supported

I saw an exception here: https://github.com/Kozea/WeasyPrint/blob/master/weasyprint/fonts.py#L357

Maybe it's possible to catch it somewhere and provide a clearer message?

What do you think? (You may answer that I'll just have to wait for the support of WOFF and WOFF2 fonts 😉)

@liZe
Copy link
Member

liZe commented Dec 2, 2020

Hello! Thank you for reporting this issue.

You may answer that I'll just have to wait for the support of WOFF and WOFF2 fonts

Right, it’s even already supported in the pydyf branch 😉.

In the meantime, I think that the following error message:

WARNING: Font-face "Open Sans" cannot be loaded

may be replaced with

WARNING: Font-face "Open Sans" cannot be loaded because WOFF and WOFF2 fonts are not currently supported

It’s a bit more complicated than that: this warning is displayed when loading all the different fonts if one @font-face rule have failed. We may have different reasons why loading different fonts fail, we can’t have a specific message here.

But the message of the exception is displayed when you launch WeasyPrint with the --debug option. It’s not useful to display it as a warning, because font-face rules often contain fallback fonts, and one import failing doesn’t mean that the whole font-face rule is failing.

A clean way to do this would be to store the exceptions in a list and display them after the warning message (as warning messages) when they all fail.

Now that WOFF(2) fonts are supported, I’m not sure that it’s really useful to have this feature. Letting developers know that there’s a --debug option is probably a better idea 😄.

@vpoulailleau
Copy link
Author

OK, thanks for all this information. The --debug option is exactly what I needed (I read too fast the --help result…), I now get some messages that indicate the lack of support of WOFF fonts.

I'll try the pydyf branch.

@liZe Just to know, when is it planned to use this branch as the new master branch?

@grewn0uille
Copy link
Member

Hi @vpoulailleau! Please have a look at #1232 (comment) :)

@vpoulailleau
Copy link
Author

Hi @grewn0uille! Thanks for the good news and for WeasyPrint/pydf!

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

No branches or pull requests

3 participants