Skip to content

Commit

Permalink
Chore: prepare 5.0.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Krasnoyarov committed Oct 24, 2016
1 parent d7307e6 commit cf04d80
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 119 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 5.0.0 - 2016-10-24

- Fixed: wrong `CSS` syntax when not all format are selected.
- Chore(SEMVER-MAJOR): rename extension for all templates from `nunjucks` to `njk`.

# 4.0.1 - 2016-10-19

- Fixed: CLI `fontName` and `formats` arguments bug.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webfont",
"version": "4.0.1",
"version": "5.0.0",
"description": "Generator of webfonts from svg icons, svg icons to svg font, svg font to ttf, ttf to eot, ttf to woff, ttf to woff2",
"license": "MIT",
"author": "itgalaxy <[email protected]>",
Expand Down Expand Up @@ -52,6 +52,7 @@
"globby": "^6.0.0",
"meow": "^3.3.0",
"mkdirp": "^0.5.1",
"merge-deep": "^3.0.0",
"nunjucks": "^2.5.0",
"resolve-from": "2.0.0",
"svg2ttf": "^4.0.0",
Expand Down
22 changes: 22 additions & 0 deletions src/__tests__/standalone-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@ test('should generated only `woff2` font', (t) => {
}).catch(logError);
});

// In future improve css tests on valid based on postcss

test('should generated only `woff and `woff2` fonts with css', (t) => {
t.plan(6);

return standalone({
css: true,
files: `${fixturesPath}/svg-icons/**/*`,
formats: ['woff', 'woff2'],
quite: true
}).then((result) => {
t.true(typeof result.svg === 'undefined');
t.true(typeof result.ttf === 'undefined');
t.true(typeof result.eot === 'undefined');
t.true(isWoff(result.woff));
t.true(isWoff2(result.woff2));
t.true(result.css.length > 0); // eslint-disable-line ava/max-asserts

return result;
}).catch(logError);
});

test('should generated all fonts and css', (t) => {
t.plan(6);

Expand Down
7 changes: 4 additions & 3 deletions src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import defaultMetadataProvider from 'svgicons2svgfont/src/metadata';
import fileSorter from 'svgicons2svgfont/src/filesorter';
import fs from 'fs';
import globby from 'globby';
import merge from 'merge-deep';
import nunjucks from 'nunjucks';
import path from 'path';
import svg2ttf from 'svg2ttf';
Expand Down Expand Up @@ -189,7 +190,7 @@ export default function ({
configFile
})
.then((buildedConfig) => {
const options = Object.assign({}, {
const options = merge({}, {
ascent,
centerHorizontally,
css,
Expand Down Expand Up @@ -264,11 +265,11 @@ export default function ({

options.srcCssTemplate = path.join(
__dirname,
`../templates/template.${options.cssFormat}.nunjucks`
`../templates/template.${options.cssFormat}.njk`
);
}

const nunjucksOptions = Object.assign(
const nunjucksOptions = merge(
{},
{
glyphs
Expand Down
78 changes: 78 additions & 0 deletions templates/template.css.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@font-face {
font-family: {{ fontName }};
{% if formats.indexOf('eot')>-1 -%}
src: url("{{ fontPath }}{{ fontName }}.eot");
{%- endif %}
{%- set eotIndex = formats.indexOf('eot') -%}
{%- set woff2Index = formats.indexOf('woff2') -%}
{%- set woffIndex = formats.indexOf('woff') -%}
{%- set ttfIndex = formats.indexOf('ttf') -%}
{%- set svgIndex = formats.indexOf('svg') %}
src: {% if eotIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.eot?#iefix") format("embedded-opentype")
{%- set nothing = formats.splice(eotIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woff2Index != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff2") format("woff2")
{%- set nothing = formats.splice(woff2Index, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woffIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff") format("woff")
{%- set nothing = formats.splice(woffIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if ttfIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.ttf") format("truetype")
{%- set nothing = formats.splice(ttfIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if svgIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.svg#{{ fontName }}") format("svg");
{%- endif %}
font-style: normal;
font-weight: 400;
}

.{{ className }} {
display: inline-block;
transform: translate(0, 0);
text-rendering: auto;
font: normal normal 400 14px/1 {{ fontName }};
font-size: inherit;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}

.{{ className }}-lg {
vertical-align: -15%;
line-height: 0.75em;
font-size: 1.33333333em;
}

.{{ className }}-2x {
font-size: 2em;
}

.{{ className }}-3x {
font-size: 3em;
}

.{{ className }}-4x {
font-size: 4em;
}

.{{ className }}-5x {
font-size: 5em;
}

.{{ className }}-fw {
width: 1.28571429em;
text-align: center;
}{% for glyph in glyphs
%}

.{{ className }}-{{ glyph.name }}::before {
content: "\{{ glyph.unicode[0].charCodeAt(0).toString(16) }}";
}{% endfor %}
54 changes: 0 additions & 54 deletions templates/template.css.nunjucks

This file was deleted.

85 changes: 85 additions & 0 deletions templates/template.scss.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{% for glyph in glyphs
%}${{ className }}-{{ glyph.name }}: "\{{ glyph.unicode[0].charCodeAt(0).toString(16) }}";
{% endfor %}
@font-face {
font-family: {{ fontName }};
{% if formats.indexOf('eot')>-1 -%}
src: url("{{ fontPath }}{{ fontName }}.eot");
{%- endif -%}
{%- set eotIndex = formats.indexOf('eot') -%}
{%- set woff2Index = formats.indexOf('woff2') -%}
{%- set woffIndex = formats.indexOf('woff') -%}
{%- set ttfIndex = formats.indexOf('ttf') -%}
{%- set svgIndex = formats.indexOf('svg') %}
src: {% if eotIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.eot?#iefix") format("embedded-opentype")
{%- set nothing = formats.splice(eotIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woff2Index != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff2") format("woff2")
{%- set nothing = formats.splice(woff2Index, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woffIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff") format("woff")
{%- set nothing = formats.splice(woffIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if ttfIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.ttf") format("truetype")
{%- set nothing = formats.splice(ttfIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if svgIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.svg#{{ fontName }}") format("svg");
{%- endif %}
font-style: normal;
font-weight: 400;
}

%{{ className }} {
display: inline-block;
transform: translate(0, 0);
text-rendering: auto;
font: normal normal 400 14px/1 {{ fontName }};
font-size: inherit;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}

.{{ className }} {
@extend %{{ className }};
}

.{{ className }}-lg {
vertical-align: -15%;
line-height: 0.75em;
font-size: 1.33333333em;
}

.{{ className }}-2x {
font-size: 2em;
}

.{{ className }}-3x {
font-size: 3em;
}

.{{ className }}-4x {
font-size: 4em;
}

.{{ className }}-5x {
font-size: 5em;
}

.{{ className }}-fw {
width: 1.28571429em;
text-align: center;
}{% for glyph in glyphs
%}

.{{ className }}-{{ glyph.name }}::before {
content: "\{{ glyph.unicode[0].charCodeAt(0).toString(16) }}";
}{% endfor %}
61 changes: 0 additions & 61 deletions templates/template.scss.nunjucks

This file was deleted.

0 comments on commit cf04d80

Please sign in to comment.