@@ -20,17 +20,15 @@ function getUnresolvedIconPath (value) {
2020function parseFontIconValue ( value ) {
2121 const valueParts = value . trim ( ) . split ( ' ' ) ;
2222 const result = { } ;
23- // Just a url
24- // font-icon: url('./demo.svg');
25- if ( valueParts . length === 1 ) {
26- result . url = getUnresolvedIconPath ( valueParts [ 0 ] ) ;
27- }
28- // Font size and url
23+ // Parse font size and url
2924 // font-icon: 20px url('./demo.svg');
3025 if ( valueParts . length === 2 ) {
3126 result . size = valueParts [ 0 ] ;
32- result . url = getUnresolvedIconPath ( valueParts [ 1 ] ) ;
3327 }
28+ // The url is always the last part
29+ // font-icon: url('./demo.svg');
30+ // font-icon: 20px url('./demo.svg);
31+ result . url = getUnresolvedIconPath ( valueParts [ valueParts . length - 1 ] ) ;
3432 return result ;
3533}
3634
@@ -45,7 +43,7 @@ function getSvgPaths (postCssRoot, webpackResolve, context) {
4543 // Gather all font-icon urls:
4644 let unresolvedPaths = [ ] ;
4745 postCssRoot . walkDecls ( ( decl ) => {
48- if ( decl . prop === 'font-icon' ) {
46+ if ( decl . prop === 'font-icon' || decl . prop === 'font-icon-glyph' ) {
4947 const fontIcon = parseFontIconValue ( decl . value ) ;
5048 unresolvedPaths . push ( fontIcon . url ) ;
5149 }
@@ -83,21 +81,29 @@ function getSvgPaths (postCssRoot, webpackResolve, context) {
8381 */
8482function replaceIconFontDeclarations ( fontName , postCssRoot , svgPaths ) {
8583 postCssRoot . walkDecls ( ( decl ) => {
84+ // Add font icon styles
85+ // + text-rendering
86+ // + -webkit-font-smoothing
8687 if ( decl . prop === 'font-icon' ) {
87- const fontIcon = parseFontIconValue ( decl . value ) ;
88- // Add the font name
88+ // Add font smoothing
89+ // Similar to font Awesome
90+ // https://github.com/FortAwesome/Font-Awesome/blob/31281606f5205b0191c17c3b4d2d56e1ddbb2dc6/web-fonts-with-css/css/fontawesome-all.css#L10-L15
8991 decl . cloneBefore ( {
9092 prop : 'text-rendering' ,
9193 value : 'auto'
9294 } ) ;
9395 decl . cloneBefore ( {
9496 prop : '-webkit-font-smoothing' ,
95- value : 'auto '
97+ value : 'antialiased '
9698 } ) ;
9799 decl . cloneBefore ( {
98100 prop : '-moz-osx-font-smoothing' ,
99- value : 'auto '
101+ value : 'grayscale '
100102 } ) ;
103+ }
104+ // set content property
105+ if ( decl . prop === 'font-icon' || decl . prop === 'font-icon-glyph' ) {
106+ const fontIcon = parseFontIconValue ( decl . value ) ;
101107 // If a font size is set we can use the font shorthand
102108 if ( fontIcon . size ) {
103109 decl . cloneBefore ( {
0 commit comments