NSAttributedString attributes
✓ Published0🌍 Public
KKevinGutowski
Last edited Jun 13, 2020
Created on Jun 13, 2020
This example demonstrates programmatic manipulation of rich text attributes within a Sketch document. It shows how to access selected layers, locate the application’s Plugins menu, and log the first menu item’s title. The code then explores setting a variety of text attributes—such as superscript, underline style, stroke width, and writing direction—on an `NSAttributedString` object loaded from an RTF file. The implementation relies on Sketch’s JavaScript API, including `sketch.getSelectedDocument()`, `NSAttributedString`, and methods like `addAttribute_value_forRange`, with several experimental calls commented out.
AI-generated description