@@ -279,24 +279,23 @@ function maskParens(value: string): string {
279279 } ) ;
280280}
281281
282+ function fontSizeKind ( token : string , masked : string ) : "literal" | "function" | null {
283+ const size = token . split ( "/" ) [ 0 ] ?? "" ;
284+ if ( FONT_SIZE_KEYWORD . test ( size ) || FONT_SIZE_LENGTH . test ( token ) ) return "literal" ;
285+ if ( ! FONT_SIZE_FUNCTION . test ( token ) ) return null ;
286+ return masked . includes ( "/" ) ? "literal" : "function" ;
287+ }
288+
282289function fontShorthandFamilies ( value : string ) : string {
283- let functionSizeEnd = - 1 ;
290+ let firstFunctionSizeEnd = - 1 ;
284291 for ( const { 0 : masked , index } of maskParens ( value ) . matchAll ( / \S + / g) ) {
285292 const end = index + masked . length ;
286- const token = value . slice ( index , end ) ;
287- const size = token . split ( "/" ) [ 0 ] ?? "" ;
288- const isFunction = FONT_SIZE_FUNCTION . test ( token ) ;
289- if (
290- FONT_SIZE_KEYWORD . test ( size ) ||
291- FONT_SIZE_LENGTH . test ( token ) ||
292- ( isFunction && masked . includes ( "/" ) )
293- ) {
294- return value . slice ( end ) . trim ( ) ;
295- }
296- if ( isFunction && functionSizeEnd < 0 ) functionSizeEnd = end ;
293+ const kind = fontSizeKind ( value . slice ( index , end ) , masked ) ;
294+ if ( kind === "literal" ) return value . slice ( end ) . trim ( ) ;
295+ if ( kind === "function" && firstFunctionSizeEnd < 0 ) firstFunctionSizeEnd = end ;
297296 }
298297 // A var() can hold the style or weight, so it is the size only when no literal size follows.
299- return functionSizeEnd < 0 ? "" : value . slice ( functionSizeEnd ) . trim ( ) ;
298+ return firstFunctionSizeEnd < 0 ? "" : value . slice ( firstFunctionSizeEnd ) . trim ( ) ;
300299}
301300
302301function * iterateCssRootFontFamilyDeclarations (
@@ -1016,8 +1015,7 @@ function findDeclaredFamilyAlias(
10161015 return match ;
10171016}
10181017
1019- // Design exports name a family by class, `font-<Family>-<weight>`; serve <Family> under that name.
1020- // ponytail: every face is emitted, so the element's own font-weight still picks the face.
1018+ // Design exports name a family by class, `font-<Family>-<weight>`; serve all <Family> faces under that name.
10211019const WEIGHTED_CLASS_FAMILY = / ^ f o n t - ( .+ ) - [ 1 - 9 ] 0 0 $ / i;
10221020
10231021async function resolveWeightedClassFamily (
0 commit comments