-
Notifications
You must be signed in to change notification settings - Fork 14
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
Surface resvg font fallback warnings #50
Comments
Thanks for the report @hukka. I'm having trouble reproducing the issue though. What version of vl-convert are you using?
With current |
0.7.0. This is on Linux, so the binary is of course a bit different, but does it use anything from the system for rendering? |
The PNG rendering is handled by resvg which uses rustybuzz for text shaping. This library uses system fonts, but performs it's own text shaping. Let's see if we can reproduce this using resvg directly and a simpler SVG. Copy this text into an SVG file named <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100" height="100">
<rect width="100%" height="100%" fill="white" />
<text transform="translate(10,30)" font-family="sans-serif" font-size="20px" fill="#000">foo₂</text>
<text transform="translate(10,60)" font-family="sans-serif" font-size="20px" fill="#000">bar</text>
</svg> Then download and extract resvg-linux-x86_64.tar.gz from https://github.com/RazrFalcon/resvg/releases/tag/v0.30.0. This should give you a CLI executable named Convert the SVG above to PNG with:
When I do this, here's the PNG I end up with: The following warning is shown by resvg:
Do you see the bold effect in this example? We may need to play with the |
Indeed without the font flag, it just complains that there's no match for font family. With With |
If you're willing, I think it's probably worth opening an issue in the resvg repo with this example. ("Nimbus Sans" turning subscript text bold and "DejaVu Sans" not doing so). On the vl-convert side, we vendor "Liberation Sans" as a fallback (as it matches Arial quite well), so I'm guessing that you're also seeing the issue with Liberation Sans. |
Oddly I'll see if I can figure out why it doesn't seem to find fonts that should be there |
Ah, it's of course because resvg is trying to find a bold font, and I don't have Liberation Sans bold installed (if it even exists). If I remove the subscript from the svg, it uses Liberation Sans without complaints. |
Also oddly, |
Filed as linebender/resvg#609. I suppose the only thing vl-convert could do here is to show the warnings that resvg outputs. |
Font fallback was significantly revamped in #170, so we now have a place to raise a warning or exception if we want to. See vl-convert/vl-convert-rs/src/text.rs Line 187 in d3da690
We do currently write a warning log with the rust log crate, but turning this into a Python warning will take a bit of routing. Related: #47 |
For some reason if text with character "₂" (subscript 2) is rendered with vg2png, the whole text is rendered as bold. vg2svg and the online vega editor do not render the text like that.
For example this document
with command
vl-convert vg2png --input visualization.vg.json --output test.png
will render likewhile
vl-convert vg2svg --input visualization.vg.json --output test.svg
likeThe text was updated successfully, but these errors were encountered: