npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@forthgoing/subfont

v0.1.2

Published

Astro integration that subsets your font files so you get significantly smaller font sizes and faster loading speeds

Readme

Build the web you want

npm version Astro version compatibility License: MIT Stars

About The Project

Subfont is a powerful Astro integration that takes your local fonts (TTF, OTF, WOFF2) in /src/assets/fonts, analyzes all actual text content across your .astro, .md, .mdx, .ts, etc. files, and generates WOFF2 subsets with only the text you use.

The result? Fonts that are often 70-95% smaller than the originals, with zero visual difference, leading to faster page loads, lower data usage (especially on mobile), improved Largest Contentful Paint (LCP), and significantly better Lighthouse / Core Web Vitals scores.

Key Features

  • Only includes glyphs actually used in your site
  • Automatic WOFF2 conversion & compression (TTF/OTF → highly optimized WOFF2)
  • Original font source files - Keeps your original fonts saved so when you use more characters in your site it automatically gets added to the optimized fonts.
  • Variable font support
  • Smart caching - only re-processes changed fonts or when content changes
  • Font manifest generation
  • Full control of your fonts Preload, display, alias, etc..
  • Duplicate & symlink protection

What Makes Subfont Stand Out

Most font optimization tools either:

  • Require manual unicode-range lists
  • Depend on Google Fonts / external services
  • Don't update subsets when content changes
  • Rely on bloated python scripts or wrappers like glyphhanger

@forthgoing/subfont stands out because it:

  • Core fully built in Rust.
  • Fast and lightweight
  • Fully configurable
  • Keeps your original font files for updating your optimized fonts
  • Doesn't require installing anything extra
  • Caches intelligently using content hash + font hash + version

Getting Started

Prerequisites

Requires:

  • Node 18+
  • Astro 4+
  • Fonts in /src/assets/fonts

Supported source formats:

  • .ttf
  • .otf
  • .woff2

WOFF is not supported and will be skipped gracefully.


Installation

  1. Add the dependency:
npm install @forthgoing/subfont
# or
pnpm add @forthgoing/subfont
# or
yarn add @forthgoing/subfont
  1. Add the plugin to astro.config.(ts|js|mjs):
import subfont from "@forthgoing/subfont";

export default defineConfig({
  integrations: [subfont()],
});
  1. Import tags into your Layout.astro:
import SubfontHead from "forthgoing:subfont/head";
import SubfontBody from "forthgoing:subfont/body";

Usage inside Layout.astro:

<head>
  <meta charset="utf-8" />
  <SubfontHead />
  <!--- other head content--->
</head>
<body>
  <SubfontBody />
  ...
</body>
  1. Place your fonts in src/assets/fonts:
src/assets/fonts/
├── Inter-Regular.ttf
├── Inter-Italic.ttf
├── PragmataPro.woff2
└── MyCustomFont-Variable.ttf

Usage

After setup, just run npm run dev or npm run build

And use your font normally:

h1 {
    font-family: 'InterRegular',
}

Configuration

Subfont config subfont.config.ts

Create this file at the root of your project.


import type { SubfontConfig } from "@forthgoing/subfont";

const config: SubfontConfig = {
  inter: {
    alias: "Inter",
    display: "swap",
    weight: "100 900",
    tagPlacement: "head",      // "head" | "body"
    stylePlacement: "head",
    preload: true,
  },
  pragma: {
    tagPlacement: "head",
    weight: "100 900",
    stylePlacement: "head",
  },
  // Add more font families...
};

export default config;

Plugin options astro.config.ts

subfont({
  assetsFolder: "src/assets",      // default
  fontsSubdir: "fonts",            // default = "fonts"
  hashFonts: true,                 // append content hash to filename (great for caching)
})

How it works

  1. Scans all source files and collects used characters
  2. Computes content hash
  3. For each font:
  • Checks cache
  • Subsets to only used glyphs
  • Converts to WOFF2
  • Keeps your original fonts
  • Removes old variants
  1. Injects <link rel="preload">, @font-face via SubfontHead / SubfontBody

Contributing

Contributions are welcome!

  1. Fork the project
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a pull request

License

Distributed under the MIT License. See LICENSE for more information.