2.4 KiB
2.4 KiB
0007 Yekan Bakh served from the app's public folder or a CDN
Status: Superseded by 0009 · 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-sansis 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-latinis 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 usenext/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'sFontFacesprimitive renders these rules from the URLs in island env. - Preload only the FaNum face with
ReactDOM.preload(url, { as: 'font', type: 'font/woff2' }), which addscrossorigin. The Latin face loads only where it's used. - A CDN on another origin must send
Access-Control-Allow-Origin, because browsers fetch@font-faceURLs in CORS mode.
Alternatives
next/font/localwithassetPrefixfor the CDN (0004): it gives hashing, preload, and fallback metrics for free, but fonts can't live inpublic/.
Consequences
- We now own what
next/fontdid: hashed names and immutableCache-Control(the asset plugin), the preload (FontFaces), and the fallback metrics (FONT_FALLBACKin islandconstants.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/localinsrc/styles/fonts.ts, andisland.csssays so.FontFacesandFONT_FALLBACKdon't exist yet; island env and the asset plugin do, and already write and pass the hashed font URLs.