Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

2 changes: 0 additions & 2 deletions .github/DISCUSSIONS_GUIDE.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
blank_issues_enabled: false
blank_issues_enabled: false
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Check that the pattern stays compile-clean.

name: CI

on:
push:
branches: [main]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v6
with:
node-version: "20"
cache: npm
cache-dependency-path: |
package-lock.json
examples/consumer-app/package-lock.json

- name: Install dependencies - library
run: npm ci

- name: Build - library
run: npm run build

- name: Install dependencies - consumer app
run: npm ci
working-directory: examples/consumer-app

- name: Build - consumer app
run: npm run build
working-directory: examples/consumer-app
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ This repository is a reference implementation pattern. Changes should remain min

- Keep the library minimal — `src/` demonstrates the pattern, it is not a production component library
- The CSS variable approach in `src/MyComponent.jsx` is intentional; do not replace it with direct font imports or bundled font files
- Do not commit font files; the `.gitignore` exclusion of font extensions must remain intact
- The **demo subset** font under `examples/consumer-app/public/fonts/` is intentional so CI and `npm run build` succeed; do not add unrelated font binaries without legal review. The `.gitignore` rule for `*.woff2` still applies to **new** files unless explicitly whitelisted or force-added
- If a canonical assertion changes in the reference repo, update this pattern to stay aligned
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Monotype Imaging Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> License-safe web font delivery in a React component library using CSS variables.

This repository demonstrates the correct pattern for font delivery in a shared React component library. The library references fonts only through CSS custom properties — it never bundles, embeds, or redistributes font files. Font definitions and license-covered assets remain with the consuming application.
This repository demonstrates the correct pattern for font delivery in a shared React component library. The library references fonts only through CSS custom properties — it never bundles, embeds, or redistributes font files. Font definitions and license-covered assets remain with the consuming application, which serves font files from its own deployment (end users’ browsers still download font data for rendering — that is normal for the web; the pattern avoids putting font binaries inside the installable library package).

## What this pattern demonstrates

Expand All @@ -22,6 +22,9 @@ This pattern implements the following assertions from [reference-fonts-implement
- `lc-006` — using a font differs from distributing a font
- `pc-008` — self-hosting web fonts requires a web font license; desktop licenses do not permit web delivery
- `bd-001` — self-hosted fonts integrate into CI/CD pipelines as versioned static assets
- `pc-010` — cross-origin font delivery requires CORS configuration

In the consumer example, `@font-face` points at **`/fonts/...` on the same origin** as the Vite app, so you typically do not hit cross-origin `@font-face` blocking. **`pc-010` still applies** if you move font files to another origin (for example a CDN): that host must send correct `Access-Control-Allow-Origin` (and related) headers on font responses.

## Repository structure

Expand All @@ -30,6 +33,10 @@ This pattern implements the following assertions from [reference-fonts-implement

## Usage

1. Obtain font files under a valid Monotype web font license (this repo ships a **small subset** for build/CI; use your own files in forks or production)
2. Place `.woff2` files in `examples/consumer-app/public/fonts/` and update the `src` path in `examples/consumer-app/fonts.css` (`@font-face`) to match. Additional font names remain **gitignored** unless you force-add (`git add -f`) or add a `!` exception in `.gitignore`
3. Install and run:

### Build the library

```bash
Expand All @@ -45,11 +52,13 @@ npm install
npm run dev
```

Before running, place a `.woff2` font file in `examples/consumer-app/public/fonts/` and update the `src` path in `examples/consumer-app/fonts.css` to match. Font files are gitignored — supply your own under a valid Monotype web font license.
This repository includes a committed **`package-lock.json`**. After cloning, use **`npm ci`** when you want installs to match CI and the lockfile exactly; use **`npm install`** when you intentionally add or upgrade dependencies (then commit the updated lockfile).

## Font files

Font files are intentionally excluded from this repository via `.gitignore`. The consuming application is responsible for providing font files under a valid license. See `examples/consumer-app/public/fonts/placeholder.txt` for placement instructions.
This repository includes **`examples/consumer-app/public/fonts/MyFont.woff2`**, a heavily subsetted version of Gotham Regular, so **`npm run build`** and **GitHub Actions** work out of the box. It demonstrates self-hosting only; **redistribution rights for that file are not granted to you**—use fonts you are licensed to deploy. For your own project, replace the file and the `src:` path in `examples/consumer-app/fonts.css`. See `examples/consumer-app/public/fonts/placeholder.txt` for placement notes.

To commit a different binary despite `*.woff2` in `.gitignore`, use **`git add -f examples/consumer-app/public/fonts/YourFile.woff2`** once, or add a **`!examples/consumer-app/public/fonts/YourFile.woff2`** line after the `*.woff2` rule.

## Requirements

Expand All @@ -70,4 +79,4 @@ Use GitHub Discussions (Q&A category) for questions about this pattern.

## License

Code in this repository is provided for educational and interoperability purposes. Font files are not included. Canonical guidance © Monotype Imaging Inc.
Sample application **code** in this repository is licensed under the [MIT License](LICENSE). The **subset font file** in `examples/consumer-app/public/fonts/` is included **only** as a build/CI demonstration asset; it is **not** licensed to third parties for separate redistribution—use fonts you have rights to ship. Canonical assertion text in [reference-fonts-implementation](https://github.com/Monotype/reference-fonts-implementation) remains subject to that repository’s terms.
6 changes: 5 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A minimal runnable application that demonstrates how a consuming project provide
- `App.jsx` — imports `MyComponent` from the library and applies the font via the CSS variable
- `main.jsx` — mounts the app and imports `fonts.css`

The font file itself is not included. Place a `.woff2` file in `public/fonts/` and update the `src` path in `fonts.css` to match.
This repository includes **`public/fonts/MyFont.woff2`**, a heavily subsetted version of Gotham Regular. **Redistribution rights for that file are not granted to you.** For your own project, replace the file and the `src:` path in `examples/consumer-app/fonts.css`. See `public/fonts/placeholder.txt` for placement notes.

## Running

Expand All @@ -18,3 +18,7 @@ npm run dev
```

Requires Node.js 18+.

## Notes

This app has no `vite.config.js`. Vite 8 processes `.jsx` files via esbuild by default, so builds and `npm run dev` work without `@vitejs/plugin-react`. The trade-off is no React Fast Refresh in dev mode — acceptable for a minimal demo.
2 changes: 1 addition & 1 deletion examples/consumer-app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export default function App() {
<MyComponent />
</>
);
}
}
3 changes: 1 addition & 2 deletions examples/consumer-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand All @@ -16,6 +15,6 @@
},
"scripts": {
"dev": "vite",
"test": "echo \"Error: no test specified\" && exit 1"
"build": "vite build"
}
}
Binary file added examples/consumer-app/public/fonts/MyFont.woff2
Binary file not shown.
6 changes: 5 additions & 1 deletion examples/consumer-app/public/fonts/placeholder.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
place fonts here
Place your licensed .woff2 files in this directory (same folder as this file).

- Obtain files under a valid Monotype web font license for self-hosted delivery.
- This repository includes **MyFont.woff2**, a heavily subsetted version of Gotham Regular, for CI and local `npm run build` only; replace it with your own file and update `examples/consumer-app/fonts.css` (`@font-face` `src`) if you fork or ship your app.
- Additional font filenames are covered by `*.woff2` in `.gitignore`; use `git add -f` or a `!` exception in `.gitignore` when you intentionally commit another binary.
2 changes: 1 addition & 1 deletion src/MyComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export default function MyComponent() {
React font pattern demo
</div>
)
}
}