Created
January 27, 2017 21:50
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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