Prologue
For the past few years, I (Florian Lefebvre) have worked quite a lot on fonts. I built Astro’s Fonts API, which became stable in Astro 6.0. It is heavily inspired by Nuxt’s Fonts module and Next.js font optimization.
While working on it, I made sure to decouple it from Astro internally, so other frameworks could benefit from it too, for example as a Vite plugin.
But thinking more deeply about font optimization on the web, I realized something: I had never questioned whether shipping it as a package was the right approach in the first place. And if you’re reading this, it means I think there’s a better way.
The package approach comes with a few downsides:
- It only works for a given ecosystem or tool (Astro, Next.js, Nuxt, Vite) and would need to be redone from scratch for others such as Laravel or Rails.
- The abstraction, however thin, makes more advanced use cases harder: granular preloads, programmatic access for OG image generation, and so on.
So I thought about a different take, inspired by shadcn/ui: what if a CLI downloaded the files once, and then they were yours?
That’s Leturgerð. You get the convenience of a package without giving up ownership of your files:
- Just like with a package, you pick exactly what you want: family, weights, styles, formats, subsets…
- The files are downloaded and self-hosted, so there are no requests to third-party services and your users’ privacy is preserved.
- You get fallback optimization, if you want it (coming soon).
- The files are yours: preload only the ones you need, read them to use with Takumi, do anything.
- It works with any tool: it’s just font and CSS files.