-
-
Save ryanbugden/229da5d9b23f7609d98f769398620f24 to your computer and use it in GitHub Desktop.
Riffing on Stephen's script. Toggle whether selected glyphs are export or non-export, depending on what's happening with the first glyph selected. EDIT: just added a version that acts as a contextual menu item, for easy access.
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: Toggle Skip Export - Selected Glyphs | |
| ''' | |
| Go through all selected glyphs, and change whether they are set to export or non-export, | |
| based on the opposite of the state of the first glyph. | |
| ''' | |
| f = CurrentFont() | |
| # check to see if the public.skipExportGlyphs key is in the lib. if not, make it | |
| try: | |
| # stephen’s duplicate-clean-up step, but sandwiched in here | |
| f.lib['public.skipExportGlyphs'] = list(set(f.lib['public.skipExportGlyphs'])) | |
| except: | |
| f.lib['public.skipExportGlyphs'] = [] | |
| # starting empty lists to print out later when filled | |
| non_exp = [] | |
| exp = [] | |
| # check first glyph of selection, and plan to set everything to the opposite state of that | |
| if f.selectedGlyphNames[0] in f.lib['public.skipExportGlyphs']: | |
| make_nonExp = False | |
| else: | |
| make_nonExp = True | |
| # let's change states | |
| for g_name in f.selectedGlyphNames: # f.selection is deprecated | |
| g = f[g_name] | |
| if make_nonExp == True: | |
| if not g_name in f.lib['public.skipExportGlyphs']: | |
| f.lib['public.skipExportGlyphs'].append(g_name) | |
| non_exp.append(g_name) | |
| elif make_nonExp == False: | |
| if g_name in f.lib['public.skipExportGlyphs']: | |
| f.lib['public.skipExportGlyphs'].remove(g_name) | |
| exp.append(g_name) | |
| g.changed() # officially "updates" the glyph. g.update() is deprecated. | |
| # doing the above on the "glyph" level should help it update in the UI | |
| # print results | |
| if exp != []: | |
| print("NEWLY SET TO EXPORT:") | |
| print(exp) | |
| if non_exp != []: | |
| print("NEWLY SET TO NON-EXPORT:") | |
| print(non_exp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment