Skip to content

Instantly share code, notes, and snippets.

@KevinGutowski
Created June 13, 2020 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KevinGutowski/34e1f5bd840d4c6105d0f46618022f5b to your computer and use it in GitHub Desktop.
Save KevinGutowski/34e1f5bd840d4c6105d0f46618022f5b to your computer and use it in GitHub Desktop.
NSAttributedString attributes
let sketch = require('sketch')
let doc = sketch.getSelectedDocument()
let selection = doc.selectedLayers.layers[0]
let menu = NSApplication.sharedApplication().mainMenu()
let pluginsMenu = menu.itemWithTitle('Plugins').submenu()
console.log(pluginsMenu.itemArray()[0].title())
/*
let path = "/Users/Kski/Downloads/file.rtf"
let rtfData = NSData.dataWithContentsOfFile(path)
let atString = NSAttributedString.alloc().initWithRTF_documentAttributes(rtfData,null)
//selection.sketchObject.addAttribute_value_forRange(NSBaselineOffsetAttributeName, 10, NSMakeRange(3,1))
//selection.sketchObject.addAttribute_value_forRange(NSSuperscriptAttributeName,1,NSMakeRange(10,1))
// NOPE
//selection.sketchObject.addAttribute_value_forRange(NSBackgroundColorAttributeName,NSColor.yellowColor(),NSMakeRange(4,3))
// NOPE
//selection.sketchObject.addAttribute_value_forRange(NSShadowAttributeName,NSShadow.alloc().init(),NSMakeRange(4,3))
//selection.sketchObject.addAttribute_value_forRange(NSUnderlineStyleAttributeName,NSUnderlineStyleByWord,NSMakeRange(4,7))
//selection.sketchObject.addAttribute_value_forRange(NSStrokeWidthAttributeName,4,NSMakeRange(4,7))
selection.sketchObject.addAttribute_value(NSWritingDirectionAttributeName,[1])
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment