Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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