Munter / subfont

Command line tool to optimize your webfont loading. Aggressive subsetting based on your font use, self-hosting of Google fonts and preloading
MIT License
1.56k stars 29 forks source link

Using subfont/lib/subsetLocalFontWithHarfbuzz as API #138

Closed ind1go closed 3 years ago

ind1go commented 3 years ago

Hi! For my use case I don't need all the bells and whistles of subfont like its use of assetgraph or the way it performs replacement in HTML, I'm really more interested in just the subsetting area. I already know what the text is, and I'm not replacing in an HTML file.

In particular, in my prototyping I've been able to use subfont/lib/subsetLocalFontWithHarfbuzz.js to take text and a font file and subset it to a minimal font. Really I suppose I'm just capitalising on @papandreou's excellent work in harfbuzz/harfbuzzjs#9 to find the right incantation to control harfbuzzjs just right, and I don't want to have to independently maintain that code (that I don't understand), really! 😆

But of course doing this is undocumented and I suspect you wouldn't regard subfont/lib/subsetLocalFontWithHarfbuzz.js as API. I wondered whether you will give any thought to promoting it as API, either directly in subfont or by extracting it as a separately installable module. Thanks for your consideration.

papandreou commented 3 years ago

Thanks! Yeah, that's a good idea -- it's fairly clean. It does rely on /lib/convertFontBuffer.js, which is also used elsewhere in subfont, though. That file is also quite self-contained and generally useful, so maybe we should just turn them both into separate modules.

Then we just need to find some good names for the npm packages :)

ind1go commented 3 years ago

Oh no, that's always the worst part! 😆 Thanks for being so positive about the idea.

papandreou commented 3 years ago

Step 1 complete: https://github.com/papandreou/fontverter (adopted in https://github.com/Munter/subfont/pull/139)

Can you come up with a bad pun on harfbuzz and/or subsetting as a name for the other module?

papandreou commented 3 years ago

Step 2: https://github.com/papandreou/subset-font (adopted in #140)

ind1go commented 3 years ago

Thanks, I drew a blank at puns I'm afraid!