-
-
Save weiweihuanghuang/0fe8a1377150aaefd142 to your computer and use it in GitHub Desktop.
Covert text to Uppercase for Glyphs App
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: Uppercase | |
# -*- coding: utf-8 -*- | |
"""Creates a new tab of the selected text in upppercase.""" | |
Doc = Glyphs.currentDocument | |
Font = Glyphs.font | |
selectedLayers = Font.selectedLayers | |
selectedText = [] | |
capsString = "" | |
for l in selectedLayers: | |
try: | |
selectedText += [l.parent.name] | |
except AttributeError: | |
selectedText += ["\n"] | |
def UppercaseNameForName(name): | |
baseName = name | |
suffix = "" | |
periodPos = baseName.find(".") | |
if periodPos > 0: | |
baseName = name[:periodPos] | |
suffix = name[periodPos:] | |
try: | |
Char = int(GSGlyphsInfo.glyphInfoForName_(baseName).unicode(), 16) | |
String = u"%c" % Char | |
UpperChar = ord(String.upper()[0]) | |
UpperUnicode = "%0.4X" % UpperChar | |
UpperName = GSGlyphsInfo.glyphInfoForUnicode_(UpperUnicode).name() | |
return UpperName | |
except AttributeError: | |
return "\n" | |
for eachGlyph in selectedText: | |
capsString += "/" + UppercaseNameForName(eachGlyph) | |
Doc.windowController().addTabWithString_(capsString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment