@istmx/skills 1.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.
Files changed (210) hide show
  1. package/README.md +49 -0
  2. package/bin/cli.js +251 -0
  3. package/istm/SKILL.md +65 -0
  4. package/istm-animate/SKILL.md +87 -0
  5. package/istm-animate/animations/animation_utils.md +280 -0
  6. package/istm-animate/animations/animations.md +220 -0
  7. package/istm-animate/animations/core_motion.md +250 -0
  8. package/istm-animate/animations/examples/README.md +29 -0
  9. package/istm-animate/animations/examples/nuxt/app/app.vue +3 -0
  10. package/istm-animate/animations/examples/nuxt/app/composables/useGSAP.ts +91 -0
  11. package/istm-animate/animations/examples/nuxt/app/pages/index.vue +55 -0
  12. package/istm-animate/animations/examples/nuxt/nuxt.config.ts +4 -0
  13. package/istm-animate/animations/examples/nuxt/package.json +18 -0
  14. package/istm-animate/animations/examples/react/App.jsx +46 -0
  15. package/istm-animate/animations/examples/react/index.html +12 -0
  16. package/istm-animate/animations/examples/react/main.jsx +9 -0
  17. package/istm-animate/animations/examples/react/package.json +21 -0
  18. package/istm-animate/animations/examples/react/vite.config.js +7 -0
  19. package/istm-animate/animations/examples/vanilla/index.html +33 -0
  20. package/istm-animate/animations/examples/vanilla/main.js +36 -0
  21. package/istm-animate/animations/examples/vue/app.vue +47 -0
  22. package/istm-animate/animations/examples/vue/index.html +15 -0
  23. package/istm-animate/animations/examples/vue/main.js +9 -0
  24. package/istm-animate/animations/examples/vue/package.json +19 -0
  25. package/istm-animate/animations/examples/vue/vite.config.js +7 -0
  26. package/istm-animate/animations/framework_motion.md +262 -0
  27. package/istm-animate/animations/motion.csv +17 -0
  28. package/istm-animate/animations/motion.md +11 -0
  29. package/istm-animate/animations/motion_catalog.json +226 -0
  30. package/istm-animate/animations/motion_performance.md +75 -0
  31. package/istm-animate/animations/motion_plugins.md +429 -0
  32. package/istm-animate/animations/react_animations.md +132 -0
  33. package/istm-animate/animations/scroll_trigger_effects.md +291 -0
  34. package/istm-animate/animations/timeline_sequencing.md +103 -0
  35. package/istm-architecture/SKILL.md +109 -0
  36. package/istm-architecture/frameworks/angular.csv +51 -0
  37. package/istm-architecture/frameworks/astro.csv +54 -0
  38. package/istm-architecture/frameworks/avalonia.csv +57 -0
  39. package/istm-architecture/frameworks/flutter.csv +53 -0
  40. package/istm-architecture/frameworks/javafx.csv +76 -0
  41. package/istm-architecture/frameworks/jetpack-compose.csv +53 -0
  42. package/istm-architecture/frameworks/laravel.csv +51 -0
  43. package/istm-architecture/frameworks/nextjs.csv +53 -0
  44. package/istm-architecture/frameworks/nuxtjs.csv +59 -0
  45. package/istm-architecture/frameworks/react-native.csv +52 -0
  46. package/istm-architecture/frameworks/react.csv +54 -0
  47. package/istm-architecture/frameworks/svelte.csv +54 -0
  48. package/istm-architecture/frameworks/swiftui.csv +51 -0
  49. package/istm-architecture/frameworks/uwp.csv +56 -0
  50. package/istm-architecture/frameworks/vue.csv +50 -0
  51. package/istm-architecture/frameworks/winui.csv +60 -0
  52. package/istm-architecture/frameworks/wpf.csv +57 -0
  53. package/istm-architecture/templates/agents.md +229 -0
  54. package/istm-architecture/templates/architecture.md +111 -0
  55. package/istm-architecture/templates/design.md +138 -0
  56. package/istm-architecture/templates/project-overview.md +215 -0
  57. package/istm-awwward-designer/SKILL.md +43 -0
  58. package/istm-awwward-designer/libraries/threejs.csv +54 -0
  59. package/istm-awwward-designer/references/accessibility.md +774 -0
  60. package/istm-awwward-designer/references/anim-anti-patterns.md +576 -0
  61. package/istm-awwward-designer/references/animation-map.md +166 -0
  62. package/istm-awwward-designer/references/animation-standards.md +86 -0
  63. package/istm-awwward-designer/references/anti-patterns.md +191 -0
  64. package/istm-awwward-designer/references/color-systems.md +604 -0
  65. package/istm-awwward-designer/references/css-performance.md +477 -0
  66. package/istm-awwward-designer/references/descender-safety.md +490 -0
  67. package/istm-awwward-designer/references/design-audit.md +93 -0
  68. package/istm-awwward-designer/references/font-loading.md +378 -0
  69. package/istm-awwward-designer/references/image-optimization.md +440 -0
  70. package/istm-awwward-designer/references/invention-gate.md +356 -0
  71. package/istm-awwward-designer/references/micro-interactions.md +825 -0
  72. package/istm-awwward-designer/references/page-transitions.md +365 -0
  73. package/istm-awwward-designer/references/performance-standards.md +79 -0
  74. package/istm-awwward-designer/references/quality-gate.md +103 -0
  75. package/istm-awwward-designer/references/responsive-design.md +778 -0
  76. package/istm-awwward-designer/references/scoring-guide.md +201 -0
  77. package/istm-awwward-designer/references/scroll-patterns.md +668 -0
  78. package/istm-awwward-designer/references/stitch-brief.md +124 -0
  79. package/istm-awwward-designer/references/tech-stack.md +204 -0
  80. package/istm-awwward-designer/references/technical-audit.md +133 -0
  81. package/istm-awwward-designer/references/technique-families.md +293 -0
  82. package/istm-awwward-designer/references/testing.md +535 -0
  83. package/istm-awwward-designer/references/text-animation.md +585 -0
  84. package/istm-awwward-designer/references/typography.md +504 -0
  85. package/istm-awwward-designer/references/usability-audit.md +108 -0
  86. package/istm-awwward-designer/references/visual-standards.md +97 -0
  87. package/istm-design/SKILL.md +98 -0
  88. package/istm-design/colors/color_theory.md +293 -0
  89. package/istm-design/colors/colors.csv +193 -0
  90. package/istm-design/colors/colors_catalog.json +4034 -0
  91. package/istm-design/colors/palette.json +21 -0
  92. package/istm-design/styles/design_system.md +288 -0
  93. package/istm-design/styles/html-tailwind.csv +56 -0
  94. package/istm-design/styles/nuxt-ui.csv +71 -0
  95. package/istm-design/styles/product_design.md +55 -0
  96. package/istm-design/styles/shadcn.csv +61 -0
  97. package/istm-design/styles/style.md +12 -0
  98. package/istm-design/styles/styles.csv +85 -0
  99. package/istm-design/styles/styles_catalog.json +2018 -0
  100. package/istm-design/styles/ui-reasoning.csv +162 -0
  101. package/istm-design/styles/uno.csv +60 -0
  102. package/istm-design/typography/font_and_font.md +10 -0
  103. package/istm-design/typography/google-fonts.csv +1924 -0
  104. package/istm-design/typography/sans_serif_fonts.md +112 -0
  105. package/istm-design/typography/typography.csv +75 -0
  106. package/istm-design/typography/typography_catalog.json +964 -0
  107. package/istm-design/ux/app-interface.csv +31 -0
  108. package/istm-design/ux/charts.csv +26 -0
  109. package/istm-design/ux/icons.csv +106 -0
  110. package/istm-design/ux/landing.csv +35 -0
  111. package/istm-design/ux/products.csv +193 -0
  112. package/istm-design/ux/react-performance.csv +45 -0
  113. package/istm-design/ux/responsive_rules.md +62 -0
  114. package/istm-design/ux/storytelling.md +47 -0
  115. package/istm-design/ux/ux-guidelines.csv +100 -0
  116. package/istm-design/ux/ux_guidelines.json +1190 -0
  117. package/istm-system-design/SKILL.md +88 -0
  118. package/istm-system-design/principles/01-architecture-patterns.md +24 -0
  119. package/istm-system-design/principles/02-database-selection.md +32 -0
  120. package/istm-system-design/principles/03-api-design.md +25 -0
  121. package/istm-system-design/principles/04-authentication-security.md +23 -0
  122. package/istm-system-design/principles/05-caching-performance.md +21 -0
  123. package/istm-system-design/principles/06-asynchronous-processing.md +17 -0
  124. package/istm-system-design/principles/07-infrastructure-deployment.md +22 -0
  125. package/istm-system-design/principles/08-low-level-design.md +35 -0
  126. package/istm-system-design/principles/09-state-management.md +14 -0
  127. package/istm-system-design/principles/10-error-handling-and-logging.md +26 -0
  128. package/istm-system-design/principles/11-testing-strategy.md +18 -0
  129. package/istm-system-design/principles/12-seo-and-web-vitals.md +18 -0
  130. package/istm-system-design/stacks/SETUP.md +82 -0
  131. package/istm-system-design/stacks/STACK.md +67 -0
  132. package/istm-system-design/stacks/WORKFLOW.md +84 -0
  133. package/istm-system-design/templates/api-route.ts.template +32 -0
  134. package/istm-system-design/templates/migrations.md.template +30 -0
  135. package/istm-system-design/templates/schema.drizzle.ts.template +17 -0
  136. package/istm-system-design/templates/schema.prisma.template +28 -0
  137. package/istm-system-design/templates/trpc-router.ts.template +22 -0
  138. package/istm-system-design/templates/zod-validators.ts.template +14 -0
  139. package/istm-workflow/istm-audit/SKILL.md +108 -0
  140. package/istm-workflow/istm-audit/agent-prompt.md +393 -0
  141. package/istm-workflow/istm-audit/agents/openai.yaml +7 -0
  142. package/istm-workflow/istm-audit/modes/area.md +19 -0
  143. package/istm-workflow/istm-audit/modes/gapfill.md +12 -0
  144. package/istm-workflow/istm-audit/modes/greenfield.md +24 -0
  145. package/istm-workflow/istm-audit/modes/tool-skills.md +39 -0
  146. package/istm-workflow/istm-audit/modes/whole-repo.md +5 -0
  147. package/istm-workflow/istm-audit/patterns/clean-architecture.md +15 -0
  148. package/istm-workflow/istm-audit/patterns/domain-driven.md +16 -0
  149. package/istm-workflow/istm-audit/patterns/functional.md +16 -0
  150. package/istm-workflow/istm-audit/patterns/solid-oop.md +17 -0
  151. package/istm-workflow/istm-check/SKILL.md +52 -0
  152. package/istm-workflow/istm-check/agents/openai.yaml +7 -0
  153. package/istm-workflow/istm-check/modes/review.md +156 -0
  154. package/istm-workflow/istm-check/modes/verify.md +197 -0
  155. package/istm-workflow/istm-check/review-agent-prompt.md +57 -0
  156. package/istm-workflow/istm-check/review-guide.md +133 -0
  157. package/istm-workflow/istm-craft/SKILL.md +37 -0
  158. package/istm-workflow/istm-craft/agent-modes/architecture.md +73 -0
  159. package/istm-workflow/istm-craft/agent-modes/cross-cutting.md +65 -0
  160. package/istm-workflow/istm-craft/agent-modes/enhancement.md +45 -0
  161. package/istm-workflow/istm-craft/agent-modes/feature.md +85 -0
  162. package/istm-workflow/istm-craft/agent-prompt.md +249 -0
  163. package/istm-workflow/istm-craft/agents/openai.yaml +7 -0
  164. package/istm-workflow/istm-craft/internal/after-subagent.md +90 -0
  165. package/istm-workflow/istm-craft/internal/design-conversation.md +140 -0
  166. package/istm-workflow/istm-craft/internal/tool-discovery.md +58 -0
  167. package/istm-workflow/istm-craft/spec-template.md +278 -0
  168. package/istm-workflow/istm-debug/SKILL.md +102 -0
  169. package/istm-workflow/istm-debug/agents/openai.yaml +7 -0
  170. package/istm-workflow/istm-develop/SKILL.md +144 -0
  171. package/istm-workflow/istm-develop/agents/openai.yaml +7 -0
  172. package/istm-workflow/istm-develop/checklist.md +95 -0
  173. package/istm-workflow/istm-develop/flow/build.md +133 -0
  174. package/istm-workflow/istm-develop/flow/git.md +34 -0
  175. package/istm-workflow/istm-develop/logical-guide.md +99 -0
  176. package/istm-workflow/istm-develop/ui/existing.md +23 -0
  177. package/istm-workflow/istm-develop/ui/generate.md +131 -0
  178. package/istm-workflow/istm-develop/ui/image.md +41 -0
  179. package/istm-workflow/istm-develop/ui/implementation.md +281 -0
  180. package/istm-workflow/istm-develop/ui/mcp.md +11 -0
  181. package/istm-workflow/istm-develop/ui-guide.md +164 -0
  182. package/istm-workflow/istm-document/SKILL.md +123 -0
  183. package/istm-workflow/istm-document/agent-prompt.md +57 -0
  184. package/istm-workflow/istm-document/agents/openai.yaml +7 -0
  185. package/istm-workflow/istm-document/templates/changelog.md +54 -0
  186. package/istm-workflow/istm-document/templates/postmortem.md +58 -0
  187. package/istm-workflow/istm-document/templates/pr.md +43 -0
  188. package/istm-workflow/istm-document/templates/release-note.md +41 -0
  189. package/istm-workflow/istm-scope/SKILL.md +100 -0
  190. package/istm-workflow/istm-scope/agents/openai.yaml +7 -0
  191. package/istm-workflow/istm-scope/approaches/facade.md +33 -0
  192. package/istm-workflow/istm-scope/approaches/journey.md +31 -0
  193. package/istm-workflow/istm-scope/approaches/skateboard.md +33 -0
  194. package/istm-workflow/istm-scope/approaches/tracer-bullet.md +34 -0
  195. package/istm-workflow/istm-scope/modes/add.md +14 -0
  196. package/istm-workflow/istm-scope/modes/plan-brownfield.md +11 -0
  197. package/istm-workflow/istm-scope/modes/plan-greenfield.md +20 -0
  198. package/istm-workflow/istm-scope/modes/plan-monorepo.md +8 -0
  199. package/istm-workflow/istm-scope/modes/plan.md +120 -0
  200. package/istm-workflow/istm-scope/modes/replan.md +13 -0
  201. package/istm-workflow/istm-scope/scope-template.md +148 -0
  202. package/istm-workflow/istm-sync/SKILL.md +166 -0
  203. package/istm-workflow/istm-sync/agent-prompt.md +211 -0
  204. package/istm-workflow/istm-sync/agents/openai.yaml +7 -0
  205. package/istm-workflow/istm-test/SKILL.md +233 -0
  206. package/istm-workflow/istm-test/agent-prompt.md +62 -0
  207. package/istm-workflow/istm-test/agents/openai.yaml +7 -0
  208. package/istm-workflow/istm-test/modes/setup.md +97 -0
  209. package/istm-workflow/istm-test/writing-guide.md +196 -0
  210. package/package.json +35 -0
@@ -0,0 +1,378 @@
1
+ # Font Loading — Deep Dive
2
+
3
+ Web fonts are one of the most common sources of both LCP delay and CLS. A misconfigured font stack causes invisible text, layout shifts, and render-blocking requests. Get this right and your CLS score will thank you.
4
+
5
+ ---
6
+
7
+ ## The Font Loading Problem
8
+
9
+ Default font behavior: browser downloads font → renders text. This causes:
10
+ 1. **Flash of Invisible Text (FOIT)** — Text invisible during font load (bad for LCP)
11
+ 2. **Flash of Unstyled Text (FOUT)** — Fallback font visible, then swaps (causes CLS)
12
+ 3. **Render blocking** — Browser can't render text until font is available (slow FCP)
13
+
14
+ ---
15
+
16
+ ## font-display
17
+
18
+ The `font-display` property controls how the browser handles text during font load.
19
+
20
+ ```css
21
+ @font-face {
22
+ font-family: 'MyFont';
23
+ src: url('myfont.woff2') format('woff2');
24
+ font-display: swap; /* Key setting */
25
+ }
26
+ ```
27
+
28
+ | Value | Behavior | FOUT? | FOIT? | Best For |
29
+ |-------|---------|-------|-------|----------|
30
+ | `swap` | Fallback → swap in | Yes | No | Body text, headings |
31
+ | `optional` | Use fallback only | No | No | Body text (accepts FOUT) |
32
+ | `fallback` | Short wait → fallback | Yes | Brief | Body text |
33
+ | `block` | Block up to 3s → fallback | No | Yes | Never use (blocks rendering) |
34
+ | `auto` | Browser default | Varies | Varies | Never use explicitly |
35
+
36
+ **Recommendation: `font-display: swap` for everything.** Accept the brief FOUT. It's better than invisible text or blocking.
37
+
38
+ ---
39
+
40
+ ## Preloading Critical Fonts
41
+
42
+ ```html
43
+ <head>
44
+ <!-- Preload WOFF2 only — never preload WOFF or TTF -->
45
+ <link
46
+ rel="preload"
47
+ href="/fonts/heading.woff2"
48
+ as="font"
49
+ type="font/woff2"
50
+ crossorigin
51
+ >
52
+ </head>
53
+ ```
54
+
55
+ ```css
56
+ @font-face {
57
+ font-family: 'HeadingFont';
58
+ src: url('/fonts/heading.woff2') format('woff2');
59
+ font-weight: 700;
60
+ font-display: swap;
61
+ }
62
+ ```
63
+
64
+ ### Critical Path Font Subsetting
65
+
66
+ Only preload what you need in the critical path. If you have 5 font weights but only load 2 for above-fold content, preload only those 2.
67
+
68
+ ```html
69
+ <!-- Only preload the 2 weights needed above fold -->
70
+ <link rel="preload" href="/fonts/Inter-400.woff2" as="font" crossorigin>
71
+ <link rel="preload" href="/fonts/Inter-700.woff2" as="font" crossorigin>
72
+ ```
73
+
74
+ ### Preconnect to Font Origins
75
+
76
+ ```html
77
+ <head>
78
+ <!-- Preconnect — establish connection early -->
79
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
80
+ <link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
81
+
82
+ <!-- Only if using Google Fonts (prefer self-hosting) -->
83
+ <link rel="preload" href="..." as="font" crossorigin>
84
+ </head>
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Self-Hosting Fonts
90
+
91
+ **Self-hosting is always better than Google Fonts.** Why?
92
+ - Eliminates DNS lookup + connection to `fonts.googleapis.com` / `fonts.gstatic.com`
93
+ - One fewer render-blocking chain
94
+ - Full control over font files and subsetting
95
+ - No third-party tracking
96
+
97
+ ### The Google Fonts Round-Trip Problem
98
+
99
+ ```
100
+ User → Google Fonts CSS → Google Fonts WOFF2 → Render text
101
+ ↑ 1 RTT ↑ Another RTT
102
+ ```
103
+
104
+ With self-hosting:
105
+ ```
106
+ User → Your CDN → Render text
107
+ ↑ 1 RTT
108
+ ```
109
+
110
+ ### Self-Hosting with Fontsource
111
+
112
+ ```bash
113
+ bun add @fontsource/inter
114
+ ```
115
+
116
+ ```css
117
+ /* In your CSS entry point */
118
+ @import '@fontsource/inter/400.css';
119
+ @import '@fontsource/inter/700.css';
120
+
121
+ /* Or in your HTML */
122
+ <link rel="stylesheet" href="/node_modules/@fontsource/inter/400.css">
123
+ ```
124
+
125
+ ### Self-Hosting Manual
126
+
127
+ ```bash
128
+ # Download WOFF2 from Google Fonts (via fontsource or google-webfonts-helper)
129
+ wget https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hjp-Ek-_EeA.woff2
130
+
131
+ # Place in /public/fonts/
132
+ ```
133
+
134
+ ```css
135
+ @font-face {
136
+ font-family: 'Inter';
137
+ src: url('/fonts/inter-400.woff2') format('woff2');
138
+ font-weight: 400;
139
+ font-style: normal;
140
+ font-display: swap;
141
+ }
142
+
143
+ @font-face {
144
+ font-family: 'Inter';
145
+ src: url('/fonts/inter-700.woff2') format('woff2');
146
+ font-weight: 700;
147
+ font-style: normal;
148
+ font-display: swap;
149
+ }
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Font Subsetting
155
+
156
+ ### What to Subset
157
+
158
+ | Scope | Character Count | Example |
159
+ |-------|----------------|---------|
160
+ | Latin only | ~100-200 chars | a-z, A-Z, 0-9, punctuation |
161
+ | Extended Latin | ~300-400 chars | Latin + accented characters |
162
+ | Full | 10,000+ chars | All Unicode glyphs |
163
+
164
+ ### Subsetting with Glyphhanger
165
+
166
+ ```bash
167
+ # Install glyphhanger
168
+ bunx glyphhanger --subset=fonts/MyFont.woff2 --whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\ .,\!\? --
169
+ ```
170
+
171
+ ### Subsetting with pyftsubset (Python)
172
+
173
+ ```bash
174
+ # Install fonttools
175
+ pip install fonttools brotli zopfli
176
+
177
+ pyftsubset fonts/MyFont.woff2 \
178
+ --unicodes="U+0020-007E" \
179
+ --output-file=fonts/MyFont-subset.woff2
180
+ ```
181
+
182
+ ### Content-Aware Subsetting
183
+
184
+ Generate the character set from your actual content:
185
+
186
+ ```bash
187
+ # Extract all unique characters from your HTML
188
+ cat dist/index.html | grep -o '[[:alnum:][:punct:][:space:]]' | sort -u | tr -d '\n'
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Variable Fonts
194
+
195
+ Variable fonts combine multiple weights, widths, and styles into a single file. One variable font replaces 4-10 static font files.
196
+
197
+ ### Static vs Variable
198
+
199
+ ```
200
+ Static: inter-300.woff2 + inter-400.woff2 + inter-700.woff2 + inter-900.woff2
201
+ = 4 requests, ~200-400KB total
202
+
203
+ Variable: Inter-Variable.woff2
204
+ = 1 request, ~100-200KB total
205
+ ```
206
+
207
+ ### Using Variable Fonts
208
+
209
+ ```css
210
+ @font-face {
211
+ font-family: 'InterVariable';
212
+ src: url('/fonts/Inter-Variable.woff2') format('woff-variations');
213
+ font-weight: 100 900; /* Full weight range */
214
+ font-display: swap;
215
+ }
216
+
217
+ /* Use any weight */
218
+ h1 { font-weight: 800; }
219
+ .body { font-weight: 400; }
220
+ .caption { font-weight: 300; }
221
+ ```
222
+
223
+ ### Variable Font Axes
224
+
225
+ | Axis Tag | Name | Example |
226
+ |----------|------|---------|
227
+ | wght | Weight | 100–900 |
228
+ | wdth | Width | 75–125 |
229
+ | ital | Italic | 0–1 |
230
+ | slnt | Slant | -12–0 |
231
+ | opsz | Optical Size | 8–144 |
232
+
233
+ ```css
234
+ /* Optical size — larger text gets slightly different metrics */
235
+ .body-text { font-variation-settings: 'opsz' 16; }
236
+ .heading { font-variation-settings: 'opsz' 48; }
237
+ ```
238
+
239
+ ---
240
+
241
+ ## Font Metric Stability (CLS Prevention)
242
+
243
+ The #1 cause of CLS after images is **font swap causing layout shift**. When the fallback font metrics (x-height, cap height, character width) differ from the web font, text reflows when the web font loads.
244
+
245
+ ### The Problem
246
+
247
+ ```
248
+ Fallback font: "Times New Roman" → Renders at 16px
249
+ Web font: "Inter" → Renders at 16px
250
+
251
+ BUT: x-height differs, cap height differs, character widths differ
252
+ → Text reflows → CLS spike
253
+ ```
254
+
255
+ ### size-adjust — Fix Glyph Metrics
256
+
257
+ ```css
258
+ @font-face {
259
+ font-family: 'Inter-fallback';
260
+ src: local('Arial');
261
+ font-display: swap;
262
+ /* Adjust so fallback metrics match Inter */
263
+ size-adjust: 103%;
264
+ ascent-override: 95%;
265
+ descent-override: 20%;
266
+ }
267
+ ```
268
+
269
+ ### Generating Override Values
270
+
271
+ Use [Fontaine](https://github.com/unjs/fontaine) (automated) or [next/font](https://nextjs.org/docs/app/building-your-application/optimizing/fonts):
272
+
273
+ ```js
274
+ // Fontaine (for Vite/Node)
275
+ import { createFontMetricsFallback } from 'fontaine';
276
+
277
+ const { metrics, fallback } = createFontMetricsFallback(
278
+ 'Inter',
279
+ '/fonts/Inter-Variable.woff2',
280
+ { weight: '400' }
281
+ );
282
+
283
+ // Metrics are auto-calculated
284
+ ```
285
+
286
+ ### The Complete CLS-Prevention Font Stack
287
+
288
+ ```css
289
+ @font-face {
290
+ font-family: 'MyFont-fallback';
291
+ src: local('Arial');
292
+ font-display: swap;
293
+ size-adjust: 104%; /* Match x-height */
294
+ ascent-override: 93%; /* Match cap-height */
295
+ descent-override: 23%; /* Match baseline */
296
+ line-gap-override: 0%; /* Match leading */
297
+ }
298
+
299
+ /* Primary with fallback chain */
300
+ .primary-text {
301
+ font-family: 'Inter', 'Inter-fallback', 'Arial', sans-serif;
302
+ }
303
+ ```
304
+
305
+ ---
306
+
307
+ ## CSS Custom Properties for Font Loading
308
+
309
+ ```css
310
+ :root {
311
+ /* Define the font stack once */
312
+ --font-sans: 'Inter', 'Inter-fallback', system-ui, sans-serif;
313
+ --font-display: 'HeadingFont', 'Georgia', serif;
314
+ --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
315
+
316
+ /* Font metric adjustments (generated by Fontaine) */
317
+ --font-sans-fallback-size-adjust: 103%;
318
+ --font-sans-fallback-ascent: 93%;
319
+ --font-sans-fallback-descent: 23%;
320
+ }
321
+
322
+ @font-face {
323
+ font-family: 'Inter-fallback';
324
+ src: local('Arial');
325
+ font-display: swap;
326
+ size-adjust: var(--font-sans-fallback-size-adjust);
327
+ ascent-override: var(--font-sans-fallback-ascent);
328
+ descent-override: var(--font-sans-fallback-descent);
329
+ }
330
+ ```
331
+
332
+ ---
333
+
334
+ ## Font Loading Checklist
335
+
336
+ ```plaintext
337
+ □ WOFF2 only (never WOFF, never TTF, never OTF)
338
+ □ font-display: swap on every @font-face
339
+ □ Preload critical font files (<link rel="preload">)
340
+ □ Preconnect to font origins (<link rel="preconnect">)
341
+ □ Self-host fonts (avoid Google Fonts round-trip)
342
+ □ Subset fonts to required character ranges
343
+ □ Use variable fonts to reduce request count
344
+ □ size-adjust + ascent-override + descent-override for metric stability
345
+ □ Local font fallback with matching metrics (Arial or system-ui)
346
+ □ CSS custom properties for font stack consistency
347
+ □ Only preload fonts needed above the fold
348
+ □ defer non-critical font weights with FontFace API
349
+ □ Use Fontsource for easy self-hosted Google Fonts
350
+ □ Set Cache-Control: immutable for versioned font files
351
+ ```
352
+
353
+ ---
354
+
355
+ ## Font Loading API (Advanced)
356
+
357
+ ```js
358
+ // Load fonts dynamically with FontFace API
359
+ async function loadFonts() {
360
+ try {
361
+ await document.fonts.load('400 16px Inter');
362
+ await document.fonts.ready;
363
+ console.log('Fonts loaded and ready');
364
+ } catch (e) {
365
+ console.warn('Font loading failed:', e);
366
+ }
367
+ }
368
+
369
+ // CSS font loading with link preload
370
+ // This approach gives full control
371
+ const fontLink = document.createElement('link');
372
+ fontLink.rel = 'preload';
373
+ fontLink.as = 'font';
374
+ fontLink.href = '/fonts/Inter-400.woff2';
375
+ fontLink.type = 'font/woff2';
376
+ fontLink.crossOrigin = 'anonymous';
377
+ document.head.appendChild(fontLink);
378
+ ```