Open Nova38 opened 8 months ago
I've seen tools like those. The problem is text. Text in SVG sucks, so we and many others inject a little HTML for text, which is unrenderable in these tools. See https://github.com/typst/svg2pdf/issues/57 .
I suppose we could do it twice. Grab a PNG of just the texts and overlay it on an SVG, but it's hairy. I'll leave it open for a OneDay task
Hmm when I ran in on my desktop I think that it did render the text fine. It just rendered it as part of the vectorized path and not as text. The text was not selectable/embedded but instead it was still vectorized.
I am away from my computer at the moment so I don't have the d2 -> svg -> pdf that is the direct output of the tool I linked above, however that tool is the library that typst uses to render svg's in their documents. I have included below a link that contains a link to a typst project that contains it rendering a few different svg's from various tools, including d2langs avg output
Oh interesting. Will have to take another look to verify
I think it might still need a post prossing step to add back in the hovertext
Currently the PDF export uses playwrite to grab a PNG, this results in a rasterized image instead of a vector image, which can cause a lower quality output. I have been playing around with typst, a alternative to latex, and they have a nice svg to pdf library that renders the svg's to a pdf. It seems to do a good job with foreign objects, unlike inkscape etc... who have trouble rendering the d2 svg's. It currently doesn't render the text as text, but as paths which is a small downside. But it's output is a vectorized pdf which retains the high quality of d2 diagrams. I mainly was looking into this as I wanted to use d2 to draw diagrams for latex, but found that the pdf output ended up not looking great when imbedded in a pdf.
https://github.com/typst/svg2pdf