@@ -175,7 +175,10 @@ function probeWidth(fontList: string): number | null {
175175 */
176176export function isFontFamilyAvailable ( family : string ) : boolean {
177177 const families = cssFontFamilies ( family ) ;
178- if ( families === null ) return false ;
178+ return families !== null && familiesResolve ( families ) ;
179+ }
180+
181+ function familiesResolve ( families : string ) : boolean {
179182 if ( / ^ ( s y s t e m - u i | s a n s - s e r i f | s e r i f | m o n o s p a c e | u i - m o n o s p a c e ) $ / i. test ( families ) ) return true ;
180183 try {
181184 for ( const generic of [ "monospace" , "serif" , "sans-serif" ] ) {
@@ -208,13 +211,16 @@ export function areFontAdvancesMonospace(advances: readonly number[]): boolean {
208211
209212/**
210213 * Probing a family is up to 32 measureText calls, and setting the canvas font
211- * to a new family string forces engine font matching on top. Verdicts cannot
212- * change while the page lives (the installed font list is itself cached for
213- * the session), so both passes and failures are kept, keyed by the normalized
214- * family list.
214+ * to a new family string forces engine font matching on top, so verdicts are
215+ * kept keyed by the normalized family list. A failure always names a resolved
216+ * face and is final. A pass may be the generic fallback speaking for a face
217+ * that has not loaded yet, so it is only kept once the family resolves;
218+ * until then every call probes again, which is what lets the terminal
219+ * revalidate after a late face loads and still reject a proportional one.
215220 */
216221export function createCachedFamilyProbe (
217222 probe : ( families : string ) => boolean ,
223+ resolves : ( families : string ) => boolean ,
218224) : ( family : string ) => boolean {
219225 const verdicts = new Map < string , boolean > ( ) ;
220226 return ( family ) => {
@@ -223,7 +229,7 @@ export function createCachedFamilyProbe(
223229 const cached = verdicts . get ( families ) ;
224230 if ( cached !== undefined ) return cached ;
225231 const verdict = probe ( families ) ;
226- verdicts . set ( families , verdict ) ;
232+ if ( ! verdict || resolves ( families ) ) verdicts . set ( families , verdict ) ;
227233 return verdict ;
228234 } ;
229235}
@@ -257,7 +263,7 @@ function measureMonospaceFamilies(families: string): boolean {
257263 * Unmeasurable environments answer true, so a missing canvas never blocks a
258264 * legitimate font.
259265 */
260- export const isMonospaceFamily = createCachedFamilyProbe ( measureMonospaceFamilies ) ;
266+ export const isMonospaceFamily = createCachedFamilyProbe ( measureMonospaceFamilies , familiesResolve ) ;
261267
262268// Nameable faces the platform generics commonly map to, likeliest first.
263269// Pixel-comparing a generic against these names the actual face; Apple's own
0 commit comments