Created
July 27, 2019 16:03
-
-
Save mekkablue/f9dbb42e8352203eab59ce222028dd0a to your computer and use it in GitHub Desktop.
Copy Unicode-Sorted Glyph Name List
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
#MenuTitle: Copy Unicode-Sorted Glyph Name List | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Creates a glyph list of all encoded glyphs, in Unicode order, and puts in your clipboard for pasting. | |
""" | |
from AppKit import NSPasteboard | |
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