Last active
August 29, 2015 14:11
-
-
Save crecotun/2ce192cb6dc54dda88bb to your computer and use it in GitHub Desktop.
iconfont example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate iconfont from svgs | |
gulp.task 'common:iconfont', -> | |
gulp.src config.paths.src.common.svg.icons.all | |
.pipe g.iconfont | |
fontName: "icons" | |
appendCodepoints: true | |
normalize: true | |
.on 'codepoints', (codepoints) => | |
codepoints.forEach (glyph, idx, arr) -> | |
arr[idx].codepoint = glyph.codepoint.toString(16) | |
gulp.src config.paths.src.common.framework.icons.template.path | |
.pipe g.consolidate 'lodash', | |
glyphs: codepoints | |
fontName: 'iconfont' | |
fontPath: config.paths.built.common.fonts.icons.path | |
.pipe gulp.dest config.paths.src.common.framework.icons.path | |
.pipe gulp.dest config.paths.built.common.fonts.icons.path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('common:iconfont', function() { | |
return gulp.src(config.paths.src.common.svg.icons.all).pipe(g.iconfont({ | |
fontName: "icons", | |
appendCodepoints: true, | |
normalize: true | |
})).on('codepoints', (function(_this) { | |
return function(codepoints) { | |
codepoints.forEach(function(glyph, idx, arr) { | |
return arr[idx].codepoint = glyph.codepoint.toString(16); | |
}); | |
return gulp.src(config.paths.src.common.framework.icons.template.path).pipe(g.consolidate('lodash', { | |
glyphs: codepoints, | |
fontName: 'iconfont', | |
fontPath: config.paths.built.common.fonts.icons.path | |
})).pipe(gulp.dest(config.paths.src.common.framework.icons.path)); | |
}; | |
})(this)).pipe(gulp.dest(config.paths.built.common.fonts.icons.path)); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% _.each(glyphs, function(glyph) { | |
%>$i-<%= glyph.name %>= "\<%= glyph.codepoint %>" | |
<% }); %> | |
icon($icon) | |
font-family "<%= fontName %>" | |
-webkit-font-smoothing antialiased | |
-moz-osx-font-smoothing grayscale | |
font-style normal | |
font-variant normal | |
font-weight normal | |
speak none | |
text-decoration none | |
text-transform none | |
content $icon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment