sapegin / grunt-webfont

SVG to webfont converter for Grunt
MIT License
1.11k stars 210 forks source link

"Warning: Can't run ttfautohint" on Windows depiste speicyfing the node engine #329

Closed jlchereau closed 8 years ago

jlchereau commented 8 years ago

On Windows 10 with grunt-webfont v1.1.1 or above (not v1.1.0 and below)

Warning: Can't run ttfautohint.

Command failed: C:\WINDOWS\system32\cmd.exe /s /c "ttfautohint --symbol --fallback-script=latn --windows-compatibility --no-info C:\Users\jlche\AppData\Local\Temp\d-11635-6676-1an4qj9\font.ttf C:\Users\jlche\AppData\Local\Temp\d-11635-6676-1an4qj9\hinted.ttf"
'ttfautohint' is not recognized as an internal or external command,
operable program or batch file.
 Use --force to continue.

My config in gruntfile.js is:

webfont: {
    icons: {
        src: 'svg/*.svg',
        dest: 'dist/fonts',
        options: {
            font: 'kidoju',
            hashes: false, //do not add random string at the end of the font file names (used to avoid caching when changing version)
            stylesheet: 'less',
            engine: 'node',
            //ie7: true, //Commented otherwise Webstorm cannot generate css from less
            fontHeight: 1024,
            descent: 128,
            ascent: 896,
            startCodepoint: 0xF101, //http://www.fileformat.info/info/unicode/block/private_use_area/utf8test.htm
            codepoints: {
                //TODO: maybe we should specify codepoints for all icons otherwise adding new icons might change the correspondence
                'star': 0x2605, //http://www.fileformat.info/info/unicode/char/2605/index.htm
                'star-o': 0x2606 //http://www.fileformat.info/info/unicode/char/2606/index.htm
            },
            templateOptions: {
                baseClass: 'kf',
                classPrefix: 'kf-',
                mixinPrefix: 'kf-'
            },
            rename: function(fileName) {
                var name;
                switch(fileName) {
                    case 'svg/calendar_clock.svg':
                        name = 'datetime';
                        break;
                    case 'svg/door_exit.svg':
                        name = 'signout';
                        break;
                    case 'svg/eye.svg':
                        name = 'view';
                        break;
                    case 'svg/find_again.svg':
                        name = 'search-adv';
                        break;
                    case 'svg/log_in.svg':
                        name = 'signin';
                        break;
                    case 'svg/megaphone.svg':
                        name = 'report';
                        break;
                    case 'svg/message.svg':
                        name = 'comment';
                        break;
                    case 'svg/plus.svg':
                        name = 'create';
                        break;
                    case 'svg/question.svg':
                        name = 'help';
                        break;
                    case 'svg/star2.svg':
                        name = 'star-o';
                        break;
                    case 'svg/trophy.svg':
                        name = 'score';
                        break;
                    default: //home, star
                        name = fileName.replace(/^svg\/(\w+).svg$/, '$1');
                }
                console.log(fileName + '-->' + name);
                return name;
            }
        }
    }
}

Full project is available at https://github.com/kidoju/Kidoju-WebFonts

mrhyde commented 8 years ago

You should set autoHint option to false

jlchereau commented 8 years ago

Thx!

toriaketevan commented 6 years ago

Hi. I fixed the problem by placing ttfautohint.exe in rute of the project where package.json is placed. Than I set autoHint to true and run grunt task.