Skip to content

Instantly share code, notes, and snippets.

@mekkablue
Created May 29, 2015 22:40
Show Gist options
  • Save mekkablue/0a382cb4cef101b0064c to your computer and use it in GitHub Desktop.
Save mekkablue/0a382cb4cef101b0064c to your computer and use it in GitHub Desktop.
Copy Glyph Names to Clipboard
#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