Skip to content

Instantly share code, notes, and snippets.

@mekkablue
Created May 13, 2015 07:33
Show Gist options
  • Save mekkablue/65e1deeab13c111010a9 to your computer and use it in GitHub Desktop.
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.
#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