inter icon indicating copy to clipboard operation
inter copied to clipboard

Bundle size. A way to disable unused glyphs?

Open ivan-kleshnin opened this issue 2 years ago • 1 comments

I would like to reduce a bundle size by removing unnecessary font glyphs.

Here's a screenshot from https://yellowlab.tools analysis for a landing page of one of my projects:

Screenshot 2023-10-25 at 15 56 43

Weight	222 KB
Number of glyphs	2548 (better < 500)
Average glyph complexity	31.4

It seems like I could decrease those staggering 222Kb somewhat closer to more reasonable 20Kb – by dropping glyphs I was never even going to use. Now I understand it's more about packaging and distribution than about the font itself.

Unfortunately, as I'm searching for tools that can repackage font files and drop certain glyphs, I find only paid services like https://nitropack.io or limited libraries like https://github.com/funbox/beatrix (can produce WOFF but the input must be TTF/OTF). 😞

Wouldn't it be great to have some UI with checkboxes for glyph families at https://rsms.me/inter/download/ ?

Or if there's a well-known tool that can handle it and that I'm missing – please suggest (UI, CLI, anything) 🙏 I'm using Inter-roman.var.woff2 so it should support variable fonts.

ivan-kleshnin avatar Oct 25 '23 13:10 ivan-kleshnin

@ivan-kleshnin i've had good experience using https://github.com/zachleat/glyphhanger to subset fonts

adamkiss avatar Nov 01 '23 11:11 adamkiss

As the website FAQ mentions, try FontTools' pyftsubset

glyphhanger as mentioned by @adamkiss works too, but is a more complex tool which AFAIK only works for websites.

In the future when you have a question, please don't file an issue! Instead, ask your question in "Q&A" Inter is a pro-bono project and my time is very precious. Plus, in "Discussions" other people might be able to help you more easily.

rsms avatar Mar 22 '24 19:03 rsms

@rsms I'll just note that while it has website spider mode, you can also just provide character set and/or custom string to subset - I know I've never used the spider mode through my websites, just gave it the subset.

adamkiss avatar Mar 22 '24 20:03 adamkiss