File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ interface FontIndexMeta {
33
33
width : number | null
34
34
lineHeight : number | null
35
35
} >
36
+ axes : Array < {
37
+ tag : string
38
+ min : number
39
+ max : number
40
+ defaultValue : number
41
+ } >
36
42
}
37
43
38
44
/** internal */
@@ -57,16 +63,19 @@ function isGoogleFont (family: string) {
57
63
return fonts . some ( font => font . family === family )
58
64
}
59
65
66
+ const styleMap = {
67
+ italic : '1' ,
68
+ oblique : '1' ,
69
+ normal : '0'
70
+ }
60
71
async function getFontDetails ( family : string , variants : ResolveFontFacesOptions ) {
61
72
const font = fonts . find ( font => font . family === family ) !
62
- const weights = variants . weights . filter ( weight => String ( weight ) in font . fonts )
63
- const styleMap = {
64
- italic : '1' ,
65
- oblique : '1' ,
66
- normal : '0'
67
- }
73
+ const styles = [ ...new Set ( variants . styles . map ( i => styleMap [ i ] ) ) ] . sort ( )
68
74
69
- const styles = new Set ( variants . styles . map ( i => styleMap [ i ] ) )
75
+ const variableWeight = font . axes . find ( a => a . tag === 'wght' )
76
+ const weights = variableWeight
77
+ ? [ `${ variableWeight . min } ..${ variableWeight . max } ` ]
78
+ : variants . weights . filter ( weight => String ( weight ) in font . fonts )
70
79
const resolvedVariants = weights . flatMap ( w => [ ...styles ] . map ( s => `${ s } ,${ w } ` ) )
71
80
72
81
let css = ''
You can’t perform that action at this time.
0 commit comments