Skip to content

Instantly share code, notes, and snippets.

@KevinGutowski
Last active December 19, 2018 18:15
Show Gist options
  • Save KevinGutowski/ccd47da2c5cc6d5cba8760feb0493d96 to your computer and use it in GitHub Desktop.
Save KevinGutowski/ccd47da2c5cc6d5cba8760feb0493d96 to your computer and use it in GitHub Desktop.
Testing to see if I can build an Opentype Panel
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