perrin4869 / gulp-fontgen

Generator of browser fonts and css from ttf or otf files
MIT License
23 stars 10 forks source link

FontForge child_process throw err; #11

Closed CameronCarranza closed 8 years ago

CameronCarranza commented 8 years ago

Hello all,

Running into a bit of an issue whenever I use a .json file with the same name as the font in order to get the font names.

First of all, not sure if this is default behavior but without a JSON file font-family, weight, and style all output as false in the css. This includes the test folder in node_modules for this project. Not sure if it's supposed to fetch the fonts properties or just set them all to false. Would be fantastic if it fetched them and my system is just being troublesome.

My issue appears to have something to do with having a space in any of the JSON values. I am using the example from the fontfacegen page:

{
    "name"   : "Super Sans",
    "weight" : "400",
    "style"  : "normal"
}

This example causes FontForge to error out. However, if I change Super Sans to SuperSans it executes and all of the values are filled in the CSS.


Here's the error I get when there's a space in the JSON file:

[16:18:51] Starting 'fontgen'...
child_process.js:484
    throw err;
    ^

Error: Command failed: /usr/local/bin/fontforge -lang=ff -c 'Open($1);SetFontNames($3,$3,$3);Generate($2, "", 8);' '/Users/cameron/Desktop/wordpress/theme_files/src/fonts/test.otf' 'static/fonts/test/test.ttf' 'Super Sans' 2> /dev/null

    at checkExecSyncError (child_process.js:441:13)
    at Object.execSync (child_process.js:481:13)
    at fontforge (/Users/cameron/Desktop/wordpress/theme_files/node_modules/gulp-fontgen/node_modules/fontfacegen/fontfacegen.js:281:20)
    at generateTtf (/Users/cameron/Desktop/wordpress/theme_files/node_modules/gulp-fontgen/node_modules/fontfacegen/fontfacegen.js:134:12)
    at generateFontFace (/Users/cameron/Desktop/wordpress/theme_files/node_modules/gulp-fontgen/node_modules/fontfacegen/fontfacegen.js:49:5)
    at DestroyableTransform._transform (/Users/cameron/Desktop/wordpress/theme_files/node_modules/gulp-fontgen/gulp-fontgen.js:32:5)
    at DestroyableTransform.Transform._read (/Users/cameron/Desktop/wordpress/theme_files/node_modules/gulp-fontgen/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:10)
    at DestroyableTransform.Transform._write (/Users/cameron/Desktop/wordpress/theme_files/node_modules/gulp-fontgen/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:160:12)
    at doWrite (/Users/cameron/Desktop/wordpress/theme_files/node_modules/gulp-fontgen/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:335:12)
    at writeOrBuffer (/Users/cameron/Desktop/wordpress/theme_files/node_modules/gulp-fontgen/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:321:5)

Edit, Here's my Gulp task as well:

Variables:

gconf.paths.fonts_folder is equal to src/fonts/

Gulp Task:

gulp.task('fontgen', function() {

    var successTitle = 'Font generation success';
    var successMessage = '\nFonts in ' + gconf.paths.fonts_folder + ' generated\n' +
                         'Output: ./static/fonts/';

    return gulp.src(gconf.paths.fonts_folder + '*.{ttf,otf}')
        .pipe(fontgen({
            collate: true,
            css_fontpath: 'static/fonts/',
            dest: './static/fonts/'
        }))
        .pipe(pipeErrorStop({ errorCallback: function(err) {
            notifier.notify({ title: 'Font compile Error', message: err.message })
        } }))
        .pipe(cached('fontgen'))
        .pipe(notify ({ title: successTitle, message: successMessage }));
});
sgen commented 8 years ago

I believe this was fixed in 0.1.7 or 0.1.8.

kohmaeda commented 7 years ago

Hi. I'm still getting an error like this when my font names have spaces in the JSON:

/home/rangi/(snip)/node_modules/fontfacegen/lib/fontforge.js:46
        throw new FontForgeException(e, cmd)
        ^
FontForgeException: FontForge command failed: Error: Command failed: /usr/bin/fontforge -lang=ff -c 'Open($1);SetFontNames($3,$3,$3);Generate($2, "", 8);' '/home/rangi/(snip)/assets/rangi/PumpDemiBoldLetPlain.ttf' 'assets/fonts/PumpDemiBoldLetPlain.ttf' 'Pump Demi Bold LET' 2> /dev/null

From command: /usr/bin/fontforge -lang=ff -c 'Open($1);SetFontNames($3,$3,$3);Generate($2, "", 8);' '/home/rangi/(snip)/assets/rangi/PumpDemiBoldLetPlain.ttf' 'assets/fonts/PumpDemiBoldLetPlain.ttf' 'Pump Demi Bold LET' 2> /dev/null

Changing the font name to have no spaces fixes it so it's not the end of the world for me.

aminta commented 6 years ago

I'm still getting the same error too....