예제 #1
0
 def showAllPairs(self, sender=None):
     # open all resulting pairs in Space Center
     rawString = ""
     for g1, g2 in self.touchingPairs:
         rawString += "/%s/%s/space" % (g1, g2)
     s = OpenSpaceCenter(self.f)
     s.setRaw(rawString)
예제 #2
0
 def showAllPairs(self, sender=None):
     # open all resulting pairs in Space Center
     rawString = ""
     for g1, g2 in self.touchingPairs:
         rawString += "/%s/%s/space" % (g1, g2)
     s = OpenSpaceCenter(self.f)
     s.setRaw(rawString)
	def spaceCenter(self, sender): 
		if CurrentFont() == None: 
			self.w.textBox.set("Open a font!")
		else:
			self.font = CurrentFont()
			textinput = self.w.textBox.get()
			if textinput == "Open a font!":
			   textinput = ""
			   sc = OpenSpaceCenter(self.font)
			   sc.setRaw(textinput)
			else:		 		  
			   sc = OpenSpaceCenter(self.font)
			   sc.setRaw(textinput)
	def spaceCenterAllFonts(self, sender): 
		if CurrentFont() == None: 
			self.w.textBox.set("Open a font!")
		else: 
			textinput = self.w.textBox.get()
			if textinput == "Open a font!":
			   textinput = ""
			   for font in AllFonts():	 
				    sc = OpenSpaceCenter(font)
				    sc.setRaw(textinput)
			else:	  
			   for font in AllFonts():	 
				    sc = OpenSpaceCenter(font)
				    sc.setRaw(textinput)
예제 #5
0
 def makeWords(self, sender=None):
     global warned
     self.f = CurrentFont()
     self.fontChars = self.fontCharacters(self.f)
     self.wordCount = self.getIntegerValue(self.w.basicsBox.wordCount)
     self.minLength = self.getIntegerValue(self.w.basicsBox.minLength)
     self.maxLength = self.getIntegerValue(self.w.basicsBox.maxLength)
     self.case = self.w.basicsBox.case.get()
     self.requiredLetters = self.getInputString(self.w.reqBox.mustLettersBox, False) 
     self.requiredGroups[0] = self.getInputString(self.w.reqBox.group1box, True) 
     self.requiredGroups[1] = self.getInputString(self.w.reqBox.group2box, True) 
     self.requiredGroups[2] = self.getInputString(self.w.reqBox.group3box, True) 
     self.bannedLetters = self.getInputString(self.w.reqBox.notLettersBox, False)
     self.bannedLetters.append(" ")
     self.limitToCharset = self.w.optionsBox.checkbox0.get()
     self.banRepetitions = self.w.optionsBox.checkbox1.get()
     self.randomize = self.w.optionsBox.checkbox2.get()
     self.outputWords = [] #initialize/empty
     
     checker = wordChecker(self.limitToCharset, self.fontChars, self.requiredLetters, self.requiredGroups, self.bannedLetters, self.banRepetitions, self.minLength, self.maxLength)
     for i in self.allWords:
         if len(self.outputWords) >= self.wordCount:
             break
         else:
             if self.randomize:
                 w = choice(self.allWords)
             else:
                 w = i
             if self.case == 1:   w = w.lower()
             elif self.case == 2: w = w.title()
             elif self.case == 3: w = w.upper()
             if checker.checkWord(w, self.outputWords):
                 self.outputWords.append(w)  
     # output
     if len(self.outputWords) < 1:
         print "word-o-mat: No matching words found <sad trombone>"
     else:
         outputString = " ".join(self.outputWords)
         try:
             sp = OpenSpaceCenter(CurrentFont())
             sp.setRaw(outputString)
         except:
             print "word-o-mat:", outputString
             pass
예제 #6
0
    def makeWords(self, sender=None):
        """Parse user input, save new values to prefs, compile and display the resulting words.
        
        I think this function is too long and bloated, it should be taken apart. ########
        """

        global warned
        self.f = CurrentFont()

        if self.f is not None:
            self.fontChars, self.glyphNames = self.fontCharacters(self.f)
            self.glyphNamesForValues = {
                self.fontChars[i]: self.glyphNames[i]
                for i in range(len(self.fontChars))
            }
        else:
            self.fontChars = []
            self.glyphNames = []

        self.wordCount = self.getIntegerValue(self.g1.wordCount)
        self.minLength = self.getIntegerValue(self.g1.minLength)
        self.maxLength = self.getIntegerValue(self.g1.maxLength)
        self.case = self.g1.case.get()
        self.customCharset = []

        charset = self.g1.base.get()
        self.limitToCharset = True
        if charset == 0:
            self.limitToCharset = False

        elif charset == 2:  # use selection
            if len(self.f.selection) == 0:  # nothing selected
                Message(
                    "word-o-mat: No glyphs were selected in the font window. Will use any characters available in the current font."
                )
                self.g1.base.set(1)  # use font chars
            else:
                try:
                    self.customCharset = []
                    for gname in self.f.selection:
                        if self.f[gname].unicode is not None:
                            try:
                                self.customCharset.append(
                                    unichr(int(self.f[gname].unicode)))
                            except ValueError:
                                pass
                except AttributeError:
                    pass

        elif charset == 3:  # use mark color
            c = self.g1.colorWell.get()

            if c is None:
                pass
            elif c.className(
            ) == "NSCachedWhiteColor":  # not set, corresponds to mark color set to None
                c = None

            self.customCharset = []
            self.reqMarkColor = (c.redComponent(), c.greenComponent(),
                                 c.blueComponent(),
                                 c.alphaComponent()) if c is not None else None
            for g in self.f:
                if g.mark == self.reqMarkColor:
                    try:
                        self.customCharset.append(unichr(int(g.unicode)))
                    except:
                        pass
            if len(self.customCharset) == 0:
                Message(
                    "word-o-mat: Found no glyphs that match the specified mark color. Will use any characters available in the current font."
                )
                self.g1.base.set(1)  # use font chars
                self.toggleColorSwatch(0)

        self.matchMode = "text" if self.g2.matchMode.get(
        ) == 0 else "grep"  # braucht es diese zeile noch?

        self.requiredLetters = self.getInputString(
            self.g2.textMode.mustLettersBox, False)
        self.requiredGroups[0] = self.getInputString(
            self.g2.textMode.group1box, True)
        self.requiredGroups[1] = self.getInputString(
            self.g2.textMode.group2box, True)
        self.requiredGroups[2] = self.getInputString(
            self.g2.textMode.group3box, True)
        self.matchPattern = self.g2.grepMode.grepBox.get()

        self.banRepetitions = self.g3.checkbox0.get()
        self.outputWords = []  # initialize/empty

        self.source = self.g1.source.get()
        languageCount = len(self.textfiles)
        if self.source == languageCount:  # User Dictionary
            self.allWords = self.dictWords["user"]
        elif self.source == languageCount + 1:  # Use all languages
            for i in range(languageCount):
                # if any language: concatenate all the wordlists
                self.allWords.extend(self.dictWords[self.textfiles[i]])
        elif self.source == languageCount + 2:  # Custom word list
            try:
                if self.customWords != []:
                    self.allWords = self.customWords
                else:
                    self.allWords = self.dictWords["ukacd"]
                    self.g1.source.set(0)
            except AttributeError:
                self.allWords = self.dictWords["ukacd"]
                self.g1.source.set(0)
        else:  # language lists
            for i in range(languageCount):
                if self.source == i:
                    self.allWords = self.dictWords[self.textfiles[i]]

        # store new values as defaults

        markColorPref = self.reqMarkColor if self.reqMarkColor is not None else "None"

        extDefaults = {
            "wordCount": self.wordCount,
            "minLength": self.minLength,
            "maxLength": self.maxLength,
            "case": self.case,
            "limitToCharset": self.writeExtDefaultBoolean(self.limitToCharset),
            "source": self.source,
            "matchMode": self.matchMode,
            "matchPattern": self.matchPattern,  # non compiled string
            "markColor": markColorPref,
        }
        for key, value in extDefaults.iteritems():
            setExtensionDefault("com.ninastoessinger.word-o-mat." + key, value)

        # go make words
        if self.checkInput(self.limitToCharset, self.fontChars,
                           self.customCharset, self.requiredLetters,
                           self.minLength, self.maxLength, self.case) == True:

            checker = wordcheck.wordChecker(self.limitToCharset,
                                            self.fontChars,
                                            self.customCharset,
                                            self.requiredLetters,
                                            self.requiredGroups,
                                            self.matchPatternRE,
                                            self.banRepetitions,
                                            self.minLength,
                                            self.maxLength,
                                            matchMode=self.matchMode)

            for i in self.allWords:
                if len(self.outputWords) >= self.wordCount:
                    break
                else:
                    w = choice(self.allWords)
                    if self.case == 1: w = w.lower()
                    elif self.case == 2:
                        # special capitalization rules for Dutch IJ
                        # this only works when Dutch is selected as language, not "any".
                        try:
                            ijs = ["ij", "IJ", "Ij"]
                            if self.languageNames[
                                    self.source] == "Dutch" and w[:2] in ijs:
                                wNew = "IJ" + w[2:]
                                w = wNew
                            else:
                                w = w.title()
                        except IndexError:
                            w = w.title()
                    elif self.case == 3:
                        # special capitalization rules for German double s
                        if u"ß" in w:
                            w2 = w.replace(u"ß", "ss")
                            w = w2
                        w = w.upper()

                    if checker.checkWord(w, self.outputWords):
                        self.outputWords.append(w)

            # output
            if len(self.outputWords) < 1:
                Message("word-o-mat: no matching words found <sad trombone>")
            else:
                joinString = " "
                if self.g3.listOutput.get() == True:
                    joinString = "\\n"
                    self.outputWords = self.sortWordsByWidth(self.outputWords)
                outputString = joinString.join(self.outputWords)
                try:
                    sp = OpenSpaceCenter(CurrentFont())
                    sp.setRaw(outputString)
                except:
                    if warned == False:
                        Message(
                            "word-o-mat: No open fonts found; words will be displayed in the Output Window."
                        )
                    warned = True
                    print "word-o-mat:", outputString
예제 #7
0
# 2015 Benedikt Bramböck
# @arialcrime
#
#########################################################

from mojo.UI import OpenSpaceCenter

import collections, random, string, os
cities = open('cities.txt', 'r')
letters = string.uppercase

azcities = ''

alphabetdict = collections.defaultdict(list)
for city in cities:
    city = city[:-1]
    alphabetdict[city[0].upper()].append(city)

#print alphabet
for l in letters:

    add = random.choice(alphabetdict[l]) + ' '
    azcities += add

# Copy list of cities to clipboard
# os.system("echo '%s' | pbcopy" % azcities)

print azcities
sp = OpenSpaceCenter(CurrentFont())
sp.setRaw(azcities)
예제 #8
0
# 2015 Benedikt Bramböck
# @arialcrime
#
#########################################################

from mojo.UI import OpenSpaceCenter

import collections, random, string, os
cities = open('cities.txt', 'r')
letters = string.uppercase

azcities = ''

alphabetdict = collections.defaultdict(list)
for city in cities:
    city = city[:-1]
    alphabetdict[city[0].upper()].append(city)
    
#print alphabet
for l in letters: 
    
    add = random.choice(alphabetdict[l]) + ' '
    azcities += add

# Copy list of cities to clipboard
# os.system("echo '%s' | pbcopy" % azcities)

print azcities
sp = OpenSpaceCenter(CurrentFont())
sp.setRaw(azcities)
예제 #9
0
    def makeWords(self, sender=None):
        """Parse user input, save new values to prefs, compile and display the resulting words.
        
        I think this function is too long and bloated, it should be taken apart. ########
        """
        
        global warned
        self.f = CurrentFont()
        
        if self.f is not None:
            self.fontChars, self.glyphNames = self.fontCharacters(self.f)
            self.glyphNamesForValues = {self.fontChars[i]: self.glyphNames[i] for i in range(len(self.fontChars))}
        else:
            self.fontChars = []
            self.glyphNames = []

        self.wordCount = self.getIntegerValue(self.g1.wordCount)
        self.minLength = self.getIntegerValue(self.g1.minLength)
        self.maxLength = self.getIntegerValue(self.g1.maxLength)
        self.case = self.g1.case.get()
        self.customCharset = []
        
        charset = self.g1.base.get()
        self.limitToCharset = True
        if charset == 0:
            self.limitToCharset = False
            
        elif charset == 2: # use selection
            if len(self.f.selection) == 0: # nothing selected
                Message("word-o-mat: No glyphs were selected in the font window. Will use any characters available in the current font.")
                self.g1.base.set(1) # use font chars
            else:
                try:
                    self.customCharset = []
                    for gname in self.f.selection:
                        if self.f[gname].unicode is not None:
                            try: 
                                self.customCharset.append(unichr(int(self.f[gname].unicode)))
                            except ValueError:
                                pass 
                except AttributeError: 
                    pass 
                    
        elif charset == 3: # use mark color
            c = self.g1.colorWell.get()
            
            if c is None:
                pass
            elif c.className() == "NSCachedWhiteColor": # not set, corresponds to mark color set to None
                c = None
            
            self.customCharset = []
            self.reqMarkColor = (c.redComponent(), c.greenComponent(), c.blueComponent(), c.alphaComponent()) if c is not None else None
            for g in self.f:
                if g.mark == self.reqMarkColor: 
                    try: 
                        self.customCharset.append(unichr(int(g.unicode)))
                    except:
                        pass
            if len(self.customCharset) == 0:
                Message("word-o-mat: Found no glyphs that match the specified mark color. Will use any characters available in the current font.")
                self.g1.base.set(1) # use font chars
                self.toggleColorSwatch(0)
        
        self.matchMode = "text" if self.g2.matchMode.get() == 0 else "grep" # braucht es diese zeile noch?
        
        self.requiredLetters = self.getInputString(self.g2.textMode.mustLettersBox, False)
        self.requiredGroups[0] = self.getInputString(self.g2.textMode.group1box, True) 
        self.requiredGroups[1] = self.getInputString(self.g2.textMode.group2box, True) 
        self.requiredGroups[2] = self.getInputString(self.g2.textMode.group3box, True)
        self.matchPattern = self.g2.grepMode.grepBox.get()
        
        self.banRepetitions = self.g3.checkbox0.get()
        self.outputWords = [] # initialize/empty
        
        self.source = self.g1.source.get()
        languageCount = len(self.textfiles)
        if self.source == languageCount: # User Dictionary    
            self.allWords = self.dictWords["user"]
        elif self.source == languageCount+1: # Use all languages
            for i in range(languageCount):
                # if any language: concatenate all the wordlists
                self.allWords.extend(self.dictWords[self.textfiles[i]])
        elif self.source == languageCount+2: # Custom word list
            try:
                if self.customWords != []:
                    self.allWords = self.customWords
                else:
                    self.allWords = self.dictWords["ukacd"] 
                    self.g1.source.set(0)
            except AttributeError:
                self.allWords = self.dictWords["ukacd"] 
                self.g1.source.set(0)
        else: # language lists
            for i in range(languageCount):
                if self.source == i:
                    self.allWords = self.dictWords[self.textfiles[i]]
                
        # store new values as defaults
        
        markColorPref = self.reqMarkColor if self.reqMarkColor is not None else "None"
        
        extDefaults = {
            "wordCount": self.wordCount, 
            "minLength": self.minLength, 
            "maxLength": self.maxLength, 
            "case": self.case, 
            "limitToCharset": self.writeExtDefaultBoolean(self.limitToCharset), 
            "source": self.source,
            "matchMode": self.matchMode,
            "matchPattern": self.matchPattern, # non compiled string
            "markColor": markColorPref,
            }
        for key, value in extDefaults.iteritems():
            setExtensionDefault("com.ninastoessinger.word-o-mat."+key, value)
                
        # go make words
        if self.checkInput(self.limitToCharset, self.fontChars, self.customCharset, self.requiredLetters, self.minLength, self.maxLength, self.case) == True:
        
            checker = wordcheck.wordChecker(self.limitToCharset, self.fontChars, self.customCharset, self.requiredLetters, self.requiredGroups, self.matchPatternRE, self.banRepetitions, self.minLength, self.maxLength, matchMode=self.matchMode)
            
            for i in self.allWords:
                if len(self.outputWords) >= self.wordCount:
                    break
                else:
                    w = choice(self.allWords)
                    if self.case == 1:   w = w.lower()
                    elif self.case == 2: 
                        # special capitalization rules for Dutch IJ
                        # this only works when Dutch is selected as language, not "any".
                        try:
                            ijs = ["ij", "IJ", "Ij"]
                            if self.languageNames[self.source] == "Dutch" and w[:2] in ijs:
                                wNew = "IJ" + w[2:]
                                w = wNew
                            else:
                                w = w.title()
                        except IndexError:
                            w = w.title()
                    elif self.case == 3:
                        # special capitalization rules for German double s
                        if u"ß" in w:
                            w2 = w.replace(u"ß", "ss")
                            w = w2
                        w = w.upper()
                        
                    if checker.checkWord(w, self.outputWords):
                        self.outputWords.append(w)  
            
            # output
            if len(self.outputWords) < 1:
                Message("word-o-mat: no matching words found <sad trombone>")
            else:
                joinString = " "
                if self.g3.listOutput.get() == True:
                    joinString = "\\n"
                    self.outputWords = self.sortWordsByWidth(self.outputWords)
                outputString = joinString.join(self.outputWords)
                try:
                    sp = OpenSpaceCenter(CurrentFont())
                    sp.setRaw(outputString)
                except:
                    if warned == False:
                        Message("word-o-mat: No open fonts found; words will be displayed in the Output Window.")
                    warned = True
                    print "word-o-mat:", outputString
        else:
            print "word-o-mat: Aborted because of errors"
예제 #10
0
    def makeWords(self, sender=None):
        
        global warned
        self.f = CurrentFont()
        self.fontChars, self.glyphNames = self.fontCharacters(self.f)

        self.glyphNamesForValues = {self.fontChars[i]: self.glyphNames[i] for i in range(len(self.fontChars))}

        self.wordCount = self.getIntegerValue(self.basicsBox.wordCount)
        self.minLength = self.getIntegerValue(self.basicsBox.minLength)
        self.maxLength = self.getIntegerValue(self.basicsBox.maxLength)
        self.case = self.basicsBox.case.get()
        self.customCharset = []
        
        charset = self.basicsBox.radioGroup.get()
        self.limitToCharset = True
        if charset == 0:
            self.limitToCharset = False
        else:
            if charset == 2: # use selection
                if len(self.f.selection) == 0: #nothing selected
                    Message("No glyphs were selected in the font window. Word-o-mat will use any characters available in the font.")
                    self.basicsBox.radioGroup.set(1) # use font chars
                else:
                    try:
                        #self.customCharset = self.f.selection # this just gives me the glyph names
                        self.customCharset = []
                        for gname in self.f.selection:
                            if self.f[gname].unicode is not None: # make sure this does what it should
                                try: 
                                    self.customCharset.append(unichr(int(self.f[gname].unicode)))
                                except ValueError:
                                    pass 
                        #for entry in self.customCharset:
                        #    print entry
                    except AttributeError: 
                        pass        
                
        self.requiredLetters = self.getInputString(self.reqBox.mustLettersBox, False)
        self.requiredGroups[0] = self.getInputString(self.reqBox.group1box, True) 
        self.requiredGroups[1] = self.getInputString(self.reqBox.group2box, True) 
        self.requiredGroups[2] = self.getInputString(self.reqBox.group3box, True)
        self.banRepetitions = self.reqBox.checkbox0.get()
        self.outputWords = [] #initialize/empty
        
        
        self.source = self.basicsBox.source.get()
        languageCount = len(self.textfiles)
        if self.source == languageCount: # User Dictionary    
            self.allWords = self.dictWords["user"]
        elif self.source == languageCount+1: # Custom word list
            try:
                if self.customWords != []:
                    self.allWords = self.customWords
                else:
                    self.allWords = self.dictWords["ukacd"] 
                    self.basicsBox.source.set(0)
            except AttributeError:
                self.allWords = self.dictWords["ukacd"] 
                self.basicsBox.source.set(0)
        else: # language lists
            for i in range(languageCount):
                if self.source == i:
                    self.allWords = self.dictWords[self.textfiles[i]]
                
        # store new values as defaults
        extDefaults = {
            "wordCount": self.wordCount, 
            "minLength": self.minLength, 
            "maxLength": self.maxLength, 
            "case": self.case, 
            "limitToCharset": self.writeExtDefaultBoolean(self.limitToCharset), 
            "source": self.source,
            }
        for key, value in extDefaults.iteritems():
            setExtensionDefault("com.ninastoessinger.word-o-mat."+key, value)
                
        # go make words
        if self.checkInput(self.limitToCharset, self.fontChars, self.customCharset, self.requiredLetters, self.minLength, self.maxLength, self.case) == True:
        
            checker = wordChecker(self.limitToCharset, self.fontChars, self.customCharset, self.requiredLetters, self.requiredGroups, self.banRepetitions, self.minLength, self.maxLength)
            for i in self.allWords:
                if len(self.outputWords) >= self.wordCount:
                    break
                else:
                    w = choice(self.allWords)
                    if self.case == 1:   w = w.lower()
                    elif self.case == 2: w = w.title()
                    elif self.case == 3: w = w.upper()
                    if checker.checkWord(w, self.outputWords):
                        self.outputWords.append(w)  
            # output
            if len(self.outputWords) < 1:
                Message("word-o-mat: no matching words found <sad trombone>")
            else:
                joinString = " "
                #if self.reqBox.delimiterRadio.get() == 1:
                if self.reqBox.listOutput.get() == True:
                    joinString = "\\n"
                    self.outputWords = self.sortWordsByWidth(self.outputWords) ##### NEW / EXPERIMENTAL FEATURE
                outputString = joinString.join(self.outputWords)
                try:
                    sp = OpenSpaceCenter(CurrentFont())
                    sp.setRaw(outputString)
                except:
                    if warned == False:
                        Message("No open fonts found; word-o-mat will output to the Output Window.")
                    warned = True
                    print "word-o-mat:", outputString
        else:
            print "word-o-mat: Aborted because of errors"
예제 #11
0
class SpaceCenterKerning(object):

    """class for SpaceCenterKerning"""

    def __init__(self):

        self.font = CurrentFont()
        self.spaceCenter = None
        if self.font:
            addObserver(self, 'SpaceCenterObserver', 'spaceCenterDidOpen')
            self.spaceCenter = OpenSpaceCenter(self.font, newWindow=True)

            addObserver(self, 'pressedKey', 'spaceCenterKeyDown')
            addObserver(self, 'closeSpaceCenter', 'spaceCenterWillClose')

            # get kerning from CurrentFont and build text list
            self.pairsTextCheck = []
            self.kKeys = self.getKerningPairsRef(self.font)
            for key, gkey in self.kKeys:
                self.pairsTextCheck.append(self.returnPattern(key))

            # index of text
            self.i = 0
            self.maxi = len(self.kKeys)

            if self.pairsTextCheck:
                self.hasKerning = True
                self.spaceCenter.set(self.pairsTextCheck[self.i])
            else:
                self.hasKerning = False
                self.spaceCenter.setRaw('YOUR FONT HAS NO KERNING PAIRS -- your font has no kerning pairs')

        else:
            message('You need to open a font first!')

    def SpaceCenterObserver(self, info):
        if self.spaceCenter:
            self.spaceCenter.set(self.pairsTextCheck[self.i])
            self.updateSpaceCenter()

    def pressedKey(self, info):
        if self.hasKerning is True:
            event = info['event']
            pair = self.kKeys[self.i][1]
            keyCode = event.keyCode()

            # modifier key? alt, shift, None
            if event.modifierFlags() == 11010336:
                kIncrement = 1
            elif event.modifierFlags() == 10617090:
                kIncrement = 5
            else:
                kIncrement = 10

            # down, up, left, right keyCodes
            if keyCode == 125:
                self.i += 1
            elif keyCode == 126:
                self.i -= 1
            elif keyCode == 123:
                self.font.kerning[pair] -= kIncrement
            elif keyCode == 124:
                self.font.kerning[pair] += kIncrement

            # reset if self.i is out of range
            if self.i == self.maxi or self.i == -self.maxi:
                self.i = 0

            self.spaceCenter.set(self.pairsTextCheck[self.i])

    def getKerningPairsRef(self, font):
        """use only the main glyph from kerning group and keep the reference"""
        kerningRef = font.kerning.keys()[:]

        for k in kerningRef:
            left, right = k

            if left in font.groups:
                groupGlyphs = font.groups[left]
                groupGlyphs.sort()
                # get first glyphname in the group
                leftRef = groupGlyphs[0]
            else:
                leftRef = left

            if right in font.groups:
                groupGlyphs = font.groups[right]
                groupGlyphs.sort()
                # get first glyphname in the group
                rightRef = groupGlyphs[0]
            else:
                rightRef = right

            i = kerningRef.index(k)
            kerningRef[i] = (leftRef, rightRef), (left, right)

        kerningRef.sort()
        return kerningRef

    def returnPattern(self, pair):
        """returns the pattern for each kerning pair for its use in the SpaceCenter"""
        left, right = pair
        pattern = 'H/O/H/%s/%s/H/O/H/\\n/H/H/H/%s/%s/H/H/H/\\n/O/O/O/%s/%s/o/o/o/\\n/X/H/X/%s/%s/x/o/x' % (
            left, right, left, right, left, right, left, right,)
        return pattern

    def closeSpaceCenter(self, info):
        """remove Observers when closing the custom SpaceCenter"""
        removeObserver(self, 'spaceCenterDidOpen')
        removeObserver(self, 'spaceCenterWillClose')
        removeObserver(self, 'spaceCenterKeyDown')