@@ -22,6 +22,8 @@ interface FontaineTransformOptions {
22
22
sourcemap ?: boolean
23
23
}
24
24
25
+ const supportedExtensions = [ 'woff2' , 'woff' , 'ttf' ]
26
+
25
27
export const FontaineTransform = createUnplugin (
26
28
( options : FontaineTransformOptions ) => {
27
29
const cssContext = ( options . css = options . css || { } )
@@ -54,20 +56,23 @@ export const FontaineTransform = createUnplugin(
54
56
55
57
faceRanges . push ( [ match . index , match . index + matchContent . length ] )
56
58
57
- const { family, source } = parseFontFace ( matchContent )
58
- if ( ! family ) continue
59
-
60
- const metrics =
61
- ( await getMetricsForFamily ( family ) ) ||
62
- ( source && ( await readMetricsFromId ( source , id ) . catch ( ( ) => null ) ) )
63
-
64
- if ( metrics ) {
65
- const fontFace = generateFontFace ( metrics , {
66
- name : overrideName ( family ) ,
67
- fallbacks : options . fallbacks ,
68
- } )
69
- cssContext . value += fontFace
70
- s . appendLeft ( match . index , fontFace )
59
+ for ( const { family, source } of parseFontFace ( matchContent ) ) {
60
+ if ( ! family ) continue
61
+ if ( ! supportedExtensions . some ( e => source ?. endsWith ( e ) ) ) continue
62
+
63
+ const metrics =
64
+ ( await getMetricsForFamily ( family ) ) ||
65
+ ( source &&
66
+ ( await readMetricsFromId ( source , id ) . catch ( ( ) => null ) ) )
67
+
68
+ if ( metrics ) {
69
+ const fontFace = generateFontFace ( metrics , {
70
+ name : overrideName ( family ) ,
71
+ fallbacks : options . fallbacks ,
72
+ } )
73
+ cssContext . value += fontFace
74
+ s . appendLeft ( match . index , fontFace )
75
+ }
71
76
}
72
77
}
73
78
0 commit comments