Skip to content

Instantly share code, notes, and snippets.

@crecotun
Last active August 29, 2015 14:11

Revisions

  1. Krekotun revised this gist Dec 9, 2014. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions template.styl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <% _.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
  2. Krekotun created this gist Dec 9, 2014.
    17 changes: 17 additions & 0 deletions .coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # 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
    18 changes: 18 additions & 0 deletions .js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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));
    });