23 lines
2.3 KiB
Markdown
23 lines
2.3 KiB
Markdown
|
|
# 0007 Yekan Bakh served from the app's public folder or a CDN
|
|||
|
|
|
|||
|
|
Status: Accepted · Area: design · Date: 2026-10-04 · Decided by: user · Supersedes: 0004
|
|||
|
|
|
|||
|
|
## Context
|
|||
|
|
Lumina uses two variable faces from `packages/island/src/fonts/`: Yekan Bakh FaNum (`yekan-bakh-fa-num-vf.woff2`), which draws Latin digits as Persian, and Yekan Bakh (`yekan-bakh-vf.woff2`), which keeps Latin digits. 0004 loaded them with `next/font/local`, which serves them only from `/_next/static/media`. The user wants fonts served as plain files from each app's `public/` or from a CDN, put there by a plugin (0008).
|
|||
|
|
|
|||
|
|
## Decision
|
|||
|
|
- `font-sans` is Yekan Bakh FaNum, for every UI text. Formatters output Latin digits, which the font draws as Persian, and insert `٬` and `٫` themselves, because the font doesn't map `,` and `.`.
|
|||
|
|
- `font-latin` is Yekan Bakh, only for text that must show Latin digits: شبا and other codes banks print in Latin digits.
|
|||
|
|
- Serve both as content-hashed files from the app's `public/fonts/`, or from a CDN under the same paths. Never use `next/font`, and never use a public third-party font CDN.
|
|||
|
|
- Declare them with `@font-face` (`font-display: swap`, weight 100–950, width 62.5–150%) and a size-adjusted fallback face over local Arial. island's `FontFaces` primitive renders these rules from the URLs in island env.
|
|||
|
|
- Preload only the FaNum face with `ReactDOM.preload(url, { as: 'font', type: 'font/woff2' })`, which adds `crossorigin`. The Latin face loads only where it's used.
|
|||
|
|
- A CDN on another origin must send `Access-Control-Allow-Origin`, because browsers fetch `@font-face` URLs in CORS mode.
|
|||
|
|
|
|||
|
|
## Alternatives
|
|||
|
|
- `next/font/local` with `assetPrefix` for the CDN (0004): it gives hashing, preload, and fallback metrics for free, but fonts can't live in `public/`.
|
|||
|
|
|
|||
|
|
## Consequences
|
|||
|
|
- We now own what `next/font` did: hashed names and immutable `Cache-Control` (the asset plugin), the preload (`FontFaces`), and the fallback metrics (`FONT_FALLBACK` in island `constants.ts`, measured on Persian text).
|
|||
|
|
- The font is licensed. "Never a public CDN" means only the company's own CDN. Confirm the licence covers web embedding from that CDN.
|
|||
|
|
- Debt: both apps still load the faces with `next/font/local` in `src/styles/fonts.ts`, and `island.css` says so. `FontFaces`, island env, `FONT_FALLBACK`, and the asset plugin don't exist yet.
|