Skip to content

Instantly share code, notes, and snippets.

@weiweihuanghuang
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weiweihuanghuang/ad64d65413df3674cc57 to your computer and use it in GitHub Desktop.
Save weiweihuanghuang/ad64d65413df3674cc57 to your computer and use it in GitHub Desktop.
Find in Layer Names
#MenuTitle: Find in Layer Names
# -*- coding: utf-8 -*-
__doc__="""Reports Glyphs with Layers containing the search string"""
import GlyphsApp
import vanilla
editString = []
class findInLayerNames(object):
def __init__(self):
self.w = vanilla.FloatingWindow((380, 40), "Search for")
self.w.textSearch = vanilla.TextBox((15, 12+2, 67, 14), "Search for:", sizeStyle='small')
self.w.searchFor = vanilla.EditText((15+67, 12, 60, 19), "[", sizeStyle='small')
self.w.findButton = vanilla.Button((-80, 12+1, -15, 17), "Find", sizeStyle='small', callback=self.buttonCallback)
self.w.setDefaultButton( self.w.findButton )
self.w.center()
self.w.open()
def buttonCallback(self, sender):
Font = Glyphs.font
selectedLayers = Font.selectedLayers
numberOfMasters = len( Font.masters )
searchFor = self.w.searchFor.get()
for g in Font.glyphs:
if len( g.layers ) > numberOfMasters:
for l in [ x for x in g.layers ][numberOfMasters:]:
if searchFor in l.name:
print "%s in %s" % (l.name, g.name)
print l
# editString += (Here the layer should be added to a list to be printed?)
Glyphs.showMacroWindow()
findInLayerNames()
# Create tab with a string of the glyphs at the bracket layer
# Doc.windowController().addTabWithString_( editString )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment