Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ function iconfontCSS(config) {
engine,
cssClass;

var availableFormats = ['eot', 'woff2', 'woff', 'ttf', 'svg'];

// Set default values
config = _.merge({
path: 'css',
targetPath: '_icons.css',
fontPath: './',
engine: 'lodash',
formats: availableFormats,
firstGlyph: 0xE001,
fixedCodepoints: false,
cssClass: 'icon'
Expand Down Expand Up @@ -100,13 +103,42 @@ function iconfontCSS(config) {
};

stream._flush = function(cb) {
var content;
var content,
formatTypes = [],
formatModifiers = {
'eot': { extension : "eot?#iefix" },
'ttf': { format : 'truetype' },
'svg': { extension : 'svg#'+config.fontName }
};

config.formats = _.intersection(availableFormats, config.formats);

_.each(config.formats, function(format) {
var ext = formatModifiers[format] && formatModifiers[format]["extension"]
? formatModifiers[format]["extension"]
: format;

var format = formatModifiers[format] && formatModifiers[format]["format"]
? formatModifiers[format]["format"]
: format;

formatTypes.push({
'url': config.fontPath + config.fontName + "." + ext,
'format' : format
});
});

formatTypes = _.map(formatTypes, function(type) {
return "url('"+type.url+"') format('"+type.format+"')"
});

if (glyphMap.length) {
consolidate[config.engine](config.path, {
glyphs: glyphMap,
fontName: config.fontName,
fontPath: config.fontPath,
cssClass: config.cssClass
cssClass: config.cssClass,
formatTypes: formatTypes
}, function(err, html) {
if (err) {
throw new gutil.PluginError(PLUGIN_NAME, 'Error in template: ' + err.message);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "gulp-iconfont-css",
"name": "gulp-iconfont-css-fork",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please correct the name of the package?

"version": "2.1.0",
"description": "Generate (S)CSS file for icon font created with Gulp",
"license": "MIT",
Expand Down
9 changes: 4 additions & 5 deletions templates/_icons.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

@font-face {
font-family: "<%= fontName %>";
src: url('<%= fontPath %><%= fontName %>.eot');
src: url('<%= fontPath %><%= fontName %>.eot?#iefix') format('eot'),
url('<%= fontPath %><%= fontName %>.woff2') format('woff2'),
url('<%= fontPath %><%= fontName %>.woff') format('woff'),
url('<%= fontPath %><%= fontName %>.ttf') format('truetype'),
url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg');
<% if(formatTypes.length) {%>
src: <%= formatTypes.join(", ")%>;
<% } %>
}

.<%= cssClass %>:before {
Expand Down
8 changes: 3 additions & 5 deletions templates/_icons.less
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
@font-face {
font-family: "<%= fontName %>";
src: url('<%= fontPath %><%= fontName %>.eot');
src: url('<%= fontPath %><%= fontName %>.eot?#iefix') format('eot'),
url('<%= fontPath %><%= fontName %>.woff2') format('woff2'),
url('<%= fontPath %><%= fontName %>.woff') format('woff'),
url('<%= fontPath %><%= fontName %>.ttf') format('truetype'),
url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg');
<% if(formatTypes.length) {%>
src: <%= formatTypes.join(", ")%>;
<% } %>
}

.<%= cssClass%>-base-pseudo {
Expand Down
8 changes: 3 additions & 5 deletions templates/_icons.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
@font-face {
font-family: "<%= fontName %>";
src: url('<%= fontPath %><%= fontName %>.eot');
src: url('<%= fontPath %><%= fontName %>.eot?#iefix') format('eot'),
url('<%= fontPath %><%= fontName %>.woff2') format('woff2'),
url('<%= fontPath %><%= fontName %>.woff') format('woff'),
url('<%= fontPath %><%= fontName %>.ttf') format('truetype'),
url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg');
<% if(formatTypes.length) {%>
src: <%= formatTypes.join(", ")%>;
<% } %>
}

@mixin <%= cssClass%>-styles {
Expand Down