-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to isolate each SVG from a TTF font so the symbols are all scaled properly? #592
Comments
This is what I am seeing when doing |
Maybe we can add an additonal parameter or method to output an SVG for glyphs or text including all the spacing. |
Layout-wise (so in an HTML/CSS context) setting a fixed width for an (Clunky) proof of conceptSee this codepen example
The first lines are essentially just retrieving metrics values: either globally from the font (such as ascender, descender UnitsperEm etc.) as well as specific to the glyph (e.g. left side bearing, advance width ... or not necessarily needed a "right side bearing" calculated from boundingBox and advanceWidth). |
After browsing through several issues on the opentype.js repo and fontkit, I landed on this code which isolates the SVGs for each glyph it seems like (mixed in here is some Next.js API code):
It appears when looking at the SVG renderings, that the symbols have a tight bounding box. This seems to mean if you were to place them side by side with each the same width and height container, they would be all jumbled. How do you get the SVGs to output so they are all proportionally laid out correctly? So if you were to put them in a square for example, they would all be the appropriate relative size, not scaled strangely. I'm not sure my code will do that, but am looking to get the SVGs as they would appear in the font, so if you lay them out, you could put several SVG "letters" next to each other and it would read like normal text renderings.
Any help would be greatly appreciated, thanks!
Also, since it appears opentype.js hasn't been published in a few years, I forked it and added a version number to the package.json, and added the dist folder to the repo so I could git clone the commit with yarn. That seems to give me the latest version. Hoping we can get a more official release though so that hack isn't necessary :)
The text was updated successfully, but these errors were encountered: