Skip to content

Instantly share code, notes, and snippets.

@tannerhodges
Created January 27, 2017 21:50
Show Gist options
  • Save tannerhodges/3f92fcde545cab7d7ec0930b020b70b7 to your computer and use it in GitHub Desktop.
Save tannerhodges/3f92fcde545cab7d7ec0930b020b70b7 to your computer and use it in GitHub Desktop.
Check whether a given font has the OpenType small caps feature "smcp" enabled
var path = process.argv[2];
if (!path) {
throw 'Whoops! We need a font path to check: `node small-caps.js [path_to_font]`';
}
var fontkit = require('fontkit');
var font = fontkit.openSync(path);
var hasSmallCaps = font.availableFeatures.indexOf('smcp') > -1;
console.log(hasSmallCaps ? 'Yes, this font has small caps.' : 'No, this font does not have small caps.');
console.log('numGlyphs: ', font.numGlyphs);
console.log('characterSet: ', font.characterSet[0] + ', ' + font.characterSet[font.characterSet.length - 1]);
console.log('availableFeatures: ', font.availableFeatures.join(', '));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment