-
-
Notifications
You must be signed in to change notification settings - Fork 711
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
font face src with query not found on filesystem #687
Comments
An example to reproduce the problem :
And the weasyprint code :
|
This pull request proposes a fix for this : #688 |
Dirty problem… Thanks for the example. I'm afraid the problem is a little bit more complex, and is actually in Python: >>> from urllib.request import urlopen
>>> urlopen('file:///tmp/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf')
<addinfourl at 140212679104720 whose fp = <_io.BufferedReader name='/tmp/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf'>>
>>> urlopen('file:///tmp/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf?test')
Traceback (most recent call last):
File "/usr/lib/python3.7/urllib/request.py", line 1473, in open_local_file
stats = os.stat(localfile)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf?test' This behavior is actually OK when reading RFC 8089: query strings are not defined with the Unfortunately, browsers (including curl) allow query strings with the I've open an issue on Python's bug tracker, I'll wait for their answer before deciding what to do. |
@arthru - on Non-Windows you could provide your own url_fetcher_function (which cuts off the query string) to WeasyPrint's @liZe - on Windows we load font files via |
Yes, and if Python doesn't want to fix the "problem" in the standard library, that's probably in the default fetcher that #688's code should be applied.
Oh, I see what's in font.py… That's a different, unrelated problem: in |
Stupid me, of course only external
Because on Windows the hack would be |
And I'd rather rely on pathlib for that 😉. |
Also, always use the system's file encoding, as it's utf-8 on macOS and should be OK on Unix for recent versions of Windows. Related to #687.
@arthru's FontAwesome example works for me on Win7, produces smiling As expected @liZe to distinguish a |
Version 43 ---------- Released on 2018-11-09. Bug fixes: * `#726 <https://github.com/Kozea/WeasyPrint/issues/726>`_: Make empty strings clear previous values of named strings * `#729 <https://github.com/Kozea/WeasyPrint/issues/729>`_: Include tools in packaging This version also includes the changes from unstable rc1 and rc2 versions listed below. Version 43rc2 ------------- Released on 2018-11-02. **This version is experimental, don't use it in production. If you find bugs, please report them!** Bug fixes: * `#706 <https://github.com/Kozea/WeasyPrint/issues/706>`_: Fix text-indent at the beginning of a page * `#687 <https://github.com/Kozea/WeasyPrint/issues/687>`_: Allow query strings in file:// URIs * `#720 <https://github.com/Kozea/WeasyPrint/issues/720>`_: Optimize minimum size calculation of long inline elements * `#717 <https://github.com/Kozea/WeasyPrint/issues/717>`_: Display <details> tags as blocks * `#691 <https://github.com/Kozea/WeasyPrint/issues/691>`_: Don't recalculate max content widths when distributing extra space for tables * `#722 <https://github.com/Kozea/WeasyPrint/issues/722>`_: Fix bookmarks and strings set on images * `#723 <https://github.com/Kozea/WeasyPrint/issues/723>`_: Warn users when string() is not used in page margin Version 43rc1 ------------- Released on 2018-10-15. **This version is experimental, don't use it in production. If you find bugs, please report them!** Dependencies: * Python 3.4+ is now needed, Python 2.x is not supported anymore * Cairo 1.15.4+ is now needed, but 1.10+ should work with missing features (such as links, outlines and metadata) * Pdfrw is not needed anymore New features: * `Beautiful website <https://weasyprint.org>`_ * `#579 <https://github.com/Kozea/WeasyPrint/issues/579>`_: Initial support of flexbox * `#592 <https://github.com/Kozea/WeasyPrint/pull/592>`_: Support @font-face on Windows * `#306 <https://github.com/Kozea/WeasyPrint/issues/306>`_: Add a timeout parameter to the URL fetcher functions * `#594 <https://github.com/Kozea/WeasyPrint/pull/594>`_: Split tests using modern pytest features * `#599 <https://github.com/Kozea/WeasyPrint/pull/599>`_: Make tests pass on Windows * `#604 <https://github.com/Kozea/WeasyPrint/pull/604>`_: Handle target counters and target texts * `#631 <https://github.com/Kozea/WeasyPrint/pull/631>`_: Enable counter-increment and counter-reset in page context * `#622 <https://github.com/Kozea/WeasyPrint/issues/622>`_: Allow pathlib.Path objects for HTML, CSS and Attachment classes * `#674 <https://github.com/Kozea/WeasyPrint/issues/674>`_: Add extensive installation instructions for Windows Bug fixes: * `#558 <https://github.com/Kozea/WeasyPrint/issues/558>`_: Fix attachments * `#565 <https://github.com/Kozea/WeasyPrint/issues/565>`_, `#596 <https://github.com/Kozea/WeasyPrint/issues/596>`_, `#539 <https://github.com/Kozea/WeasyPrint/issues/539>`_: Fix many PDF rendering, printing and compatibility problems * `#614 <https://github.com/Kozea/WeasyPrint/issues/614>`_: Avoid crashes and endless loops caused by a Pango bug * `#662 <https://github.com/Kozea/WeasyPrint/pull/662>`_: Fix warnings and errors when generating documentation * `#666 <https://github.com/Kozea/WeasyPrint/issues/666>`_, `#685 <https://github.com/Kozea/WeasyPrint/issues/685>`_: Fix many table layout rendering problems * `#680 <https://github.com/Kozea/WeasyPrint/pull/680>`_: Don't crash when there's no font available * `#662 <https://github.com/Kozea/WeasyPrint/pull/662>`_: Fix support of some align values in tables
When using fontawesome from filesystem, the font is not displayed in generated pdf.
Fontawesome uses the following declaration :
In that cases, the query part (following ? in src url) is interpreted as part of the filename, which is not.
As a fix, I would suggest to improve
weasyprint.css.descriptors.preprocess_descriptors
by removing the question mark and what follows in src url whenbase_url
starts withfile://
The text was updated successfully, but these errors were encountered: