File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -114,18 +114,24 @@ interface FontFace {
114114}
115115
116116function extractFontFaces ( css : string , name : string ) : FontFace [ ] {
117- const fontFaces = css . match ( / \/ \* [ ^ * ] + \* \/ [ \s ] + @ f o n t - f a c e { [ ^ } ] + } / g) || [ ] ;
117+ const fontFaces = css . match ( / ( \/ \* [ ^ * ] + \* \/ ) ? [ \s ] + @ f o n t - f a c e { [ ^ } ] + } / g) || [ ] ;
118118
119+ let unnamedSubsetId = 1 ;
119120 return fontFaces . map ( ( fontFace ) => {
120- const subset = fontFace . match ( / \/ \* ( [ ^ * ] + ) \* \/ / ) ?. [ 1 ] ;
121+ let subset = fontFace . match ( / \/ \* ( [ ^ * ] + ) \* \/ / ) ?. [ 1 ] ;
121122 let family = fontFace . match ( / f o n t - f a m i l y : ' ( [ ^ ' ] + ) ' / ) ?. [ 1 ] ;
122123 const style = fontFace . match ( / f o n t - s t y l e : ( [ ^ ; ] + ) ; / ) ?. [ 1 ] ;
123124 const weight = fontFace . match ( / f o n t - w e i g h t : ( [ ^ ; ] + ) ; / ) ?. [ 1 ] ;
124125 const stretch = fontFace . match ( / f o n t - s t r e t c h : ( [ ^ ; ] + ) ; / ) ?. [ 1 ] ;
125126 const src = fontFace . match ( / s r c : u r l \( ' ? ( [ ^ ' ] + ) ' ? \) / ) ?. [ 1 ] ;
126127 const range = fontFace . match ( / u n i c o d e - r a n g e : ( [ ^ ; ] + ) ; / ) ?. [ 1 ] ;
127128
128- if ( ! family || ! style || ! weight || ! src || ! range || ! subset ) {
129+ if ( ! subset ) {
130+ subset = `[${ unnamedSubsetId } ]` ;
131+ unnamedSubsetId ++ ;
132+ }
133+
134+ if ( ! family || ! style || ! weight || ! src || ! range ) {
129135 throw new Error ( "Invalid font-face" ) ;
130136 }
131137
You can’t perform that action at this time.
0 commit comments