51
51
// font:
52
52
// meta:
53
53
//
54
-
55
-
56
54
'use strict' ;
57
55
58
56
59
- var _ = require ( 'lodash' ) ;
60
- var svgpath = require ( 'svgpath' ) ;
57
+ const _ = require ( 'lodash' ) ;
58
+ const svgpath = require ( 'svgpath' ) ;
59
+ const fontConfigs = require ( '../../../../lib/embedded_fonts/server_config' ) ;
61
60
62
61
63
- var fontConfigs = require ( '../../../../lib/embedded_fonts/server_config' ) ;
64
-
65
62
function collectGlyphsInfo ( clientConfig ) {
66
- var result = [ ] ;
67
- var scale = clientConfig . units_per_em / 1000 ;
63
+ let result = [ ] ;
64
+ let scale = clientConfig . units_per_em / 1000 ;
68
65
69
- _ . forEach ( clientConfig . glyphs , function ( glyph ) {
70
- var sp ;
66
+ _ . forEach ( clientConfig . glyphs , glyph => {
67
+ let sp ;
71
68
72
69
if ( glyph . src === 'custom_icons' ) {
73
70
74
71
// for custom glyphs use only selected ones
75
- if ( ! glyph . selected ) { return ; }
72
+ if ( ! glyph . selected ) return ;
76
73
77
74
sp = svgpath ( glyph . svg . path )
78
75
. scale ( scale , - scale )
@@ -93,8 +90,9 @@ function collectGlyphsInfo(clientConfig) {
93
90
94
91
// For exmbedded fonts take pregenerated info
95
92
96
- var glyphEmbedded = fontConfigs . uids [ glyph . uid ] ;
97
- if ( ! glyphEmbedded ) { return ; }
93
+ let glyphEmbedded = fontConfigs . uids [ glyph . uid ] ;
94
+
95
+ if ( ! glyphEmbedded ) return ;
98
96
99
97
sp = svgpath ( glyphEmbedded . svg . d )
100
98
. scale ( scale , - scale )
@@ -115,32 +113,31 @@ function collectGlyphsInfo(clientConfig) {
115
113
} ) ;
116
114
117
115
// Sort result by original codes.
118
- result . sort ( function ( a , b ) { return a . code - b . code ; } ) ;
116
+ result . sort ( ( a , b ) => a . code - b . code ) ;
119
117
120
118
return result ;
121
119
}
122
120
123
121
// collect fonts metadata required to build license info
124
122
125
123
function collectFontsInfo ( glyphs ) {
126
- var result = [ ] ;
124
+ let result = [ ] ;
127
125
128
- _ ( glyphs ) . map ( 'src' ) . uniq ( ) . forEach ( function ( fontname ) {
129
- var font = fontConfigs . fonts [ fontname ] ;
130
- var meta = fontConfigs . metas [ fontname ] ;
126
+ _ ( glyphs ) . map ( 'src' ) . uniq ( ) . forEach ( fontname => {
127
+ let font = fontConfigs . fonts [ fontname ] ;
128
+ let meta = fontConfigs . metas [ fontname ] ;
131
129
132
130
if ( font && meta ) {
133
131
result . push ( { font, meta } ) ;
134
132
}
135
-
136
133
} ) ;
134
+
137
135
return result ;
138
136
}
139
137
140
138
141
139
module . exports = function fontConfig ( clientConfig ) {
142
-
143
- var fontname , glyphsInfo , fontsInfo ;
140
+ let fontname , glyphsInfo , fontsInfo ;
144
141
145
142
//
146
143
// Patch broken data to fix original config
@@ -172,11 +169,9 @@ module.exports = function fontConfig(clientConfig) {
172
169
glyphsInfo = collectGlyphsInfo ( clientConfig ) ;
173
170
fontsInfo = collectFontsInfo ( glyphsInfo ) ;
174
171
175
- if ( _ . isEmpty ( glyphsInfo ) ) {
176
- return null ;
177
- }
172
+ if ( _ . isEmpty ( glyphsInfo ) ) return null ;
178
173
179
- var defaultCopyright = 'Copyright (C) ' + new Date ( ) . getFullYear ( ) + ' by original authors @ fontello.com' ;
174
+ let defaultCopyright = 'Copyright (C) ' + new Date ( ) . getFullYear ( ) + ' by original authors @ fontello.com' ;
180
175
181
176
return {
182
177
font : {
0 commit comments