Skip to content

Commit

Permalink
subsetLocalFont: Add ttf as an allowed format
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Jul 27, 2019
1 parent 8b2052a commit 3265d19
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/subsetLocalFont.js
Expand Up @@ -18,7 +18,7 @@ const Promise = require('bluebird');
const fs = require('fs');
const getTemporaryFilePath = require('gettemporaryfilepath');

const allowedFormats = ['woff', 'woff2'];
const allowedFormats = ['ttf', 'woff', 'woff2'];

const readFile = Promise.promisify(fs.readFile);
const writeFile = Promise.promisify(fs.writeFile);
Expand Down Expand Up @@ -48,14 +48,17 @@ function subsetLocalFont(inputBuffer, format, text, ignoreMissingUnicodes) {
tempInputFileName,
`--output-file=${tempOutputFileName}`,
'--obfuscate_names',
`--flavor=${format}`,
`--text="${text.replace('"', '\\"')}"`
];

if (format === 'woff') {
args.push('--with-zopfli');
}

if (format !== 'ttf') {
args.push(`--flavor=${format}`);
}

return writeFile(tempInputFileName, inputBuffer)
.then(result => execFile('pyftsubset', args))
.catch(err => {
Expand Down

0 comments on commit 3265d19

Please sign in to comment.