File tree Expand file tree Collapse file tree 1 file changed +57
-1
lines changed Expand file tree Collapse file tree 1 file changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -429,6 +429,61 @@ module.exports = function(css, options){
429
429
rules : style
430
430
} ) ;
431
431
}
432
+
433
+ /**
434
+ * Parse font-face.
435
+ */
436
+
437
+ function atfontface ( ) {
438
+ var pos = position ( ) ;
439
+ var m = match ( / ^ @ f o n t - f a c e * / ) ;
440
+ var re = / u r l \( [ ' " ] ( [ ^ ' " ] + ) [ ' " ] \) \s * (?: f o r m a t \( [ ' " ] ( [ ^ ' " ] + ) [ ' " ] \) ) ? / i;
441
+ var src = [ ] ;
442
+ var decls = [ ] ;
443
+ var srcList ;
444
+
445
+ if ( ! m ) return ;
446
+
447
+ if ( ! open ( ) ) return error ( "@font-face missing '{'" ) ;
448
+
449
+ var name = match ( / ^ f o n t - f a m i l y \s * : \s * [ ' " ] ( [ ^ ' " ] + ) [ ' " ] ; / ) ;
450
+
451
+ if ( ! name ) return error ( "@font-face missing 'font-family'" ) ;
452
+ decls . push ( {
453
+ type : 'declaration' ,
454
+ property : 'font-family' ,
455
+ value : trim ( name [ 1 ] )
456
+ } )
457
+ whitespace ( ) ;
458
+
459
+ while ( srcList = match ( / ^ s r c \s * : \s * ( [ ^ ; ] + ) ; / ) ) {
460
+ var val = trim ( srcList [ 1 ] ) ;
461
+ var set = val . split ( ',' ) ;
462
+
463
+ decls . push ( {
464
+ type : 'declaration' ,
465
+ property : 'src' ,
466
+ value : val
467
+ } ) ;
468
+
469
+ set . forEach ( function ( item ) {
470
+ m = re . exec ( item ) ;
471
+ src . push ( {
472
+ url : trim ( m [ 1 ] ) ,
473
+ format : trim ( m [ 2 ] )
474
+ } ) ;
475
+ } )
476
+ whitespace ( ) ;
477
+ }
478
+
479
+ if ( ! close ( ) ) return error ( "@font-face missing '}'" ) ;
480
+
481
+ return pos ( {
482
+ type : 'fontface' ,
483
+ src : src ,
484
+ declarations : decls
485
+ } ) ;
486
+ }
432
487
433
488
/**
434
489
* Parse import
@@ -480,7 +535,8 @@ module.exports = function(css, options){
480
535
|| atnamespace ( )
481
536
|| atdocument ( )
482
537
|| atpage ( )
483
- || athost ( ) ;
538
+ || athost ( )
539
+ || atfontface ( ) ;
484
540
}
485
541
486
542
/**
You can’t perform that action at this time.
0 commit comments