Last active
December 19, 2018 18:15
-
-
Save KevinGutowski/ccd47da2c5cc6d5cba8760feb0493d96 to your computer and use it in GitHub Desktop.
Testing to see if I can build an Opentype Panel
This file contains 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
framework("CoreText"); | |
const document = require("sketch").getSelectedDocument(); | |
const textLayer = document.selectedLayers.layers[0]; | |
const font = textLayer.sketchObject.font() | |
const descriptor = font.fontDescriptor().fontDescriptorByAddingAttributes({ | |
[NSFontFeatureSettingsAttribute]: [ | |
{ | |
[NSFontFeatureTypeIdentifierKey]: kLowerCaseType, | |
[NSFontFeatureSelectorIdentifierKey]: kLowerCaseSmallCapsSelector | |
}, | |
{ | |
[NSFontFeatureTypeIdentifierKey]: kUpperCaseType, | |
[NSFontFeatureSelectorIdentifierKey]: kUpperCaseSmallCapsSelector | |
}, | |
{ | |
[NSFontFeatureTypeIdentifierKey]: kNumberCaseType, | |
[NSFontFeatureSelectorIdentifierKey]: kLowerCaseNumbersSelector | |
} | |
] | |
}); | |
const newFont = NSFont.fontWithDescriptor_size(descriptor, 20); | |
textLayer.sketchObject.setFont(newFont); | |
document.sketchObject.inspectorController().reload(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment