@nebutra/fonts 2.0.0 → 3.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 CHANGED
@@ -1,3 +1,10 @@
1
1
  # @nebutra/fonts
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @nebutra/brand@3.0.0
9
+
3
10
  ## 2.0.0
package/NOTICE-FONTS.md CHANGED
@@ -2,18 +2,26 @@
2
2
 
3
3
  This package's MIT licence covers **first-party code only**.
4
4
 
5
- ## Noto Sans SC
5
+ ## MiSans
6
6
 
7
- 本软件使用了 **Noto Sans SC** 字体。
8
- This software uses the **Noto Sans SC** typeface.
7
+ 本软件使用了 **MiSans** 字体(小米科技有限责任公司)。
8
+ This software uses the **MiSans** typeface by Xiaomi.
9
9
 
10
- Noto Sans SC is licensed under the SIL Open Font License 1.1. The licence
11
- text is `vendor/noto-sans-sc/OFL.txt`.
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 credit
12
+ line on the product surfaces). The font may not be distributed on its own or
13
+ have its appearance altered. Licence text: `vendor/misans/LICENSE.txt`.
12
14
 
13
- Generated `.woff2` subsets stay in this workspace for first-party apps so
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
- Do not add `generated/*.woff2` or other font binaries to a publishable `files`
19
- glob.
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
+ ## Distribution
21
+
22
+ The DM Sans subset (`generated/dm-sans.woff2`) is committed so
23
+ `next/font/local` can load it offline; it is **not** in the npm `files` list.
24
+ MiSans subsets are never committed at all: the licence forbids distributing
25
+ the font on its own, so they are uploaded to the deployment's asset CDN and
26
+ `<CjkFontFace />` points at them. Do not add `generated/*.woff2` or other font
27
+ binaries to a publishable `files` glob.
package/README.md CHANGED
@@ -54,18 +54,14 @@ const stack = withRegistryFont("Space Grotesk, sans-serif");
54
54
  // "var(--font-space-grotesk), Space Grotesk, sans-serif"
55
55
  ```
56
56
 
57
- ## Simplified Chinese — self-hosted Noto Sans SC
57
+ ## Brand faces — DM Sans (headings) and MiSans (Chinese)
58
58
 
59
- Geist has no CJK coverage at all, so without a CJK face every Chinese character
60
- falls back to whatever the OS supplies: PingFang on macOS, Microsoft YaHei on
61
- Windows, something else again on Android. Chinese copy is a first-class surface
62
- in this product (see `docs/microcopy/`), so the CJK face is self-hosted and
63
- subset here.
59
+ Chosen 2026-09-25 by measuring what competitors ship: MiniMax and Moonshot set
60
+ Chinese in MiSans, DeepSeek and Databricks set Latin in DM Sans. Geist stays the
61
+ body/UI face for its tabular figures.
64
62
 
65
63
  ### Wiring an app
66
64
 
67
- Two lines in the root layout, beside the Geist loaders:
68
-
69
65
  ```tsx
70
66
  import { cjkFontClassName } from "@nebutra/fonts/next/cjk";
71
67
  import { GeistMono } from "geist/font/mono";
@@ -74,28 +70,35 @@ import { GeistSans } from "geist/font/sans";
74
70
  <html className={`${GeistSans.variable} ${GeistMono.variable} ${cjkFontClassName}`}>
75
71
  ```
76
72
 
77
- That defines `--font-noto-sans-sc`. Nothing else is needed: the token stacks in
78
- `@nebutra/tokens` (`--font-sans`, `--font-cn`, `--font-display`, `--font-heading`)
79
- already reference the variable in the right position. The app also needs
80
- `"@nebutra/fonts"` in `dependencies` and in `transpilePackages` (the package ships
81
- TypeScript source).
82
-
83
- Do **not** re-declare `--font-sans` and friends downstream. `@nebutra/ui`'s
84
- `typography/fonts.css` used to, and being the later import its Geist-only copies
85
- won, so the CJK half of the token stack never reached `--font-sans` at all. That
86
- duplication is gone; the file now only carries derived aliases.
73
+ `cjkFontClassName` defines `--font-dm-sans` (self-hosted variable subset, SIL
74
+ OFL). MiSans arrives through `<CjkFontFace />` from the same entry — render it
75
+ once in the root layout. It builds the `@font-face` rules at render time from
76
+ the committed keys and `publicAssetUrl()` (`NEXT_PUBLIC_R2_PUBLIC_URL`, then
77
+ `R2_PUBLIC_URL`, then the brand's `cdn` origin), so no host is hardcoded and a
78
+ scaffold resolves to its own CDN. The token stacks in `@nebutra/tokens` already
79
+ reference both. Non-Next hosts (Storybook) import `@nebutra/fonts/font-face` and
80
+ pass `origin` explicitly.
81
+
82
+ ### Why MiSans is on the CDN, not in this package
83
+
84
+ The MiSans licence allows free commercial use and embedding **with attribution**,
85
+ but forbids distributing the font software on its own. This repository is public
86
+ and mirrored as a template, so committing the subsets would distribute them —
87
+ the reason vivo Sans was removed (b5e73db35). `pnpm subset:cjk --upload` writes
88
+ content-hashed subsets to the bucket behind your public asset origin
89
+ (`MISANS_R2_BUCKET`, under `fonts/misans/`) and commits only their keys. Until
90
+ they are uploaded, or offline, the requests fail and the stack falls back to
91
+ PingFang / YaHei. Credit MiSans on product surfaces (see NOTICE-FONTS.md).
87
92
 
88
93
  ### Stack order is the design decision
89
94
 
90
95
  ```css
91
- font-family: var(--font-geist-sans), "Geist", var(--font-noto-sans-sc), "Noto Sans SC", …;
96
+ font-family: var(--font-geist-sans), "Geist", var(--font-misans, "MiSans"), …;
92
97
  ```
93
98
 
94
- Geist comes **first** and keeps Latin and the numerals — its tabular figures and
95
- tighter x-height are what dense dashboard tables need, and it is the locked UI
96
- face. Noto Sans SC takes CJK. Both faces cover Latin, so the *order* is what
97
- decides: reversed, Noto would take the Latin too, and its Latin is not as
98
- good as Geist's for UI.
99
+ The Latin face comes **first** and keeps Latin and the numerals; MiSans takes
100
+ CJK. Both cover Latin, so the order decides: reversed, MiSans would take the
101
+ Latin too.
99
102
 
100
103
  Belt and braces: the generated `@font-face` rules carry a `unicode-range` with
101
104
  no Latin, no ASCII and no general-punctuation codepoints in it, so a Latin-only
@@ -105,40 +108,37 @@ wrong way round. Geist Mono remains the code face.
105
108
  ### Building the subsets
106
109
 
107
110
  ```bash
108
- FONTTOOLS_PYTHON=/path/to/python \
109
- pnpm --filter @nebutra/fonts subset:cjk -- --force
111
+ FONTTOOLS_PYTHON=/path/to/python MISANS_ZIP=/path/to/MiSans.zip \
112
+ pnpm --filter @nebutra/fonts subset:cjk -- --force --upload
110
113
  ```
111
114
 
112
- Requires Python with `fontTools` and `brotli` (for `--flavor=woff2`).
113
- The script downloads the OFL Noto Sans SC variable face, instances 400 / 500 /
114
- 600 / 700, then subsets. Outputs land in `generated/`. The committed woff2
115
- files are the SIL OFL Noto Sans SC chinese-simplified faces used by
116
- `next/font/local` so a clean clone does not need fontTools to render text.
117
-
118
- ### Why three weights
119
-
120
- The design system's numeric slots are `--font-weight-medium: 500` and
121
- `--font-weight-heading: 600` (`packages/design/tokens/recipe.css`), and the token
122
- CSS writes literal `font-weight` in only four values: 500 (43×), 600 (35×),
123
- 400 (27×), 700 (10×). So 400 / 500 / 600 ship. 700 resolves to the 600 face by
124
- normal CSS font matching, and because that matched face is itself ≥ 600 no
125
- browser applies synthetic bold — which is precisely why the third face is
126
- DemiBold 600 rather than Bold 700. Choosing 700 instead would leave the *default*
127
- heading weight, the most common heading value in the system, a step out of place.
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.
115
+ Requires Python with `fontTools` and `brotli` (for `--flavor=woff2`) and a
116
+ logged-in `wrangler`. Without `MISANS_ZIP` the script downloads Xiaomi's official
117
+ package (`MISANS_ZIP_URL`). It subsets the static Regular / Medium / Semibold /
118
+ Bold faces, names each output by content hash, and with `--upload` puts them in
119
+ R2 (`MISANS_R2_BUCKET`) with an immutable cache header. Only `index.ts` (the
120
+ keys) and the manifest are committed; the woff2 files are gitignored. A hash change means a new URL, so
121
+ the CDN never serves a stale face. The bucket's CORS allowlist lives in
122
+ `infra/iac/cloudflare/r2/cors.json`: an app on a new origin gets no MiSans (the
123
+ stack silently falls back to PingFang) until its origin is added there.
124
+
125
+ ### Why four weights
126
+
127
+ `--font-weight-heading` is 500 (`packages/design/tokens/recipe.css`), body is
128
+ 400, and the token CSS writes literal 600 and 700 as well. Each static face
129
+ costs ~525 KB, and `unicode-range` plus per-weight `@font-face` means a page
130
+ only downloads the weights it renders.
130
131
 
131
132
  ### Why the static faces, not the variable one
132
133
 
133
134
  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. The
135
- pipeline instances 400 / 500 / 600 / 700 and subsets each one.
135
+ variable file costs more than the static weights a page actually uses.
136
136
 
137
137
  ### Character set
138
138
 
139
- Three inputs, unioned — 4,282 characters in the current build:
139
+ Three inputs, unioned — 4,330 characters in the current build:
140
140
 
141
- 1. **The zh catalogs, by glob** (1,586 chars) — every `zh*.json` under any
141
+ 1. **The zh catalogs, by glob** (1,662 chars) — every `zh*.json` under any
142
142
  `messages/` or `locales/` directory, walked at build time, so new Chinese copy
143
143
  is covered on the next run instead of drifting away from a hardcoded list.
144
144
  2. **CJK punctuation and fullwidth forms, wholesale** (197 chars) — U+3000–303F,
@@ -158,32 +158,22 @@ Three inputs, unioned — 4,282 characters in the current build:
158
158
  characters that appear in a fraction of a percent of text, which is exactly
159
159
  what OS fallback is for.
160
160
 
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
161
  ### Vendored sources
173
162
 
174
- `vendor/noto-sans-sc/OFL.txt` is committed. Full source TTFs are downloaded by
175
- `subset:cjk` and gitignored. Do not commit unmodified CJK source faces.
163
+ `vendor/misans/LICENSE.txt` (licence text and the FAQ answers on embedding) and
164
+ `vendor/dm-sans/OFL.txt` are committed. The MiSans zip and TTFs are gitignored.
165
+ Never commit a MiSans binary: the licence forbids distributing it on its own.
176
166
 
177
167
  ## Third-party font attribution
178
168
 
179
- 本软件使用了 **Noto Sans SC** 字体。
180
- This software uses the **Noto Sans SC** typeface.
169
+ 本产品使用了小米 **MiSans** 字体。
170
+ This product uses the **MiSans** typeface by Xiaomi.
181
171
 
182
- Noto Sans SC is licensed under the SIL Open Font License 1.1
183
- (`vendor/noto-sans-sc/OFL.txt`). That licence is separate from this package's
184
- MIT licence, which applies to first-party code only. Generated `.woff2` files
185
- stay in the workspace for first-party apps and are excluded from the npm
186
- tarball. See `NOTICE-FONTS.md`.
172
+ MiSans is free for commercial use under the MiSans Font Intellectual Property
173
+ License Agreement, which requires this attribution
174
+ (`vendor/misans/LICENSE.txt`). DM Sans is SIL OFL 1.1 (`vendor/dm-sans/OFL.txt`).
175
+ Both licences are separate from this package's MIT licence. See
176
+ `NOTICE-FONTS.md`.
187
177
 
188
178
  ## Registered Families
189
179
 
@@ -199,5 +189,5 @@ uses the corresponding CSS variable.
199
189
 
200
190
  ## License
201
191
 
202
- MIT for first-party code. Noto Sans SC binaries are SIL OFL 1.1 and are not
203
- published to npm.
192
+ MIT for first-party code. DM Sans is SIL OFL 1.1. MiSans binaries are never
193
+ committed or published to npm; they are served from the deployment's asset CDN.
@@ -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":[]}
@@ -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-JHYTIKKY.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 (`next/font/google` fails there):\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 ~16\n * `next/font/google` faces for the theme / DESIGN.md registry; importing it for\n * the brand faces would drag those build-time downloads into every app. `./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":[]}
@@ -1,36 +1,36 @@
1
1
  /**
2
- * GENERATED FILE — face metadata for `@nebutra/fonts/next/cjk`.
3
- * Current binaries are SIL OFL Noto Sans SC (chinese-simplified) woff2 files.
4
- * Rebuild with `pnpm --filter @nebutra/fonts subset:cjk` when FONTTOOLS_PYTHON
5
- * is available, or replace the woff2 files from an OFL source.
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 NOTO_SANS_SC_VARIABLE: "--font-noto-sans-sc";
8
- declare const NOTO_SANS_SC_FAMILY: "Noto Sans SC";
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 NOTO_SANS_SC_CHAR_COUNT: 4282;
14
+ declare const MISANS_CHAR_COUNT: 4330;
11
15
  /** `unicode-range` of every generated @font-face — CJK only, no Latin. */
12
- declare const NOTO_SANS_SC_UNICODE_RANGE: "U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF";
13
- /** Sources for `next/font/local({ src: [...] })`, paths relative to this file. */
14
- declare const NOTO_SANS_SC_SOURCES: readonly [{
15
- readonly path: "./noto-sans-sc-400.woff2";
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 style: "normal";
18
- readonly bytes: 1142552;
21
+ readonly bytes: 535408;
19
22
  }, {
20
- readonly path: "./noto-sans-sc-500.woff2";
23
+ readonly key: "fonts/misans/misans-500.442041bb9d.woff2";
21
24
  readonly weight: "500";
22
- readonly style: "normal";
23
- readonly bytes: 1159128;
25
+ readonly bytes: 537060;
24
26
  }, {
25
- readonly path: "./noto-sans-sc-600.woff2";
27
+ readonly key: "fonts/misans/misans-600.2590c17c53.woff2";
26
28
  readonly weight: "600";
27
- readonly style: "normal";
28
- readonly bytes: 1162352;
29
+ readonly bytes: 540540;
29
30
  }, {
30
- readonly path: "./noto-sans-sc-700.woff2";
31
+ readonly key: "fonts/misans/misans-700.ddd8bf8017.woff2";
31
32
  readonly weight: "700";
32
- readonly style: "normal";
33
- readonly bytes: 1172244;
33
+ readonly bytes: 545728;
34
34
  }];
35
35
 
36
- export { NOTO_SANS_SC_CHAR_COUNT, NOTO_SANS_SC_FAMILY, NOTO_SANS_SC_SOURCES, NOTO_SANS_SC_UNICODE_RANGE, NOTO_SANS_SC_VARIABLE };
36
+ export { MISANS_CHAR_COUNT, MISANS_FAMILY, MISANS_FILES, MISANS_UNICODE_RANGE, MISANS_VARIABLE };
@@ -1,19 +1,15 @@
1
- // generated/index.ts
2
- var NOTO_SANS_SC_VARIABLE = "--font-noto-sans-sc";
3
- var NOTO_SANS_SC_FAMILY = "Noto Sans SC";
4
- var NOTO_SANS_SC_CHAR_COUNT = 4282;
5
- var NOTO_SANS_SC_UNICODE_RANGE = "U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF";
6
- var NOTO_SANS_SC_SOURCES = [
7
- { path: "./noto-sans-sc-400.woff2", weight: "400", style: "normal", bytes: 1142552 },
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
- NOTO_SANS_SC_CHAR_COUNT,
14
- NOTO_SANS_SC_FAMILY,
15
- NOTO_SANS_SC_SOURCES,
16
- NOTO_SANS_SC_UNICODE_RANGE,
17
- NOTO_SANS_SC_VARIABLE
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":["../../generated/index.ts"],"sourcesContent":["/**\n * GENERATED FILE — face metadata for `@nebutra/fonts/next/cjk`.\n * Current binaries are SIL OFL Noto Sans SC (chinese-simplified) woff2 files.\n * Rebuild with `pnpm --filter @nebutra/fonts subset:cjk` when FONTTOOLS_PYTHON\n * is available, or replace the woff2 files from an OFL source.\n */\n\nexport const NOTO_SANS_SC_VARIABLE = \"--font-noto-sans-sc\" as const;\n\nexport const NOTO_SANS_SC_FAMILY = \"Noto Sans SC\" as const;\n\n/** Characters covered per face (catalogs ∪ CJK punctuation ∪ GB2312 level-1). */\nexport const NOTO_SANS_SC_CHAR_COUNT = 4282 as const;\n\n/** `unicode-range` of every generated @font-face — CJK only, no Latin. */\nexport const NOTO_SANS_SC_UNICODE_RANGE =\n \"U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF\" as const;\n\n/** Sources for `next/font/local({ src: [...] })`, paths relative to this file. */\nexport const NOTO_SANS_SC_SOURCES = [\n { path: \"./noto-sans-sc-400.woff2\", weight: \"400\", style: \"normal\", bytes: 1142552 },\n { path: \"./noto-sans-sc-500.woff2\", weight: \"500\", style: \"normal\", bytes: 1159128 },\n { path: \"./noto-sans-sc-600.woff2\", weight: \"600\", style: \"normal\", bytes: 1162352 },\n { path: \"./noto-sans-sc-700.woff2\", weight: \"700\", style: \"normal\", bytes: 1172244 },\n] as const;\n"],"mappings":";AAOO,IAAM,wBAAwB;AAE9B,IAAM,sBAAsB;AAG5B,IAAM,0BAA0B;AAGhC,IAAM,6BACX;AAGK,IAAM,uBAAuB;AAAA,EAClC,EAAE,MAAM,4BAA4B,QAAQ,OAAO,OAAO,UAAU,OAAO,QAAQ;AAAA,EACnF,EAAE,MAAM,4BAA4B,QAAQ,OAAO,OAAO,UAAU,OAAO,QAAQ;AAAA,EACnF,EAAE,MAAM,4BAA4B,QAAQ,OAAO,OAAO,UAAU,OAAO,QAAQ;AAAA,EACnF,EAAE,MAAM,4BAA4B,QAAQ,OAAO,OAAO,UAAU,OAAO,QAAQ;AACrF;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.js CHANGED
@@ -4,10 +4,11 @@ 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 from the subset built in ./generated (see
8
- // ./next-cjk). The Simplified-Chinese face — CJK only via unicode-range, so it
9
- // cannot take Latin away from Geist.
10
- "noto sans sc": "--font-noto-sans-sc",
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",
11
12
  // Self-hosted via next/font/google (see ./next)
12
13
  inter: "--font-inter",
13
14
  "inter tight": "--font-reg-inter-tight",
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 from the subset built in ./generated (see\n // ./next-cjk). The Simplified-Chinese face — CJK only via unicode-range, so it\n // cannot take Latin away from Geist.\n \"noto sans sc\": \"--font-noto-sans-sc\",\n // Self-hosted via next/font/google (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,gBAAgB;AAAA;AAAA,EAEhB,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":[]}
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/google (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":[]}
@@ -1,53 +1,55 @@
1
1
  import * as next_dist_compiled__next_font from 'next/dist/compiled/@next/font';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
 
3
4
  /**
4
- * @nebutra/fonts/next/cjk — the self-hosted Simplified-Chinese face (server-only).
5
+ * MiSans @font-face, rendered at request time rather than shipped as CSS.
5
6
  *
6
- * WHY A SEPARATE ENTRY FROM `./next`: that module declares ~16 `next/font/google`
7
- * faces for the theme / DESIGN.md registry. Importing it just to get the CJK face
8
- * would drag those build-time Google downloads into every app — and this repo has
9
- * a known trap where `next/font/google` fails outright in a network-sandboxed dev
10
- * server. This file imports `next/font/local` ONLY: the woff2 files live in the
11
- * workspace `generated/` directory (not the npm tarball), so first-party apps
12
- * work offline, in CI, and in the sandbox. `./next` re-exports it,
13
- * so an app already applying `fontRegistryClassName` still only needs one import.
7
+ * The MiSans licence forbids distributing the font on its own and this
8
+ * repository is public, so the subsets live in the deployment's public asset
9
+ * bucket and only their keys are committed (../generated/index.ts). A static
10
+ * stylesheet would have to spell out a host, and the host differs per
11
+ * deployment: Nebutra's CDN for Nebutra, the scaffold's own for a template
12
+ * user. publicAssetUrl() resolves it the way it resolves every other public
13
+ * asset — NEXT_PUBLIC_R2_PUBLIC_URL, then R2_PUBLIC_URL, then the brand's cdn
14
+ * origin.
14
15
  *
15
- * WHY SELF-HOSTED AT ALL: Geist has no CJK coverage, so without this every Chinese
16
- * character falls back to whatever the OS supplies — PingFang on macOS, Microsoft
17
- * YaHei on Windows, something else on Android. Chinese copy is a first-class
18
- * surface here (see docs/microcopy/), so the face is pinned rather than left to
19
- * the OS.
20
- *
21
- * The files are built by `pnpm --filter @nebutra/fonts subset:cjk` from
22
- * Noto Sans SC (SIL OFL) and live in the workspace `generated/` directory.
23
- * The literal `src` list below mirrors NOTO_SANS_SC_SOURCES in
24
- * ../generated/index.ts (a drift test in ./next-cjk.test.ts asserts they agree).
25
- * It is spelled out rather than spread because next/font is a compile-time
26
- * transform — SWC statically analyses this call, so the options object cannot
27
- * be computed.
16
+ * Before the subsets have been uploaded (a fresh scaffold, `pnpm subset:cjk
17
+ * --upload` not yet run) the requests 404 and the token stacks fall through to
18
+ * PingFang / YaHei. That is the intended degraded state, not an error.
28
19
  */
20
+ /** One @font-face per weight, CJK-only unicode-range, `swap` so text is never invisible. */
21
+ declare function misansFontFaceCss(origin?: string): string;
22
+ interface CjkFontFaceProps {
23
+ /** Asset origin override; defaults to the publicAssetUrl() resolution. */
24
+ origin?: string;
25
+ /**
26
+ * CSP nonce, for apps whose style-src allows inline styles only by nonce
27
+ * (apps/web). Without it the whole @font-face block is refused. The page's
28
+ * font-src must also allow publicAssetOrigin().
29
+ */
30
+ nonce?: string;
31
+ }
29
32
  /**
30
- * Noto Sans SC — 400 / 500 / 600 / 700 static subsets.
31
- *
32
- * - `preload: false` on purpose. Each weight is hundreds of KB; preloading them
33
- * on every route would tax Latin-only pages for nothing. The browser fetches
34
- * a weight only when a glyph in the `unicode-range` below actually renders.
35
- * - `declarations` carries that `unicode-range` (CJK blocks only — no ASCII, no
36
- * Latin, no general punctuation), so a Latin-only page can never trigger a CJK
37
- * download even if a font stack somewhere is written the wrong way round.
38
- * - `adjustFontFallback: false` — next/font's metric-matched fallback is derived
39
- * from Arial, which is meaningless for a Han face.
33
+ * Render once in each root layout, next to `cjkFontClassName` on <html>.
34
+ * React 19 hoists a `<style>` carrying `href` + `precedence` into <head> and
35
+ * dedupes it by `href`, so rendering it twice costs nothing.
36
+ */
37
+ declare function CjkFontFace({ origin, nonce }: CjkFontFaceProps): react_jsx_runtime.JSX.Element;
38
+
39
+ /**
40
+ * DM Sans — one variable file (opsz 9–40, wght 100–1000), Latin subset, 67KB.
41
+ * Preloaded: headings render above the fold on most pages.
40
42
  */
41
- declare const notoSansSc: next_dist_compiled__next_font.NextFontWithVariable;
43
+ declare const dmSans: next_dist_compiled__next_font.NextFontWithVariable;
42
44
  /**
43
- * Apply to <html> next to the Geist loaders so `--font-noto-sans-sc` exists:
45
+ * Apply to <html> next to the Geist loaders so `--font-dm-sans` exists:
44
46
  *
45
47
  * className={`${GeistSans.variable} ${GeistMono.variable} ${cjkFontClassName}`}
46
48
  *
47
- * The token stacks (`--font-sans` / `--font-cn` / `--font-display` in
48
- * @nebutra/tokens) reference the variable AFTER Geist, so Geist keeps Latin and
49
- * the numerals and only CJK falls through to this face.
49
+ * The name predates DM Sans; it now carries both brand faces so every app that
50
+ * already applies it picks them up without a layout change.
50
51
  */
52
+ declare const brandFontClassName: string;
51
53
  declare const cjkFontClassName: string;
52
54
 
53
- export { cjkFontClassName, notoSansSc };
55
+ export { CjkFontFace, brandFontClassName, cjkFontClassName, dmSans, misansFontFaceCss };
package/dist/next-cjk.js CHANGED
@@ -1,9 +1,16 @@
1
1
  import {
2
+ CjkFontFace,
3
+ brandFontClassName,
2
4
  cjkFontClassName,
3
- notoSansSc
4
- } from "./chunk-GRE7GS6W.js";
5
+ dmSans,
6
+ misansFontFaceCss
7
+ } from "./chunk-JHYTIKKY.js";
8
+ import "./chunk-FUPJK5RT.js";
5
9
  export {
10
+ CjkFontFace,
11
+ brandFontClassName,
6
12
  cjkFontClassName,
7
- notoSansSc
13
+ dmSans,
14
+ misansFontFaceCss
8
15
  };
9
16
  //# sourceMappingURL=next-cjk.js.map
package/dist/next.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as next_dist_compiled__next_font from 'next/dist/compiled/@next/font';
2
- export { cjkFontClassName, notoSansSc } from './next-cjk.js';
2
+ export { CjkFontFace, brandFontClassName, cjkFontClassName, dmSans } from './next-cjk.js';
3
+ import 'react/jsx-runtime';
3
4
 
4
5
  /** All registry faces, in declaration order. */
5
6
  declare const FONT_REGISTRY_FACES: readonly [next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable, next_dist_compiled__next_font.NextFontWithVariable];