unjs

unjs/fontaine

TypeScript MIT Web Dev

Automatic font fallback based on font metrics

2k stars
44 forks
recent
GitHub

2k

Stars

44

Forks

38

Open issues

19

Contributors

AI Analysis

Fontaine automatically generates font fallback metrics to reduce Cumulative Layout Shift (CLS) in web applications by using crafted local font substitutes. It integrates with build tools (Vite, Webpack, Astro, Next.js, Gatsby, Docusaurus) to inject CSS font-face overrides at build time with zero runtime overhead. Best suited for performance-conscious web teams building sites where custom fonts are critical but CLS must be minimized; less relevant for applications where font loading is not a p...

Web Dev Developer Tool Discovery value: 6/10
Documentation 8/10
Activity 9/10
Community 8/10
Code quality 8/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

font-optimization cls-reduction web-vitals build-plugin performance
Actively maintained Well documented MIT licensed Niche/specialized use case Production ready
Deep Analysis · Based on README and public signals
5d ago

Fontaine automates CSS font fallbacks to eliminate layout shift—a narrow but well-solved web performance problem.

Fontaine is a TypeScript build-time tool that generates system font fallbacks with matched metrics to prevent Cumulative Layout Shift (CLS) when web fonts load. It integrates with Vite, Webpack, Astro, Next.js, Docusaurus, and Gatsby. The problem is specific: web fonts cause visible text reflow. The solution is elegant: inject CSS font-face overrides that mimic the custom font's dimensions using OS fonts. Adoption appears concentrated in the Nuxt/Astro ecosystem and among performance-conscious teams, but real-world usage numbers are not publicly documented.

Origin

Created in September 2022 by the unjs collective, Fontaine emerged as a direct response to CLS scoring in Core Web Vitals and the prevalence of font loading issues. It represents a pragmatic approach to a well-understood web performance problem—using CSS metrics tuning rather than runtime JavaScript.

Growth

Fontaine gained 1,962 stars over ~4 years with steady but modest incremental growth (1 star in last 7 days as of 2026-07-06). Last push 2026-06-25 indicates active maintenance. Growth appears driven by Web Vitals awareness in the development community and integration into Nuxt ecosystem via nuxt-font-metrics wrapper, rather than viral adoption. Comparable projects (Fontsource ~6k stars, google-webfonts-helper ~13k stars) serve broader font distribution use cases, while Fontaine's narrower problem scope likely explains smaller star count.

In production

Adoption not verified through public metrics. Evidence of intentional use: (1) Nuxt ecosystem integration via danielroe's nuxt-font-metrics, suggesting adoption in Nuxt projects; (2) Documented integration patterns for Astro, Next.js, Docusaurus, Gatsby imply these teams have tested it; (3) Online playground with before/after CLS comparison (0.24→0.054) demonstrates real impact on a test site. However, no public case studies, known enterprise users, or download statistics provided. Adoption may be undercounted because fontaine is often used transitively (via nuxt-font-metrics) rather than directly.

Code analysis
Architecture

Appears to be a multi-plugin architecture exposing Vite and Webpack adapters from a core module. README shows TypeScript codebase with documented plugin configuration for major frameworks. Likely uses CSS AST parsing or @font-face injection to mutate stylesheets and generate synthetic font-face rules. The `resolvePath` and `fallbackName` callbacks suggest pluggable path resolution and naming strategies.

Tests

Not documented in README excerpt. Codecov badge present in header but no coverage metrics disclosed. Testing approach unknown from available metadata.

Maintenance

Last push 2026-06-25 (11 days before analysis date) indicates active, recent maintenance. Repository includes CHANGELOG and online Stackblitz playground, suggesting attention to user experience and documentation. MIT license and public GitHub presence typical of well-maintained open-source projects. No evidence of abandonment or stagnation.

Honest verdict

ADOPT IF: your site uses custom web fonts, you have measured CLS as a problem, and you use Vite/Webpack-based tooling (Astro, Next.js, Nuxt recommended). Fontaine solves a real, measurable problem with zero runtime overhead and integrates cleanly into modern build pipelines. AVOID IF: you already use font-display: swap or have optimized font loading via preload/prefetch to the point where CLS is minimal. Fontaine adds build-time complexity for diminishing returns if the underlying font delivery is already tuned. MONITOR IF: you are evaluating it for non-standard build systems (e.g., Rollup-only, custom bundlers) or require per-locale fallback configuration—verify plugin compatibility before committing.

Independent dimensions

Mainstream potential

3/10

Technical importance

7/10

Adoption evidence

3/10

Risks
  • Adoption appears limited primarily to Nuxt/Astro communities; integration friction may exist for teams using Webpack 4, esbuild, or custom builders not listed in README.
  • No public real-world usage metrics (npm downloads, known deployments) make it difficult to assess reliability signal in production at scale.
  • Build-time introspection of font files (reading metrics from .woff2/.ttf) may fail silently or incorrectly if font formats are atypical or tools cannot resolve file paths—resolvePath callback is required, adding configuration burden.
  • CSS variable fallback approach (e.g., Docusaurus example) requires manual template edits, reducing appeal of 'automatic' claim and introducing maintenance risk.
  • Long-term viability depends on continued maintenance by unjs collective; project has no evidence of secondary contributors or organizational backing.
Prediction

Fontaine will likely remain a specialized, stable tool with gradual adoption in performance-conscious teams and the Nuxt/Astro ecosystems. Growth may accelerate modestly if Core Web Vitals remain a Google ranking factor, but it will not become a standard dependency like Webpack or TypeScript. Potential for adoption in frameworks that adopt it as a built-in (e.g., Next.js, Astro shipping it by default) would significantly expand usage.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

TypeScript
90%
CSS
4.4%
HTML
2.3%
JavaScript
2.1%
Vue
0.6%
Svelte
0.6%

Information

Language
TypeScript
License
MIT
Last updated
2w ago
Created
46mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Similar repos

fontsource

fontsource/fontsource

Fontsource is a monorepo that packages open-source fonts as individual NPM...

6k TypeScript Web Dev
ecomfe

ecomfe/fontmin

Fontmin is a Node.js tool for minifying and subsetting font files (TTF, OTF,...

6.2k JavaScript Web Dev
majodev

majodev/google-webfonts-helper

google-webfonts-helper is a web service and tool that enables self-hosting of...

13k TypeScript Web Dev
vs. alternatives
Fontsource

Broader scope: curates and distributes open-source fonts. Solves font sourcing, not fallback metrics. Can be used alongside Fontaine.

google-webfonts-helper

Focuses on self-hosting Google Fonts. Solves font download and subsetting, not CLS prevention. Different problem domain.

Font-face loader plugins (webpack/Vite native)

Generic loaders handle font files but don't solve the metrics-mismatch problem Fontaine addresses. Fontaine is specialized, not a replacement.

FOUT/FOIT strategies (swap, optional font-display)

CSS font-display property provides basic strategies. Fontaine improves on this by actively matching metrics, avoiding visible reflow rather than hiding it.

nuxt-font-metrics

Thin wrapper around Fontaine for Nuxt-specific configuration. Not a competitor; evidence of Fontaine's adoption in Nuxt ecosystem.