Closed davidgodzsak closed 3 years ago
Please share the examples that suggest that the current logic is incorrect.
Here are a few examples using KoHo-Regular from google fonts:
J:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -1000 1000 1000">
<path fill="#000000" d="M30 -74L73 -119Q104 -81 139.5 -64Q175 -47 225 -47Q299 -47 339 -84.5Q379 -122 379 -192V-700H451V-190Q451 -93 393 -41Q335 11 227 11Q162 11 116.5 -8.5Q71 -28 30 -74Z"/>
</svg>
,:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -1000 1000 1000">
<path fill="#000000" d="M154 -27Q154 19 136 54.5Q118 90 81 122L59 100Q84 77 96.5 54Q109 31 110 5Q102 11 87 11Q70 11 60 -0.5Q50 -12 50 -32Q50 -53 65.5 -71Q81 -89 103 -89Q127 -89 140.5 -73Q154 -57 154 -27Z"/>
</svg>
}:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -1000 1000 1000">
<path fill="#000000" d="M30 -74L73 -119Q104 -81 139.5 -64Q175 -47 225 -47Q299 -47 339 -84.5Q379 -122 379 -192V-700H451V-190Q451 -93 393 -41Q335 11 227 11Q162 11 116.5 -8.5Q71 -28 30 -74Z"/>
</svg>
The SVGs are being generated as expected. The parts of the glyphs that are not visible are below the font's baseline. For your purposes, adjusting the viewBox may be something desired but it's a kind of change that should NOT be done by default. If you want to submit a patch, put it behind an option.
Hmm makes sense, but wouldn't it be desirable to also render the descender and a line gap under the font, when creating the SVG?
wouldn't it be desirable to also render the descender and a line gap under the font, when creating the SVG?
In the context of making OT-SVG fonts it's not desirable because the viewBox plays a role in how the SVG artwork is scaled and positioned within the line of text. If you start changing the viewBox to, for example, vertically center the paths within the window, all of the SVGs will also be vertically centered which is definitely not desired.
I created a PR for this https://github.com/adobe-type-tools/opentype-svg/pull/23, behind a flag.
Fixed by #23
I think to calculate the viewbox correctly we could use the minX, minY, maxX and maxY parameters from TTF header table instead of unitsPerEm. I have some fonts I transform with this tool that get clip out from the viewbox.
How could I submit a PR to fix this?