@nebutra/fonts 2.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/NOTICE-FONTS.md +31 -11
- package/README.md +92 -81
- package/dist/chunk-A4PPXTH5.js +38 -0
- package/dist/chunk-A4PPXTH5.js.map +1 -0
- package/dist/chunk-FUPJK5RT.js +20 -0
- package/dist/chunk-FUPJK5RT.js.map +1 -0
- package/dist/generated/index.d.ts +23 -23
- package/dist/generated/index.js +12 -16
- package/dist/generated/index.js.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/next-cjk.d.ts +40 -38
- package/dist/next-cjk.js +10 -3
- package/dist/next.d.ts +2 -1
- package/dist/next.js +206 -57
- package/dist/next.js.map +1 -1
- package/generated/index.ts +18 -15
- package/generated/subset-manifest.json +63 -5
- package/package.json +31 -5
- package/src/cjk-font-face.tsx +53 -0
- package/src/index.ts +6 -5
- package/src/next-cjk.test.ts +37 -30
- package/src/next-cjk.ts +36 -52
- package/src/next.test.ts +68 -0
- package/src/next.ts +238 -72
- package/vendor/{noto-sans-sc → dm-sans}/OFL.txt +93 -92
- package/vendor/misans/LICENSE.txt +13 -0
- package/dist/chunk-GRE7GS6W.js +0 -27
- package/dist/chunk-GRE7GS6W.js.map +0 -1
- package/generated/noto-sans-sc.css +0 -43
package/CHANGELOG.md
CHANGED
package/NOTICE-FONTS.md
CHANGED
|
@@ -2,18 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
This package's MIT licence covers **first-party code only**.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## MiSans
|
|
6
6
|
|
|
7
|
-
本软件使用了 **
|
|
8
|
-
This software uses the **
|
|
7
|
+
本软件使用了 **MiSans** 字体(小米科技有限责任公司)。
|
|
8
|
+
This software uses the **MiSans** typeface by Xiaomi.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
MiSans is free for commercial use and may be embedded in software on the
|
|
11
|
+
condition that the software states it uses MiSans (this notice, and the
|
|
12
|
+
landing site's /credits page, which every public footer links to). The font may not be distributed on its own or
|
|
13
|
+
have its appearance altered. Licence text: `vendor/misans/LICENSE.txt`.
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
`next/font/local` can load them offline. They are **not** included in the npm
|
|
15
|
-
`files` list and must not be published. Downstream npm consumers do not receive
|
|
16
|
-
font binaries from this package.
|
|
15
|
+
## DM Sans
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
This software uses the **DM Sans** typeface, licensed under the SIL Open Font
|
|
18
|
+
License 1.1. Licence text: `vendor/dm-sans/OFL.txt`.
|
|
19
|
+
|
|
20
|
+
## Theme / DESIGN.md registry faces
|
|
21
|
+
|
|
22
|
+
`src/next.ts` loads 19 faces from `@fontsource-variable/*` npm packages
|
|
23
|
+
(Fontsource, version 5.3.0), each licensed under the **SIL Open Font License
|
|
24
|
+
1.1**, which permits use, embedding and redistribution, including bundling with
|
|
25
|
+
software: Inter, Inter Tight, Space Grotesk, Playfair Display, Source Serif 4,
|
|
26
|
+
Fraunces, JetBrains Mono, Manrope, Sora, Work Sans, DM Sans, Plus Jakarta Sans,
|
|
27
|
+
Outfit, Figtree, Montserrat, Lexend, Fira Code, Roboto Mono, Source Code Pro.
|
|
28
|
+
Each package carries its licence text (`LICENSE`) and copyright notice; the
|
|
29
|
+
font binaries are not copied into this package — they are installed as
|
|
30
|
+
dependencies and emitted into the app's build by `next/font/local`.
|
|
31
|
+
|
|
32
|
+
## Distribution
|
|
33
|
+
|
|
34
|
+
The DM Sans subset (`generated/dm-sans.woff2`) is committed so
|
|
35
|
+
`next/font/local` can load it offline; it is **not** in the npm `files` list.
|
|
36
|
+
MiSans subsets are never committed at all: the licence forbids distributing
|
|
37
|
+
the font on its own, so they are uploaded to the deployment's asset CDN and
|
|
38
|
+
`<CjkFontFace />` points at them. Do not add `generated/*.woff2` or other font
|
|
39
|
+
binaries to a publishable `files` glob.
|
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@ Status: **WIP** — not yet published to npm.
|
|
|
4
4
|
|
|
5
5
|
The Simplified-Chinese face is wired into every Next app that loads Geist (web,
|
|
6
6
|
landing, design-docs, sailor-docs, admin, forge, router, sleptons, typelens,
|
|
7
|
-
mail-preview). The theme / DESIGN.md registry (
|
|
8
|
-
|
|
7
|
+
mail-preview). The theme / DESIGN.md registry (19 OSS faces) is applied by
|
|
8
|
+
`apps/web`, `apps/landing` and `apps/design`.
|
|
9
9
|
|
|
10
10
|
Self-hosted fonts for Nebutra: the CJK body face, plus an OSS font registry for
|
|
11
11
|
themes and imported DESIGN.md font families.
|
|
@@ -19,9 +19,10 @@ The package has three entries:
|
|
|
19
19
|
also keeps it working in a network-sandboxed dev server. **This is the one every
|
|
20
20
|
app needs.**
|
|
21
21
|
- `@nebutra/fonts/next` is server-only and declares the build-time
|
|
22
|
-
`next/font/
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
registry faces (`next/font/local` over `@fontsource-variable/*` packages — no
|
|
23
|
+
network at build or dev time) plus the combined registry class name. It
|
|
24
|
+
re-exports the CJK face, but importing it just for that would pull 19 faces
|
|
25
|
+
into the app's CSS — use `./next/cjk`.
|
|
25
26
|
|
|
26
27
|
## Installation
|
|
27
28
|
|
|
@@ -54,18 +55,14 @@ const stack = withRegistryFont("Space Grotesk, sans-serif");
|
|
|
54
55
|
// "var(--font-space-grotesk), Space Grotesk, sans-serif"
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
##
|
|
58
|
+
## Brand faces — DM Sans (headings) and MiSans (Chinese)
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
in this product (see `docs/microcopy/`), so the CJK face is self-hosted and
|
|
63
|
-
subset here.
|
|
60
|
+
Chosen 2026-09-25 by measuring what competitors ship: MiniMax and Moonshot set
|
|
61
|
+
Chinese in MiSans, DeepSeek and Databricks set Latin in DM Sans. Geist stays the
|
|
62
|
+
body/UI face for its tabular figures.
|
|
64
63
|
|
|
65
64
|
### Wiring an app
|
|
66
65
|
|
|
67
|
-
Two lines in the root layout, beside the Geist loaders:
|
|
68
|
-
|
|
69
66
|
```tsx
|
|
70
67
|
import { cjkFontClassName } from "@nebutra/fonts/next/cjk";
|
|
71
68
|
import { GeistMono } from "geist/font/mono";
|
|
@@ -74,28 +71,38 @@ import { GeistSans } from "geist/font/sans";
|
|
|
74
71
|
<html className={`${GeistSans.variable} ${GeistMono.variable} ${cjkFontClassName}`}>
|
|
75
72
|
```
|
|
76
73
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
`
|
|
85
|
-
|
|
86
|
-
|
|
74
|
+
`cjkFontClassName` defines `--font-dm-sans` (self-hosted variable subset, SIL
|
|
75
|
+
OFL). MiSans arrives through `<CjkFontFace />` from the same entry — render it
|
|
76
|
+
once in the root layout. It builds the `@font-face` rules at render time from
|
|
77
|
+
the committed keys and `publicAssetUrl()` (`NEXT_PUBLIC_R2_PUBLIC_URL`, then
|
|
78
|
+
`R2_PUBLIC_URL`, then the brand's `cdn` origin), so no host is hardcoded and a
|
|
79
|
+
scaffold resolves to its own CDN. The token stacks in `@nebutra/tokens` already
|
|
80
|
+
reference both. Non-Next hosts (Storybook) import `@nebutra/fonts/font-face` and
|
|
81
|
+
pass `origin` explicitly.
|
|
82
|
+
|
|
83
|
+
### Why MiSans is on the CDN, not in this package
|
|
84
|
+
|
|
85
|
+
The MiSans licence allows free commercial use and embedding **with attribution**,
|
|
86
|
+
but forbids distributing the font software on its own. This repository is public
|
|
87
|
+
and mirrored as a template, so committing the subsets would distribute them —
|
|
88
|
+
the reason vivo Sans was removed (b5e73db35). `pnpm subset:cjk --upload` writes
|
|
89
|
+
content-hashed subsets to the bucket behind your public asset origin
|
|
90
|
+
(`MISANS_R2_BUCKET`, under `fonts/misans/`) and commits only their keys. Until
|
|
91
|
+
they are uploaded, or offline, the requests fail and the stack falls back to
|
|
92
|
+
PingFang / YaHei. The product states it uses MiSans on the landing site's
|
|
93
|
+
`/credits` page, linked from every public footer — the licence asks for the
|
|
94
|
+
statement, not a footer line (see NOTICE-FONTS.md; guarded by
|
|
95
|
+
`tests/architecture/font-license.test.ts`).
|
|
87
96
|
|
|
88
97
|
### Stack order is the design decision
|
|
89
98
|
|
|
90
99
|
```css
|
|
91
|
-
font-family: var(--font-geist-sans), "Geist", var(--font-
|
|
100
|
+
font-family: var(--font-geist-sans), "Geist", var(--font-misans, "MiSans"), …;
|
|
92
101
|
```
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
decides: reversed, Noto would take the Latin too, and its Latin is not as
|
|
98
|
-
good as Geist's for UI.
|
|
103
|
+
The Latin face comes **first** and keeps Latin and the numerals; MiSans takes
|
|
104
|
+
CJK. Both cover Latin, so the order decides: reversed, MiSans would take the
|
|
105
|
+
Latin too.
|
|
99
106
|
|
|
100
107
|
Belt and braces: the generated `@font-face` rules carry a `unicode-range` with
|
|
101
108
|
no Latin, no ASCII and no general-punctuation codepoints in it, so a Latin-only
|
|
@@ -105,40 +112,37 @@ wrong way round. Geist Mono remains the code face.
|
|
|
105
112
|
### Building the subsets
|
|
106
113
|
|
|
107
114
|
```bash
|
|
108
|
-
FONTTOOLS_PYTHON=/path/to/python \
|
|
109
|
-
pnpm --filter @nebutra/fonts subset:cjk -- --force
|
|
115
|
+
FONTTOOLS_PYTHON=/path/to/python MISANS_ZIP=/path/to/MiSans.zip \
|
|
116
|
+
pnpm --filter @nebutra/fonts subset:cjk -- --force --upload
|
|
110
117
|
```
|
|
111
118
|
|
|
112
|
-
Requires Python with `fontTools` and `brotli` (for `--flavor=woff2`)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
`
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
Skin-declared fractional weights (300 / 450 / 510) resolve into the same set.
|
|
129
|
-
Each weight costs ~490 KB, so shipping all nine static faces would be ~4.4 MB.
|
|
119
|
+
Requires Python with `fontTools` and `brotli` (for `--flavor=woff2`) and a
|
|
120
|
+
logged-in `wrangler`. Without `MISANS_ZIP` the script downloads Xiaomi's official
|
|
121
|
+
package (`MISANS_ZIP_URL`). It subsets the static Regular / Medium / Semibold /
|
|
122
|
+
Bold faces, names each output by content hash, and with `--upload` puts them in
|
|
123
|
+
R2 (`MISANS_R2_BUCKET`) with an immutable cache header. Only `index.ts` (the
|
|
124
|
+
keys) and the manifest are committed; the woff2 files are gitignored. A hash change means a new URL, so
|
|
125
|
+
the CDN never serves a stale face. The bucket's CORS allowlist lives in
|
|
126
|
+
`infra/iac/cloudflare/r2/cors.json`: an app on a new origin gets no MiSans (the
|
|
127
|
+
stack silently falls back to PingFang) until its origin is added there.
|
|
128
|
+
|
|
129
|
+
### Why four weights
|
|
130
|
+
|
|
131
|
+
`--font-weight-heading` is 500 (`packages/design/tokens/recipe.css`), body is
|
|
132
|
+
400, and the token CSS writes literal 600 and 700 as well. Each static face
|
|
133
|
+
costs ~525 KB, and `unicode-range` plus per-weight `@font-face` means a page
|
|
134
|
+
only downloads the weights it renders.
|
|
130
135
|
|
|
131
136
|
### Why the static faces, not the variable one
|
|
132
137
|
|
|
133
138
|
A variable CJK font carries per-weight deltas for every glyph it keeps, so one
|
|
134
|
-
variable file costs more than the static weights a page actually uses.
|
|
135
|
-
pipeline instances 400 / 500 / 600 / 700 and subsets each one.
|
|
139
|
+
variable file costs more than the static weights a page actually uses.
|
|
136
140
|
|
|
137
141
|
### Character set
|
|
138
142
|
|
|
139
|
-
Three inputs, unioned — 4,
|
|
143
|
+
Three inputs, unioned — 4,330 characters in the current build:
|
|
140
144
|
|
|
141
|
-
1. **The zh catalogs, by glob** (1,
|
|
145
|
+
1. **The zh catalogs, by glob** (1,662 chars) — every `zh*.json` under any
|
|
142
146
|
`messages/` or `locales/` directory, walked at build time, so new Chinese copy
|
|
143
147
|
is covered on the next run instead of drifting away from a hardcoded list.
|
|
144
148
|
2. **CJK punctuation and fullwidth forms, wholesale** (197 chars) — U+3000–303F,
|
|
@@ -158,46 +162,53 @@ Three inputs, unioned — 4,282 characters in the current build:
|
|
|
158
162
|
characters that appear in a fraction of a percent of text, which is exactly
|
|
159
163
|
what OS fallback is for.
|
|
160
164
|
|
|
161
|
-
The floor is what costs the bytes: the catalog set alone subsets to 191,108 B per
|
|
162
|
-
weight, the full set to ~498,000 B.
|
|
163
|
-
|
|
164
|
-
> Possible follow-up, measured but **not** implemented here: splitting each
|
|
165
|
-
> weight into a hot tier (catalogs + punctuation, 1,777 chars, 197,028 B) and an
|
|
166
|
-
> extended tier (the GB2312 remainder, 2,509 chars, 312,644 B) with complementary
|
|
167
|
-
> `unicode-range`s would drop the common path from ~1.47 MB to ~591 KB across
|
|
168
|
-
> three weights, and only fetch the extended tier when user data actually renders
|
|
169
|
-
> a character outside our own copy. It costs two files per weight and (on the
|
|
170
|
-
> `next/font/local` path) a per-tier `declarations` entry to carry the range.
|
|
171
|
-
|
|
172
165
|
### Vendored sources
|
|
173
166
|
|
|
174
|
-
`vendor/
|
|
175
|
-
`
|
|
167
|
+
`vendor/misans/LICENSE.txt` (licence text and the FAQ answers on embedding) and
|
|
168
|
+
`vendor/dm-sans/OFL.txt` are committed. The MiSans zip and TTFs are gitignored.
|
|
169
|
+
Never commit a MiSans binary: the licence forbids distributing it on its own.
|
|
176
170
|
|
|
177
171
|
## Third-party font attribution
|
|
178
172
|
|
|
179
|
-
|
|
180
|
-
This
|
|
173
|
+
本产品使用了小米 **MiSans** 字体。
|
|
174
|
+
This product uses the **MiSans** typeface by Xiaomi.
|
|
181
175
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
176
|
+
MiSans is free for commercial use under the MiSans Font Intellectual Property
|
|
177
|
+
License Agreement, which requires this attribution
|
|
178
|
+
(`vendor/misans/LICENSE.txt`). DM Sans is SIL OFL 1.1 (`vendor/dm-sans/OFL.txt`).
|
|
179
|
+
Both licences are separate from this package's MIT licence. See
|
|
180
|
+
`NOTICE-FONTS.md`.
|
|
187
181
|
|
|
188
182
|
## Registered Families
|
|
189
183
|
|
|
190
|
-
The registry includes Geist, Inter, Space Grotesk, Playfair
|
|
191
|
-
|
|
192
|
-
|
|
184
|
+
The registry includes Geist, Inter, Inter Tight, Space Grotesk, Playfair
|
|
185
|
+
Display, Source Serif 4, Fraunces, JetBrains Mono, Manrope, Sora, Work Sans, DM
|
|
186
|
+
Sans, Plus Jakarta Sans, Outfit, Figtree, Montserrat, Lexend, Fira Code, Roboto
|
|
187
|
+
Mono, and Source Code Pro.
|
|
193
188
|
|
|
194
189
|
## Runtime Model
|
|
195
190
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
191
|
+
Every face is a file that arrives with `pnpm install`: the registry loads the
|
|
192
|
+
Latin, upright, `wght`-axis variable build from its `@fontsource-variable/*`
|
|
193
|
+
package through `next/font/local`, so `next build` and `next dev` never contact
|
|
194
|
+
fonts.googleapis.com / fonts.gstatic.com. That matters wherever Google is
|
|
195
|
+
unreachable — mainland China, corporate proxies, offline machines — where
|
|
196
|
+
`next/font/google` failed the build and made the Turbopack dev server answer
|
|
197
|
+
500. npm packages come through any registry mirror (npmmirror in China).
|
|
198
|
+
|
|
199
|
+
The files are Google Fonts' own builds as republished by Fontsource (same font
|
|
200
|
+
version, same axis; shaping checked glyph by glyph against what
|
|
201
|
+
`next/font/google` downloaded) and the `@font-face` family names are Google's,
|
|
202
|
+
so pages render pixel-identically. Only the Latin subset is shipped — the one
|
|
203
|
+
the registry declared and preloaded; characters outside it fall back to the
|
|
204
|
+
metric-matched system font. `scripts/lint-no-google-fonts.mjs` (in `pnpm lint`)
|
|
205
|
+
keeps `next/font/google` out of every file the template ships.
|
|
206
|
+
|
|
207
|
+
At runtime the browser requests fonts from the application origin only when an
|
|
208
|
+
element uses the corresponding CSS variable.
|
|
199
209
|
|
|
200
210
|
## License
|
|
201
211
|
|
|
202
|
-
MIT for first-party code.
|
|
203
|
-
|
|
212
|
+
MIT for first-party code. DM Sans and every registry face are SIL OFL 1.1
|
|
213
|
+
(see `NOTICE-FONTS.md`). MiSans binaries are never
|
|
214
|
+
committed or published to npm; they are served from the deployment's asset CDN.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MISANS_FAMILY,
|
|
3
|
+
MISANS_FILES,
|
|
4
|
+
MISANS_UNICODE_RANGE
|
|
5
|
+
} from "./chunk-FUPJK5RT.js";
|
|
6
|
+
|
|
7
|
+
// src/next-cjk.ts
|
|
8
|
+
import localFont from "next/font/local";
|
|
9
|
+
|
|
10
|
+
// src/cjk-font-face.tsx
|
|
11
|
+
import { publicAssetUrl } from "@nebutra/brand/metadata-helpers";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
function misansFontFaceCss(origin) {
|
|
14
|
+
return MISANS_FILES.map(
|
|
15
|
+
(face) => `@font-face{font-family:"${MISANS_FAMILY}";font-style:normal;font-weight:${face.weight};font-display:swap;src:url("${publicAssetUrl(face.key, origin)}") format("woff2");unicode-range:${MISANS_UNICODE_RANGE}}`
|
|
16
|
+
).join("\n");
|
|
17
|
+
}
|
|
18
|
+
function CjkFontFace({ origin, nonce }) {
|
|
19
|
+
return /* @__PURE__ */ jsx("style", { href: "nebutra-misans", precedence: "default", nonce: nonce || void 0, children: misansFontFaceCss(origin) });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/next-cjk.ts
|
|
23
|
+
var dmSans = localFont({
|
|
24
|
+
src: [{ path: "../generated/dm-sans.woff2", weight: "100 1000", style: "normal" }],
|
|
25
|
+
display: "swap",
|
|
26
|
+
variable: "--font-dm-sans"
|
|
27
|
+
});
|
|
28
|
+
var brandFontClassName = dmSans.variable;
|
|
29
|
+
var cjkFontClassName = brandFontClassName;
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
misansFontFaceCss,
|
|
33
|
+
CjkFontFace,
|
|
34
|
+
dmSans,
|
|
35
|
+
brandFontClassName,
|
|
36
|
+
cjkFontClassName
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=chunk-A4PPXTH5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/next-cjk.ts","../src/cjk-font-face.tsx"],"sourcesContent":["/**\n * @nebutra/fonts/next/cjk — the self-hosted brand faces (server-only).\n *\n * The Latin brand face lives here through `next/font/local` so first-party apps work\n * offline, in CI and in the network sandbox (the registry in `./next` is local too):\n *\n * - MiSans — the Simplified-Chinese face — is CDN-hosted; see <CjkFontFace /> below.\n * - DM Sans — the Latin display/heading face (SIL OFL). Chosen the same day\n * from the same measurement (DeepSeek, Databricks). Body/UI Latin stays\n * Geist: its tabular figures are what dense dashboard tables need.\n *\n * WHY A SEPARATE ENTRY FROM `./next`: that module declares 19\n * faces for the theme / DESIGN.md registry; importing it for the brand faces\n * would put all of them into every app's CSS. `./next`\n * re-exports this file, so an app already applying `fontRegistryClassName`\n * still needs one import.\n *\n * next/font is a compile-time transform: SWC statically analyses the call, so\n * the options object is spelled out as a literal.\n */\n\nimport localFont from \"next/font/local\";\n\n/**\n * MiSans is NOT loaded here: its licence forbids distributing the font on its\n * own and this repository is public (vivo Sans was removed for the same reason,\n * b5e73db35). The subsets are served from the deployment's asset CDN and\n * declared by <CjkFontFace />, re-exported below — render it in the root\n * layout next to this class name. The token stacks reference\n * var(--font-misans, \"MiSans\"): with no variable set, the literal family name\n * resolves to that @font-face.\n */\nexport { CjkFontFace, misansFontFaceCss } from \"./cjk-font-face\";\n\n/**\n * DM Sans — one variable file (opsz 9–40, wght 100–1000), Latin subset, 67KB.\n * Preloaded: headings render above the fold on most pages.\n */\nexport const dmSans = localFont({\n src: [{ path: \"../generated/dm-sans.woff2\", weight: \"100 1000\", style: \"normal\" }],\n display: \"swap\",\n variable: \"--font-dm-sans\",\n});\n\n/**\n * Apply to <html> next to the Geist loaders so `--font-dm-sans` exists:\n *\n * className={`${GeistSans.variable} ${GeistMono.variable} ${cjkFontClassName}`}\n *\n * The name predates DM Sans; it now carries both brand faces so every app that\n * already applies it picks them up without a layout change.\n */\nexport const brandFontClassName = dmSans.variable;\nexport const cjkFontClassName = brandFontClassName;\n","/**\n * MiSans @font-face, rendered at request time rather than shipped as CSS.\n *\n * The MiSans licence forbids distributing the font on its own and this\n * repository is public, so the subsets live in the deployment's public asset\n * bucket and only their keys are committed (../generated/index.ts). A static\n * stylesheet would have to spell out a host, and the host differs per\n * deployment: Nebutra's CDN for Nebutra, the scaffold's own for a template\n * user. publicAssetUrl() resolves it the way it resolves every other public\n * asset — NEXT_PUBLIC_R2_PUBLIC_URL, then R2_PUBLIC_URL, then the brand's cdn\n * origin.\n *\n * Before the subsets have been uploaded (a fresh scaffold, `pnpm subset:cjk\n * --upload` not yet run) the requests 404 and the token stacks fall through to\n * PingFang / YaHei. That is the intended degraded state, not an error.\n */\n\nimport { publicAssetUrl } from \"@nebutra/brand/metadata-helpers\";\nimport { MISANS_FAMILY, MISANS_FILES, MISANS_UNICODE_RANGE } from \"../generated/index\";\n\n/** One @font-face per weight, CJK-only unicode-range, `swap` so text is never invisible. */\nexport function misansFontFaceCss(origin?: string): string {\n return MISANS_FILES.map(\n (face) =>\n `@font-face{font-family:\"${MISANS_FAMILY}\";font-style:normal;font-weight:${face.weight};` +\n `font-display:swap;src:url(\"${publicAssetUrl(face.key, origin)}\") format(\"woff2\");` +\n `unicode-range:${MISANS_UNICODE_RANGE}}`,\n ).join(\"\\n\");\n}\n\nexport interface CjkFontFaceProps {\n /** Asset origin override; defaults to the publicAssetUrl() resolution. */\n origin?: string;\n /**\n * CSP nonce, for apps whose style-src allows inline styles only by nonce\n * (apps/web). Without it the whole @font-face block is refused. The page's\n * font-src must also allow publicAssetOrigin().\n */\n nonce?: string;\n}\n\n/**\n * Render once in each root layout, next to `cjkFontClassName` on <html>.\n * React 19 hoists a `<style>` carrying `href` + `precedence` into <head> and\n * dedupes it by `href`, so rendering it twice costs nothing.\n */\nexport function CjkFontFace({ origin, nonce }: CjkFontFaceProps) {\n return (\n <style href=\"nebutra-misans\" precedence=\"default\" nonce={nonce || undefined}>\n {misansFontFaceCss(origin)}\n </style>\n );\n}\n"],"mappings":";;;;;;;AAqBA,OAAO,eAAe;;;ACJtB,SAAS,sBAAsB;AA+B3B;AA3BG,SAAS,kBAAkB,QAAyB;AACzD,SAAO,aAAa;AAAA,IAClB,CAAC,SACC,2BAA2B,aAAa,mCAAmC,KAAK,MAAM,+BACxD,eAAe,KAAK,KAAK,MAAM,CAAC,oCAC7C,oBAAoB;AAAA,EACzC,EAAE,KAAK,IAAI;AACb;AAkBO,SAAS,YAAY,EAAE,QAAQ,MAAM,GAAqB;AAC/D,SACE,oBAAC,WAAM,MAAK,kBAAiB,YAAW,WAAU,OAAO,SAAS,QAC/D,4BAAkB,MAAM,GAC3B;AAEJ;;;ADdO,IAAM,SAAS,UAAU;AAAA,EAC9B,KAAK,CAAC,EAAE,MAAM,8BAA8B,QAAQ,YAAY,OAAO,SAAS,CAAC;AAAA,EACjF,SAAS;AAAA,EACT,UAAU;AACZ,CAAC;AAUM,IAAM,qBAAqB,OAAO;AAClC,IAAM,mBAAmB;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// generated/index.ts
|
|
2
|
+
var MISANS_VARIABLE = "--font-misans";
|
|
3
|
+
var MISANS_FAMILY = "MiSans";
|
|
4
|
+
var MISANS_CHAR_COUNT = 4330;
|
|
5
|
+
var MISANS_UNICODE_RANGE = "U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF";
|
|
6
|
+
var MISANS_FILES = [
|
|
7
|
+
{ key: "fonts/misans/misans-400.6bf25dfdf3.woff2", weight: "400", bytes: 535408 },
|
|
8
|
+
{ key: "fonts/misans/misans-500.442041bb9d.woff2", weight: "500", bytes: 537060 },
|
|
9
|
+
{ key: "fonts/misans/misans-600.2590c17c53.woff2", weight: "600", bytes: 540540 },
|
|
10
|
+
{ key: "fonts/misans/misans-700.ddd8bf8017.woff2", weight: "700", bytes: 545728 }
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
MISANS_VARIABLE,
|
|
15
|
+
MISANS_FAMILY,
|
|
16
|
+
MISANS_CHAR_COUNT,
|
|
17
|
+
MISANS_UNICODE_RANGE,
|
|
18
|
+
MISANS_FILES
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=chunk-FUPJK5RT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../generated/index.ts"],"sourcesContent":["/**\n * GENERATED FILE, DO NOT EDIT.\n * Written by packages/design/fonts/scripts/subset-cjk.mjs.\n *\n * Metadata for the CDN-hosted MiSans subsets. <CjkFontFace /> in\n * ../src/cjk-font-face.tsx turns it into @font-face rules at render time.\n *\n * The registry key is \"misans\" (see FONT_REGISTRY in ../src/index.ts);\n * the CSS variable is \"--font-misans\".\n */\n\nexport const MISANS_VARIABLE = \"--font-misans\" as const;\n\nexport const MISANS_FAMILY = \"MiSans\" as const;\n\n/** Characters covered per face (catalogs ∪ CJK punctuation ∪ GB2312 level-1). */\nexport const MISANS_CHAR_COUNT = 4330 as const;\n\n/** `unicode-range` of every generated @font-face — CJK only, no Latin. */\nexport const MISANS_UNICODE_RANGE = \"U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF\" as const;\n\n/** Public-asset keys, one per weight (content-hashed names). No host: see publicAssetUrl(). */\nexport const MISANS_FILES = [\n { key: \"fonts/misans/misans-400.6bf25dfdf3.woff2\", weight: \"400\", bytes: 535408 },\n { key: \"fonts/misans/misans-500.442041bb9d.woff2\", weight: \"500\", bytes: 537060 },\n { key: \"fonts/misans/misans-600.2590c17c53.woff2\", weight: \"600\", bytes: 540540 },\n { key: \"fonts/misans/misans-700.ddd8bf8017.woff2\", weight: \"700\", bytes: 545728 },\n] as const;\n"],"mappings":";AAWO,IAAM,kBAAkB;AAExB,IAAM,gBAAgB;AAGtB,IAAM,oBAAoB;AAG1B,IAAM,uBAAuB;AAG7B,IAAM,eAAe;AAAA,EAC1B,EAAE,KAAK,4CAA4C,QAAQ,OAAO,OAAO,OAAO;AAAA,EAChF,EAAE,KAAK,4CAA4C,QAAQ,OAAO,OAAO,OAAO;AAAA,EAChF,EAAE,KAAK,4CAA4C,QAAQ,OAAO,OAAO,OAAO;AAAA,EAChF,EAAE,KAAK,4CAA4C,QAAQ,OAAO,OAAO,OAAO;AAClF;","names":[]}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GENERATED FILE
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* GENERATED FILE, DO NOT EDIT.
|
|
3
|
+
* Written by packages/design/fonts/scripts/subset-cjk.mjs.
|
|
4
|
+
*
|
|
5
|
+
* Metadata for the CDN-hosted MiSans subsets. <CjkFontFace /> in
|
|
6
|
+
* ../src/cjk-font-face.tsx turns it into @font-face rules at render time.
|
|
7
|
+
*
|
|
8
|
+
* The registry key is "misans" (see FONT_REGISTRY in ../src/index.ts);
|
|
9
|
+
* the CSS variable is "--font-misans".
|
|
6
10
|
*/
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
11
|
+
declare const MISANS_VARIABLE: "--font-misans";
|
|
12
|
+
declare const MISANS_FAMILY: "MiSans";
|
|
9
13
|
/** Characters covered per face (catalogs ∪ CJK punctuation ∪ GB2312 level-1). */
|
|
10
|
-
declare const
|
|
14
|
+
declare const MISANS_CHAR_COUNT: 4330;
|
|
11
15
|
/** `unicode-range` of every generated @font-face — CJK only, no Latin. */
|
|
12
|
-
declare const
|
|
13
|
-
/**
|
|
14
|
-
declare const
|
|
15
|
-
readonly
|
|
16
|
+
declare const MISANS_UNICODE_RANGE: "U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF";
|
|
17
|
+
/** Public-asset keys, one per weight (content-hashed names). No host: see publicAssetUrl(). */
|
|
18
|
+
declare const MISANS_FILES: readonly [{
|
|
19
|
+
readonly key: "fonts/misans/misans-400.6bf25dfdf3.woff2";
|
|
16
20
|
readonly weight: "400";
|
|
17
|
-
readonly
|
|
18
|
-
readonly bytes: 1142552;
|
|
21
|
+
readonly bytes: 535408;
|
|
19
22
|
}, {
|
|
20
|
-
readonly
|
|
23
|
+
readonly key: "fonts/misans/misans-500.442041bb9d.woff2";
|
|
21
24
|
readonly weight: "500";
|
|
22
|
-
readonly
|
|
23
|
-
readonly bytes: 1159128;
|
|
25
|
+
readonly bytes: 537060;
|
|
24
26
|
}, {
|
|
25
|
-
readonly
|
|
27
|
+
readonly key: "fonts/misans/misans-600.2590c17c53.woff2";
|
|
26
28
|
readonly weight: "600";
|
|
27
|
-
readonly
|
|
28
|
-
readonly bytes: 1162352;
|
|
29
|
+
readonly bytes: 540540;
|
|
29
30
|
}, {
|
|
30
|
-
readonly
|
|
31
|
+
readonly key: "fonts/misans/misans-700.ddd8bf8017.woff2";
|
|
31
32
|
readonly weight: "700";
|
|
32
|
-
readonly
|
|
33
|
-
readonly bytes: 1172244;
|
|
33
|
+
readonly bytes: 545728;
|
|
34
34
|
}];
|
|
35
35
|
|
|
36
|
-
export {
|
|
36
|
+
export { MISANS_CHAR_COUNT, MISANS_FAMILY, MISANS_FILES, MISANS_UNICODE_RANGE, MISANS_VARIABLE };
|
package/dist/generated/index.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
{ path: "./noto-sans-sc-500.woff2", weight: "500", style: "normal", bytes: 1159128 },
|
|
9
|
-
{ path: "./noto-sans-sc-600.woff2", weight: "600", style: "normal", bytes: 1162352 },
|
|
10
|
-
{ path: "./noto-sans-sc-700.woff2", weight: "700", style: "normal", bytes: 1172244 }
|
|
11
|
-
];
|
|
1
|
+
import {
|
|
2
|
+
MISANS_CHAR_COUNT,
|
|
3
|
+
MISANS_FAMILY,
|
|
4
|
+
MISANS_FILES,
|
|
5
|
+
MISANS_UNICODE_RANGE,
|
|
6
|
+
MISANS_VARIABLE
|
|
7
|
+
} from "../chunk-FUPJK5RT.js";
|
|
12
8
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
MISANS_CHAR_COUNT,
|
|
10
|
+
MISANS_FAMILY,
|
|
11
|
+
MISANS_FILES,
|
|
12
|
+
MISANS_UNICODE_RANGE,
|
|
13
|
+
MISANS_VARIABLE
|
|
18
14
|
};
|
|
19
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -4,11 +4,12 @@ var FONT_REGISTRY = {
|
|
|
4
4
|
geist: "--font-geist-sans",
|
|
5
5
|
"geist sans": "--font-geist-sans",
|
|
6
6
|
"geist mono": "--font-geist-mono",
|
|
7
|
-
// Self-hosted via next/font/local
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
// Self-hosted via next/font/local (see ./next-cjk). MiSans is the
|
|
8
|
+
// Simplified-Chinese face — CJK only via unicode-range, so it cannot take
|
|
9
|
+
// Latin away from Geist. DM Sans is the Latin display/heading face.
|
|
10
|
+
misans: "--font-misans",
|
|
11
|
+
"dm sans display": "--font-dm-sans",
|
|
12
|
+
// Self-hosted via next/font/local over @fontsource-variable/* (see ./next)
|
|
12
13
|
inter: "--font-inter",
|
|
13
14
|
"inter tight": "--font-reg-inter-tight",
|
|
14
15
|
"space grotesk": "--font-space-grotesk",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @nebutra/fonts — self-hosted OSS font registry (client-safe entry).\n *\n * Maps a normalized theme / DESIGN.md font-family name to the CSS variable that\n * the build-time self-hosted face defines (declared with next/font in\n * `@nebutra/fonts/next`, applied to <html> via `fontRegistryClassName`).\n *\n * WHY: next/font registers each face under a HASHED family name reachable ONLY\n * via its CSS variable — `font-family: 'Inter'` does NOT use the self-hosted\n * Inter. So when a theme / imported DESIGN.md font's primary family matches an\n * entry here, callers prepend `var(--font-…)` to the stack, making the\n * self-hosted font actually render — with ZERO runtime external requests\n * (next/font self-hosts at build time) and next/font's automatic metric-matched\n * fallback (no layout shift). Unmatched families keep their declared stack.\n *\n * This entry is FREE of `next/font` imports so client modules can use it.\n * The `./next` subpath holds the (server-only) next/font declarations and MUST\n * keep its CSS-variable names in sync with FONT_REGISTRY below.\n */\n\nexport const FONT_REGISTRY: Record<string, string> = {\n // Self-hosted via geist/font (default brand faces, loaded by the app shell)\n geist: \"--font-geist-sans\",\n \"geist sans\": \"--font-geist-sans\",\n \"geist mono\": \"--font-geist-mono\",\n // Self-hosted via next/font/local
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @nebutra/fonts — self-hosted OSS font registry (client-safe entry).\n *\n * Maps a normalized theme / DESIGN.md font-family name to the CSS variable that\n * the build-time self-hosted face defines (declared with next/font in\n * `@nebutra/fonts/next`, applied to <html> via `fontRegistryClassName`).\n *\n * WHY: next/font registers each face under a HASHED family name reachable ONLY\n * via its CSS variable — `font-family: 'Inter'` does NOT use the self-hosted\n * Inter. So when a theme / imported DESIGN.md font's primary family matches an\n * entry here, callers prepend `var(--font-…)` to the stack, making the\n * self-hosted font actually render — with ZERO runtime external requests\n * (next/font self-hosts at build time) and next/font's automatic metric-matched\n * fallback (no layout shift). Unmatched families keep their declared stack.\n *\n * This entry is FREE of `next/font` imports so client modules can use it.\n * The `./next` subpath holds the (server-only) next/font declarations and MUST\n * keep its CSS-variable names in sync with FONT_REGISTRY below.\n */\n\nexport const FONT_REGISTRY: Record<string, string> = {\n // Self-hosted via geist/font (default brand faces, loaded by the app shell)\n geist: \"--font-geist-sans\",\n \"geist sans\": \"--font-geist-sans\",\n \"geist mono\": \"--font-geist-mono\",\n // Self-hosted via next/font/local (see ./next-cjk). MiSans is the\n // Simplified-Chinese face — CJK only via unicode-range, so it cannot take\n // Latin away from Geist. DM Sans is the Latin display/heading face.\n misans: \"--font-misans\",\n \"dm sans display\": \"--font-dm-sans\",\n // Self-hosted via next/font/local over @fontsource-variable/* (see ./next)\n inter: \"--font-inter\",\n \"inter tight\": \"--font-reg-inter-tight\",\n \"space grotesk\": \"--font-space-grotesk\",\n \"playfair display\": \"--font-playfair-display\",\n fraunces: \"--font-reg-fraunces\",\n \"source serif 4\": \"--font-reg-source-serif-4\",\n \"jetbrains mono\": \"--font-jetbrains-mono\",\n manrope: \"--font-reg-manrope\",\n sora: \"--font-reg-sora\",\n \"work sans\": \"--font-reg-work-sans\",\n \"dm sans\": \"--font-reg-dm-sans\",\n \"plus jakarta sans\": \"--font-reg-plus-jakarta-sans\",\n outfit: \"--font-reg-outfit\",\n figtree: \"--font-reg-figtree\",\n montserrat: \"--font-reg-montserrat\",\n lexend: \"--font-reg-lexend\",\n \"fira code\": \"--font-reg-fira-code\",\n \"roboto mono\": \"--font-reg-roboto-mono\",\n \"source code pro\": \"--font-reg-source-code-pro\",\n};\n\n/** Normalize a single font-family token: strip quotes/whitespace, lowercase. */\nfunction normalizeFamily(name: string): string {\n // Strip ALL quotes with a quantifier-free global replace (quotes only appear\n // at token boundaries in a font-family value). Avoids the end-anchored /['\"]+$/\n // form, which CodeQL flags as polynomial ReDoS (scanned from every position).\n return name.replace(/['\"]/g, \"\").trim().toLowerCase();\n}\n\n/** The first (primary) family in a CSS font-family list, normalized. */\nexport function primaryFamily(stack: string): string {\n return normalizeFamily(stack.split(\",\")[0] ?? \"\");\n}\n\n/** Registry CSS variable for a stack's primary family, or undefined. */\nexport function resolveRegistryVar(stack: string): string | undefined {\n return FONT_REGISTRY[primaryFamily(stack)];\n}\n\n/**\n * Return `stack` with the self-hosted registry font prepended when its primary\n * family is registered; otherwise return it unchanged.\n * e.g. \"Space Grotesk, sans-serif\" → \"var(--font-space-grotesk), Space Grotesk, sans-serif\"\n */\nexport function withRegistryFont(stack: string | undefined): string | undefined {\n if (!stack) return stack;\n const variable = resolveRegistryVar(stack);\n return variable ? `var(${variable}), ${stack}` : stack;\n}\n\n/**\n * Like `withRegistryFont`, but matches the first registered family ANYWHERE in\n * the stack rather than only in first position.\n *\n * A brand package names the typeface the design language actually uses, and\n * those are frequently licensed faces we have no right to serve — Söhne, Mori,\n * Lyon Text, Reckless. The declared stack already says what to do when they are\n * absent: fall to the next family. But \"the next family\" is usually a bare name\n * like `Inter`, which does NOT reach next/font's hashed face, so the stack\n * skidded past every self-hosted option and landed on `ui-sans-serif`. All\n * seven built-in design languages rendered in the system font until 2026-08-18.\n *\n * Prepending the nearest registered family produces exactly the outcome the\n * declared chain intended, and leaves the licensed names in place so a customer\n * who does own the font still gets it by shipping the face themselves.\n */\nexport function withNearestRegistryFont(stack: string | undefined): string | undefined {\n if (!stack) return stack;\n for (const token of stack.split(\",\")) {\n const variable = FONT_REGISTRY[normalizeFamily(token)];\n if (variable) return `var(${variable}), ${stack}`;\n }\n return stack;\n}\n"],"mappings":";AAoBO,IAAM,gBAAwC;AAAA;AAAA,EAEnD,OAAO;AAAA,EACP,cAAc;AAAA,EACd,cAAc;AAAA;AAAA;AAAA;AAAA,EAId,QAAQ;AAAA,EACR,mBAAmB;AAAA;AAAA,EAEnB,OAAO;AAAA,EACP,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,MAAM;AAAA,EACN,aAAa;AAAA,EACb,WAAW;AAAA,EACX,qBAAqB;AAAA,EACrB,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,eAAe;AAAA,EACf,mBAAmB;AACrB;AAGA,SAAS,gBAAgB,MAAsB;AAI7C,SAAO,KAAK,QAAQ,SAAS,EAAE,EAAE,KAAK,EAAE,YAAY;AACtD;AAGO,SAAS,cAAc,OAAuB;AACnD,SAAO,gBAAgB,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,EAAE;AAClD;AAGO,SAAS,mBAAmB,OAAmC;AACpE,SAAO,cAAc,cAAc,KAAK,CAAC;AAC3C;AAOO,SAAS,iBAAiB,OAA+C;AAC9E,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,WAAW,mBAAmB,KAAK;AACzC,SAAO,WAAW,OAAO,QAAQ,MAAM,KAAK,KAAK;AACnD;AAkBO,SAAS,wBAAwB,OAA+C;AACrF,MAAI,CAAC,MAAO,QAAO;AACnB,aAAW,SAAS,MAAM,MAAM,GAAG,GAAG;AACpC,UAAM,WAAW,cAAc,gBAAgB,KAAK,CAAC;AACrD,QAAI,SAAU,QAAO,OAAO,QAAQ,MAAM,KAAK;AAAA,EACjD;AACA,SAAO;AACT;","names":[]}
|