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/0fe8a1377150aaefd142 to your computer and use it in GitHub Desktop.
Save weiweihuanghuang/0fe8a1377150aaefd142 to your computer and use it in GitHub Desktop.
Covert text to Uppercase for Glyphs App
#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