Repository navigation
Add SVG export - #1729
Add SVG export#1729
Conversation
support export text with outline glyph
|
Tests are difficult, we also don't have tests for PDF export for the same reason. At least the bug surface is not too large in 400 lines of code. Comparing against the reference images would be great, but I imagine we'd need some fuzzy comparison because different rendering engines produce every so slightly different results. The transforms in |
|
The previous PR did test SVG in typst like PDF, and you can simply cherry pick this commit f95cb97. Another solution is to hash the images by perceptual-hash and keep tracking them in VCS and CI. You are free to maintain the simplified SVG exporter together with integration test of typst.ts. For example of VCS & snapshot testing, see the function typst.ts@79bfdeb1:test_wasm_renderer_functionality. For example of CI, see Action: typst.ts#974, which attaches a chrome browser's rendering report, wasm-renderer-chrome.test_points.json.gz. Also see a error report by cargo test in Action: typst.ts#349. These two integration tests work well so far. They never bother you until a pixel-by-pixel difference happens between commits. |
|
I think having an SVG folder is good for now. We can then look into perceptual hashing and more automated SVG/PDF testing separately. |
|
It appears that the test code in png export creates a long png file by connecting the pages in the document. Perhaps we can do the same for SVG export. Inaddition to individual SVG files, we can rasterize SVG pages into pixmap and concat them together. To validate it, we can compare it to the result of a PNG export. |
|
Merging SVG files seems sensible. Validating them by rasterizing them and comparing them might work but could very well fail because of slightly different rendering. |
except for path2d builder
|
I am not an expert in layout and publishing. Can anyone tell me how much |
Get it. But I'd rather stick to ppi = 72. Unlike PNG export, ppi doesn't affect the sharpness of the SVG file. Another problem is that implementing ppi control would require significant changes to current code , which I am not inclined to do. |
|
I'd prefer to leave testing out of this PR. |
It does. You're either writing them wrong or it's a bug. |
Thanks for figure it out. I used the wrong mimetype. Another problem is that typst disables default features of resvg so raster-images doesn't work. |
|
Just have a performance test on https://github.com/werifu/HUST-typst-template/blob/main/sample.typ?rgh-link-date=2023-07-27T13%3A39%3A23Z#L32. It takes about 50ms to export from scratch and 30ms to incrementalize. I expect it to be faster on your machine because I'm using an old arm64 cpu: Kunpeng 920, developed by Huawei serveral years ago. |
|
Just wanted to say that I'll probably won't get to taking a last look and merging this week because I'm quite busy with web app stuff, but I'll definitely get to it next week! |
|
Thank you, great work! |
|
Just discovered typst in amazement and also discovered from this bug report that svg export might also be coming soon. Looking forward for this feature as it will make it possible to use typst also in conjunction with WYSIWYG word processors and presentation editors such as Libreoffice Writer and Impress as an equation editor in the lines of TeXMaths that is quite nice but slow. Hope a TypMaths can come soon! |
it is already included in typst v0.8.0 |
|
Missed that, some bit of the documentation might still mention only PDF and PNG. |
can you show some pointers to these docs? so we can update them 💪 |
|
Looked for it, but no, it was not a bug in the Typst documentation, it was a bug in my memory! |
This PR is based on @Myriad-Dreamin's PR #1517 but in a simplified fashion.
possibly fix #863
TODO:
- [ ] Snapshot testTests will come in the following PRs. Perhaps using snapshot test technique.This PR is like a fast prototype and there are still many things to be done to make it more polished and stable.I think it is ready now!