Replies: 6 comments 3 replies
-
Strongly believe the font should not be included by default. We should have a flag for bundling a font. By default, we ought to render with the measurements of Arial and then ensure we have sufficient padding in case the user machine uses a different font. We could embed a script in the SVG that allows a user to click a settings icon in the corner and select a new font from what they have installed if it doesn't look right. Or adjust the font size. |
Beta Was this translation helpful? Give feedback.
-
Hey thanks for providing this awesome tool 🙏 ! I just wanted to second the importance to users to offload the font loading. I just compiled the My use case is our internal markdown wiki. My idea would be to generate the SVGs on the fly and cache them in Redis. So not only for the browser but also our server infrastructure it would be nice if the SVGs would not contain the font. My "dream" API would be if I could provide the (web) font at rendering time for measuring and then just made sure at runtime it's available to the browser. |
Beta Was this translation helpful? Give feedback.
-
It would be convenient if both cases were supported for different workflows e.g. configurable with a compiler flag. For early prototyping it's convenient to have a fully self-contained svg to pass around, but for production cases the inflated file size is not ideal |
Beta Was this translation helpful? Give feedback.
-
I recently did something similar - feel free to steal anything that may be useful: https://github.com/pedrovhb/svgfontembed tl;dr is that it includes only the subset of characters which are actually found to be used in the SVG. Probably a bit easier in the case of d2, as you don't have to parse the file to find out what text is associated to what font (you know that at generation time). |
Beta Was this translation helpful? Give feedback.
-
I think having the option to not embed the fonts would be useful for further processing with tools that don't support |
Beta Was this translation helpful? Give feedback.
-
I use MkDocs and Roboto is available, so, I set all fonts for D2 to Roboto by default for consistency with other texts. Will be great if will be an option to avoid embeddings fonts. |
Beta Was this translation helpful? Give feedback.
-
Currently we base64 encode fonts (to WOFF mimetype) and include directly in the SVG. This is to ensure the SVG has reproducible appearance everywhere and regardless of network connections.
However, this can make the SVG file unwieldy:
The alternatives are:
Beta Was this translation helpful? Give feedback.
All reactions