Closed ohmyarch closed 2 weeks ago
Thanks for raising the issue @ohmyarch, we should list this as a known limitation in the README.
As context, how are you using vl-convert, and in what kind of situation is this limitation causing issues for you?
Draw a vector map to svg, and then use vl-convert-pdf to output it to pdf. Some elements in the map, such as titles and legends, need to be overlaid on the base map. But there may be text labels on the base map below them. Therefore, in similar scenarios, this bug or limitation will cause some display confusion.
By the way, can this problem be avoided by using the original version of svg2pdf? I have a confusion about it. Its documentation tells me that text will be converted into shapes, but the same svg, such as the above example, only retains text elements, and uses svg2pdf to output, there will be nothing on the pdf.
Yeah, svg2pdf by itself will convert text to paths and should preserve proper layering of text under shapes.
vl-convert-pdf first runs svg2pdf without converting text to paths, so that svg2pdf renders everything except text. Then it performs its own logic to embed and overlay the text.
The long term solution here is probably to integrate text embedding logic into svg2pdf, but that will take a bit of effort. See https://github.com/typst/svg2pdf/issues/21 for more background.
Text embedding has been merged into svg2pdf in https://github.com/typst/svg2pdf/pull/64 (thanks @LaurenzV!), so after the next svg2pdf release we should be able to switch to this and drop our vl-convert-pdf
crate which always layers text on top.
Yeah, it should work just like that now! Also feel free to test it, if you want to try it before the release. The only caveat right now is that if a CFF font is selected for some text, it might result in rather large file sizes (see also https://github.com/typst/svg2pdf/issues/66). But it should work pretty well otherwise, all test cases that worked before still work now.
Not sure when the next release will be though, first we need a new resvg
release and there are also some other smaller things I need to add before we can make a new release. But hopefully within the next 1-2 months.
Thanks for the context @LaurenzV! No rush from our side, I'll keep an eye out for release notifications. And I'll let you know if I find time to test it out before release.
Fixed in 1.5.0
svg:
pdf: