ckolderup / postmarks

a single-user bookmarking website designed to live on the Fediverse
https://postmarks.glitch.me
MIT License
459 stars 38 forks source link

Swap TTF fonts for WOFF2 compressed versions #95

Closed boogah closed 9 months ago

boogah commented 10 months ago

While spinning up a Postmarks site and customizing the CSS, I noticed that the TrueType version of the Public Sans web fonts are being used. I understand that this was likely done because the variable versions are only publicly available for download as TrueType files.

Fortunately, WOFF2 supports variable fonts — you just have to compress them using Google's library.

I did just that and more than halved the file sizes of each:

$ woff2_compress PublicSans-Italic-VariableFont_wght.ttf
Processing PublicSans-Italic-VariableFont_wght.ttf => PublicSans-Italic-VariableFont_wght.woff2
Compressed 99991 to 44431.

$ woff2_compress PublicSans-VariableFont_wght.ttf
Processing PublicSans-VariableFont_wght.ttf => PublicSans-VariableFont_wght.woff2
Compressed 95795 to 41419.

Allegedly, 95% of folks use browsers that support WOFF2, so it's safe to use it instead of TTF. If you'd like, I can get a PR in that changes the TTFs over to their WOFF2 counterparts.

ckolderup commented 10 months ago

sounds great-- the OFL allows us to do this conversion, right? As long as that's true this sounds like a good move, especially if we're encouraging people to self-host since that sometimes means they pay their own bandwidth bills. Would definitely accept a PR!

boogah commented 10 months ago

It seems to be permitted under the OFL, yes. 😅

I'll carefully convert them, modify the CSS, and get the PR in.