You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This results in , where the text is missing in the first image.
Any matplotlib file will do, but I used this one (i had to change the extension to txt so Github wouldn't try to be helpful and upload it to user-images instead)
The Cairo based Weasyprint 52 doesn't have this problem.
I analysed the problem, and that's what I could figure out:
svg.defs.use calls node.get_href, which calls get_url_attribute, which calls url_join. This in turn calls stdlib's urljoin, and this seems to distinguish between schemes that "use relative", and those that don't. Obviously, "bug" is not in that list, and therefore just seems to return the url unchanged.
So, back in svg.defs.use, the node.get_href will return #DejaVuSans-66 instead of bug://#DejaVuSans-66, which is what the next if statement (line 29 in Weasyprint 54.3) expects. Since the first part doesn't match, it falls back to trying to fetch the URL, which, when it fails, just silently returns (NB: It would be nice if it could at least print a warning that a resources linked via <use> couldn't be found, that would have helped me save a lot of time tracking this bug down)
When the URLs are of the form file://netloc/xyz, it works, this is the workaround I currently use. But since it's a regression from how Weasyprint 52 behaved, I think it should either be fixed, or at least be documented as a gotcha when implementing custom url fetchers.
The text was updated successfully, but these errors were encountered:
By default, Matplotlib renders fonts as paths and adds references to a particular letter path using eg.
<use xlink:href="#DejaVuSans-66"/>
.Those use links will be silently ignored when the svg was loaded by a custom fetcher with a scheme different from file:
This results in
, where the text is missing in the first image.
Any matplotlib file will do, but I used this one (i had to change the extension to txt so Github wouldn't try to be helpful and upload it to user-images instead)
The Cairo based Weasyprint 52 doesn't have this problem.
I analysed the problem, and that's what I could figure out:
svg.defs.use calls
node.get_href
, which callsget_url_attribute
, which callsurl_join
. This in turn calls stdlib'surljoin
, and this seems to distinguish between schemes that "use relative", and those that don't. Obviously, "bug" is not in that list, and therefore just seems to return the url unchanged.So, back in
svg.defs.use
, thenode.get_href
will return#DejaVuSans-66
instead ofbug://#DejaVuSans-66
, which is what the next if statement (line 29 in Weasyprint 54.3) expects. Since the first part doesn't match, it falls back to trying to fetch the URL, which, when it fails, just silently returns (NB: It would be nice if it could at least print a warning that a resources linked via<use>
couldn't be found, that would have helped me save a lot of time tracking this bug down)When the URLs are of the form
file://netloc/xyz
, it works, this is the workaround I currently use. But since it's a regression from how Weasyprint 52 behaved, I think it should either be fixed, or at least be documented as a gotcha when implementing custom url fetchers.The text was updated successfully, but these errors were encountered: