Last active
November 20, 2019 04:19
-
-
Save vorbei/a7c5e910aaeb5a7fb5397c5c833e453c to your computer and use it in GitHub Desktop.
Toggle Filled/Outlined SF Symbols using Figma Scripter
This file contains hidden or 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
| /* | |
| Toggle Filled/Outlined SF Symbols via Figma Scripter: | |
| Press Command+Enter in Figma Scripter to run. | |
| NOTE: ONLY WORKS when text nodes with ONE SYMBOL. | |
| It's a problem of javascript treating the UTF-8 character ranges inappropriately like emojis and SF Symbols. | |
| */ | |
| selection().forEach(n=>{ | |
| if(isText(n)){ | |
| n.characters = toggle(n.characters ); | |
| } | |
| }) | |
| function toggle(p) { | |
| const pairs = " ".split(" "); | |
| const filtered = pairs.filter(d => d.indexOf(p) != -1); | |
| if (filtered.length) { | |
| return filtered[0].replace(p, ""); | |
| } else { | |
| return p; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment