Created
May 13, 2015 07:33
-
-
Save mekkablue/65e1deeab13c111010a9 to your computer and use it in GitHub Desktop.
Glyphs script which creates a glyph list of all encoded glyphs, in Unicode order, and puts it in your clipboard for pasting.
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 Unicode-Sorted Glyph List | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Creates a glyph list of all encoded glyphs, in Unicode order, and puts it in your clipboard for pasting. | |
""" | |
import GlyphsApp | |
from AppKit import * | |
thisFont = Glyphs.font # frontmost font | |
listOfEncodedGlyphs = [ g for g in thisFont.glyphs if g.unicode ] | |
listOfSortedGlyphNames = [ g.name for g in sorted( listOfEncodedGlyphs, key = lambda glyph: glyph.unicode ) ] | |
copyString = "\n".join( listOfSortedGlyphNames ) | |
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( copyString ): | |
print "Warning: could not set clipboard." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment