←back to thread

An SVG is all you need

(jon.recoil.org)
281 points sadiq | 1 comments | | HN request time: 0.196s | source
Show context
codedokode ◴[] No.46240238[source]
Downsides of using SVG:

- cannot wrap text

- cannot embed font glyphs - your SVG might be unreadable if the user doesn't have the font installed. You can convert letters to curves, but then you won't be able to select and edit text. It's such an obvious problem, yet nobody thought of it, how? Photoshop solved this long time ago - it saves both text and its rendering, so the text can always be rendered.

- browsers do not publish, which version and features they support

- may contain Javascript and references to external resources, which makes it difficult to view in a secure, isolated environment

One of solutions is having two SVGs: author version, which you edit in Inkscape and which uses Inkscape-specific extensions, and published version, which is generated from the first, that uses only basic features and has text converted to curves.

replies(2): >>46240554 #>>46241317 #
bobbylarrybobby ◴[] No.46240554[source]
Safari supports base64-embedding font files in a <style>’s @font-face {} (iirc it's something like `@font-face { src: url('data:application/x-font-woff;charset=utf-8;base64,...'); }`) that can then be referenced as normal throughout the SVG. I don't recommend this though, nobody wants to deal with 500KB SVGs.
replies(2): >>46242112 #>>46242806 #
1. codedokode ◴[] No.46242806[source]
The idea was that you can embed only the glyphs used in a text. For example, instead of embedding thousands of existing Chinese characters, embed only 20 of them. Embedding is necessary anyway because otherwise you cannot guarantee that your image will be displayed correctly on the other machine.

Also, allowing CSS inside SVG is not a great idea because the SVG renderer needs to include full CSS parser, and for example, will Inkscape work correctly when there is embedded CSS with base64 fonts? Not sure.