Created
May 29, 2015 22:40
-
-
Save mekkablue/0a382cb4cef101b0064c to your computer and use it in GitHub Desktop.
Copy Glyph Names to Clipboard
This file contains 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
#MenuTitle: Copy Glyph Names to Clipboard | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Copies a newline-separated list of glyph names to the clipboard. | |
""" | |
import GlyphsApp | |
from AppKit import * | |
separator = "\n" | |
thisFont = Glyphs.font # frontmost font | |
listOfGlyphNames = [ l.parent.name for l in thisFont.selectedLayers ] | |
clipboardText = separator.join( listOfGlyphNames ) | |
def setClipboard( myText ): | |
""" | |
Sets the contents of the clipboard to myText. | |
Returns True if successful, False if unsuccessful. | |
""" | |
try: | |
myClipboard = NSPasteboard.generalPasteboard() | |
myClipboard.declareTypes_owner_( [NSStringPboardType], None ) | |
myClipboard.setString_forType_( myText, NSStringPboardType ) | |
return True | |
except Exception as e: | |
return False | |
if not setClipboard(clipboardText): | |
print "Warning: could not set clipboard to %s" % ( clipboardText ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment