Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

execMaxBuffer option for setting child_process.exec() maxBuffer #320

Merged
merged 2 commits into from
Feb 29, 2016
Merged
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
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ Each entry in `customOutputs` should be an object with the following parameters:

At compile-time each template will have access to the same context as the compile-time environment of `htmlDemoTemplate` (as extended by the `context` object, if provided. See config-example below.

#### execMaxBuffer
If you get stderr maxBuffer exceeded warning message, engine probably logged a lot of warning messages. To see this warnings run grunt in verbose mode `grunt --verbose`. To go over this warning you can try to increase buffer size by this option. Default value is `1024 * 200`

### Config Examples

#### Simple font generation
Expand Down Expand Up @@ -623,6 +626,7 @@ Check the following...
* Your paths are clockwise. Anti-clockwise paths may cause fills to occur differently.
* Your paths are not overlapping. Overlapping paths will cause one of the areas to be inverted rather than combined. Use an editor to union your two paths together.
* `autoHint` also adjusts the font file and can cause your font to look different to the SVG, so you could try switching it off (though it may make windows view of the font worse).
* If you get stderr maxBuffer exceeded warning message, fontforge probably logged a lot of warning messages. To see this warnings run grunt in verbose mode `grunt --verbose`. To go over this warning you can try to increase buffer size by [execMaxBuffer](#execMaxBuffer).

## Changelog

Expand Down
21 changes: 20 additions & 1 deletion tasks/engines/fontforge.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function(o, allDone) {
path.join(__dirname, 'fontforge/generate.py')
].join(' ');

var proc = exec(args, function(err, out, code) {
var proc = exec(args, {maxBuffer: o.execMaxBuffer}, function(err, out, code) {
if (err instanceof Error && err.code === 127) {
return fontforgeNotFound();
}
Expand Down Expand Up @@ -92,6 +92,25 @@ module.exports = function(o, allDone) {
fontforgeNotFound();
}
});

proc.stderr.on('data', function (data) {
logger.verbose(data);
});
proc.stdout.on('data', function (data) {
logger.verbose(data);
});
proc.on('exit', function (code, signal) {
if (code !== 0) {
logger.log( // cannot use error() because it will stop execution of callback of exec (which shows error message)
"fontforge process has unexpectedly closed.\n" +
"1. Try to run grunt in verbose mode to see fontforge output: " + chalk.bold('grunt --verbose webfont') + ".\n" +
"2. If stderr maxBuffer exceeded try to increase " + chalk.bold('execMaxBuffer') + ", see " +
chalk.underline('https://github.com/sapegin/grunt-webfont#execMaxBuffer') + ". "
);
}
return true;
});

var params = _.extend(o, {
inputDir: tempDir
});
Expand Down
2 changes: 1 addition & 1 deletion tasks/engines/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ module.exports = function(o, allDone) {
hintedFilepath
].join(' ');

exec(args, function(err, out, code) {
exec(args, {maxBuffer: o.execMaxBuffer}, function(err, out, code) {
if (err) {
if (err.code === 127) {
logger.verbose('Hinting skipped, ttfautohint not found.');
Expand Down
3 changes: 2 additions & 1 deletion tasks/webfont.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ module.exports = function(grunt) {
descent: options.descent !== undefined ? options.descent : 64,
cache: options.cache || path.join(__dirname, '..', '.cache'),
callback: options.callback,
customOutputs: options.customOutputs
customOutputs: options.customOutputs,
execMaxBuffer: options.execMaxBuffer || 1024 * 200
};

o = _.extend(o, {
Expand Down