Skip to content

Commit

Permalink
Chore: prepare 6.0.2 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Krasnoyarov committed Nov 7, 2016
1 parent eeaaf30 commit 1a72f38
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 44 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Head
# 6.0.2 - 2016-11-07

- Fixed: use `reject` instead `Promise.reject` in glyphs `error` callback.
- Fixed: use callback `finish` instead `end` for `svgicons2svgfont` stream.
- Tests: improve tests on bad examples.

# 6.0.1 - 2016-11-07
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webfont",
"version": "6.0.1",
"version": "6.0.2",
"description": "Generator of fonts 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
79 changes: 37 additions & 42 deletions src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@ import ttf2woff from 'ttf2woff';
import ttf2woff2 from 'ttf2woff2';

function svgIcons2svgFontFn(files, options, glyphs = []) {
const fontStream = svgicons2svgfont({
ascent: options.ascent,
centerHorizontally: options.centerHorizontally,
descent: options.descent,
fixedWidth: options.fixedWidth,
fontHeight: options.fontHeight,
fontId: options.fontId,
fontName: options.fontName,
fontStyle: options.fontStyle,
fontWeight: options.fontWeight,
log: options.log,
metadata: options.metadata,
normalize: options.normalize,
round: options.round
});

const metadataProvider = options.metadataProvider || defaultMetadataProvider({
prependUnicode: options.prependUnicode,
startUnicode: options.startUnicode
Expand All @@ -41,39 +25,50 @@ function svgIcons2svgFontFn(files, options, glyphs = []) {
};

return Promise.all(
sortedFiles.map(
(srcPath) => new Promise((resolve, reject) => {
metadataProvider(srcPath, (error, metadata) => {
if (error) {
return reject(error);
}
sortedFiles.map((srcPath) => new Promise((resolve, reject) => {
metadataProvider(srcPath, (error, metadata) => {
if (error) {
return reject(error);
}

const glyph = fs.createReadStream(srcPath);
const glyph = fs.createReadStream(srcPath);

glyph.on('error', (glyphError) => reject(glyphError));
glyph.on('error', (glyphError) => reject(glyphError));

glyph.metadata = metadata;
fontStream.write(glyph);
glyph.metadata = metadata;

glyphs.push(metadata);
glyphs.push(metadata);

return resolve(glyph);
});
})
)
return resolve(glyph);
});
}))
)
.then(() => {
fontStream.end();
.then((emmitGlyphs) => new Promise((resolve, reject) => {
const fontStream = svgicons2svgfont({
ascent: options.ascent,
centerHorizontally: options.centerHorizontally,
descent: options.descent,
fixedWidth: options.fixedWidth,
fontHeight: options.fontHeight,
fontId: options.fontId,
fontName: options.fontName,
fontStyle: options.fontStyle,
fontWeight: options.fontWeight,
log: options.log,
metadata: options.metadata,
normalize: options.normalize,
round: options.round
})
.on('finish', () => resolve(result))
.on('data', (data) => {
result.svg += data;
})
.on('error', (error) => reject(error));

return new Promise((resolve, reject) => {
fontStream
.on('error', (error) => reject(error))
.on('data', (data) => {
result.svg += data;
})
.on('end', () => resolve(result));
});
});
emmitGlyphs.forEach((emmitGlyph) => fontStream.write(emmitGlyph));

fontStream.end();
}));
}

function svg2ttfFn(result, options) {
Expand Down

0 comments on commit 1a72f38

Please sign in to comment.