@@ -128,3 +128,38 @@ describe("bundled Latin precedence", () => {
128128 expect ( bundled ) . toContain ( `unicode-range: ${ LATIN_RANGE } ;` ) ;
129129 } ) ;
130130} ) ;
131+
132+ describe ( "variable supplement at bundled weights" , ( ) => {
133+ it ( "also emits a variable face's Latin Extended subset at each bundled weight it spans" , async ( ) => {
134+ const { injectDeterministicFontFaces } = await import ( "./deterministicFonts.js" ) ;
135+ const EXT = "U+0100-02BA, U+02BD-02C5, U+1E00-1EFF" ;
136+ const fetchImpl = ( async ( input : unknown ) => {
137+ const url = String ( input ) ;
138+ if ( url . startsWith ( "https://fonts.googleapis.com/" ) ) {
139+ return new Response ( `@font-face {
140+ font-family: 'Outfit'; font-style: normal; font-weight: 100 900;
141+ src: url(https://fonts.gstatic.com/s/outfit/ext.woff2) format('woff2');
142+ unicode-range: ${ EXT } ;
143+ }` ) ;
144+ }
145+ return new Response ( "OUTFIT_LATIN_EXT_BYTES" ) ;
146+ } ) as unknown as typeof fetch ;
147+ const html = `<!doctype html><html><head><style>p{font-family:"Outfit";font-weight:700}</style></head><body><p>čšćžđ ąęłńśźż řěůď ğışİ őű ășț ạảấ</p></body></html>` ;
148+ const result = await injectDeterministicFontFaces ( html , {
149+ fetchImpl,
150+ allowSystemFontCapture : false ,
151+ } ) ;
152+ const faces = ( result . match ( / @ f o n t - f a c e \{ [ \s \S ] * ?\} / g) ?? [ ] ) . filter ( ( face ) =>
153+ face . includes ( b64 ( "OUTFIT_LATIN_EXT_BYTES" ) ) ,
154+ ) ;
155+ const weights = faces . map ( ( face ) => / f o n t - w e i g h t : ( [ \d ] + ) ; / . exec ( face ) ?. [ 1 ] ) ;
156+ expect ( weights ) . toEqual ( expect . arrayContaining ( [ "400" , "700" , "900" , "100 900" ] ) ) ;
157+ for ( const face of faces ) expect ( face ) . toContain ( `unicode-range: ${ EXT } ;` ) ;
158+ // Croatian, Polish, Czech, Turkish, Hungarian, Romanian and Vietnamese letters beyond Latin-1 are all in its range.
159+ const inExt = ( ch : string ) => {
160+ const cp = ch . codePointAt ( 0 ) ?? 0 ;
161+ return ( cp >= 0x100 && cp <= 0x2ba ) || ( cp >= 0x1e00 && cp <= 0x1eff ) ;
162+ } ;
163+ for ( const ch of "čšćžđąęłńśźżřěůďğışİőűășțạảấ" ) expect ( inExt ( ch ) ) . toBe ( true ) ;
164+ } ) ;
165+ } ) ;
0 commit comments