# @xerobi/fonts

Self-hosted open-source web fonts in **one package**. Every family is a subpath; import only the weights, styles, subsets or variable axes you need. Only `woff2` is shipped and browsers download a file only when the page uses its characters (`unicode-range`).

```sh
bun add @xerobi/fonts      # npm i / pnpm add / yarn add also work
```

Families: Inter · Noto Sans Bengali · Roboto · Plus Jakarta Sans · Lora · Playfair Display · Space Grotesk · Manrope · Google Sans · Public Sans · Noto Serif · Geist

## Importing

| Goal | Import |
| --- | --- |
| Family (weight 400, all subsets) | `@xerobi/fonts/inter` |
| A weight | `@xerobi/fonts/inter/700.css` |
| Italic | `@xerobi/fonts/inter/400-italic.css` |
| One subset, one weight | `@xerobi/fonts/inter/latin-400.css` (`…-italic.css` for italics) |
| One subset, all weights | `@xerobi/fonts/inter/latin.css` |
| Variable font (wght) | `@xerobi/fonts/inter/variable` → family `"Inter Variable"` |
| Variable, one subset | `@xerobi/fonts/inter/variable/latin-wght.css` |
| Other axes | `…/variable/opsz.css`, `wdth.css`, `standard.css`, `wght-italic.css`, `<subset>-<axis>[-italic].css` |
| Raw files | `@xerobi/fonts/inter/files/inter-latin-400-normal.woff2` |
| Metadata, unicode ranges, glyph list | `@xerobi/fonts/inter/metadata.json`, `unicode.json`, `glyphs.json` |
| SCSS mixins | `@use "@xerobi/fonts/inter/scss/mixins"` (static) · `…/inter/variable/scss/mixins` |
| CDN | `https://cdn.jsdelivr.net/npm/@xerobi/fonts@1/dist/fonts/inter/400.css` |

```css
@import "@xerobi/fonts/inter/latin-400.css";
@import "@xerobi/fonts/inter/latin-700.css";
body { font-family: "Inter", sans-serif; }
```
```ts
import "@xerobi/fonts/inter/variable/latin-wght.css"; // Vite, Next.js, Astro, webpack…
```

## TypeScript API

```ts
import { fonts, getFont, fontFace, cssPath, cdnUrl, type FontMetadata } from "@xerobi/fonts";

fonts.map((f) => f.id);                               // every family (metadata only)
getFont("inter")?.weights;                            // [100, …, 900]
cssPath("inter", { weight: 700, subset: "latin" });   // "@xerobi/fonts/inter/latin-700.css"
cdnUrl("inter", "400.css");
fontFace("inter", { subsets: ["latin"], weights: [400, 700], display: "optional", baseUrl: "/fonts" });
fontFace("roboto", { variable: true, axes: "wdth" });
```

## Layout of the published package

```
dist/
  index.js · index.d.ts            library
  metadata.json                    all families
  fonts/<family>/                  one folder per font
    index.css · 400.css · latin-400.css · 400-italic.css …
    variable/  files/  scss/
    metadata.json · unicode.json · glyphs.json · LICENSE
```

Build, add or remove fonts, release: see the repository `docs/`.

## Licenses
Tooling: MIT. Font files: each family's own license (almost always SIL OFL 1.1), included in `dist/fonts/<family>/LICENSE`.
