예제 #1
0
    def tofuButtonCallback(self, sender):
        self.outputText = self.inputText
        noBueno = self.tofuText

        self.updateFont()

        if self.ucCheck == 1:
            self.outputText = self.inputText.upper()
            noBueno = noBueno.upper()

        if self.lcCheck == 1:
            self.outputText = self.inputText.lower()
            noBueno = noBueno.lower()

        if self.digitCheck == 1:
            noBueno += s.digits

        if self.punctCheck == 1:
            noBueno += s.punctuation + "‘’“”«»".decode("utf-8")

        self.outputText = removeExtraSpaces("".join(
            letter for letter in self.outputText if letter not in noBueno))
        # outputText = outputText.translate(None, noBueno)

        self.w.outputText.set(self.outputText)

        if self.copyToSCCheck == 1 and self.outputText != "":
            try:
                OpenSpaceCenter(self.font, newWindow=False)

                sc = CurrentSpaceCenter()
                sc.setRaw(self.outputText)

            except AttributeError:
                Message("You need a font to copy to Space Center")
예제 #2
0
 def openTab(self, aString):
     aString = aString[1:]
     if CurrentSpaceCenter():
         CurrentSpaceCenter().set(aString)
     else:
         OpenSpaceCenter(CurrentFont(), newWindow=True)
         CurrentSpaceCenter().set(aString)
 def showThisGlyphInSC_CB(self, sender):
     if CurrentSpaceCenter() is None:
         spaceCenter = OpenSpaceCenter(self.glyph.font)
         spaceCenter.set([self.glyphBelowName])
     else:
         scGlyphs = CurrentSpaceCenter().get()
         spaceCenter = OpenSpaceCenter(self.glyph.font)
         spaceCenter.set(scGlyphs + [self.glyphBelowName])
예제 #4
0
	def doTracking(self, value):
			sp = CurrentSpaceCenter()
			# if there is no space center
			if sp is None:
				# do nothing
				return
			sp.setTracking(value)
			self.w.setTitle("Tracking %s" % str(int(value)))
예제 #5
0
 def spaceCase(self, sender):
     
     sp = CurrentSpaceCenter()
     sc = sp.getRaw()
     
     if sc.isupper(): self.setCase(sp, 'title')
     elif sc.istitle(): self.setCase(sp, 'lower')
     elif sc.islower(): self.setCase(sp, 'upper')
     else: self.setCase(sp, 'upper')
예제 #6
0
    def textEditorCallback(self, sender):
        pangram = self.w.pangramEditor.get()
        self.w.alphabet.set(self.getRemainingLetters(pangram))

        # determine and display pangram length
        self.w.counter.set("Pangram length: %d" % len(pangram))

        # update Space Center text
        if CurrentSpaceCenter() is not None:
            sp = CurrentSpaceCenter()
            sp.setRaw(pangram)
예제 #7
0
	def addButton(self, sender):

		buttonWidth = 60

		sp = CurrentSpaceCenter()
 
		l, t, w, h = sp.top.glyphLinePreInput.getPosSize()
		sp.top.glyphLinePreInput.setPosSize((l + buttonWidth+10, t, w, h))
 
		l, t, w, h = sp.top.glyphLineInput.getPosSize()
		sp.top.glyphLineInput.setPosSize((l + buttonWidth+10, t, w, h))
 
		sp.PopUp = PopUpButton((10, 10, buttonWidth, 22), popUpItems, callback=self.buttonHitCallback)
예제 #8
0
    def myObserver(self, sender):

        sp = CurrentSpaceCenter()

        # print dir(sp.top)

        l, t, w, h = sp.top.glyphLineInput.getPosSize()
        sp.top.glyphLineInput.setPosSize((l, t, w - 37, h))

        l, t, w, h = sp.top.glyphLineAfterInput.getPosSize()
        sp.top.glyphLineAfterInput.setPosSize((l - 37, t, w, h))

        sp.myButton = Button((-134, 10, 33, 22), "OK", callback=self.spaceCase, sizeStyle="small")
예제 #9
0
    def getGlyphs(self):

        glyphs = []

        # font window selection
        if self.w.selectedGlyphs.get():
            font = CurrentFont()
            if font is not None:
                glyphs += font.selectedGlyphs

        # current glyph window
        if self.w.currentGlyph.get():
            glyphWindow = CurrentGlyphWindow()
            if glyphWindow is not None:
                g = glyphWindow.getGlyph()
                if g is not None and g not in glyphs:
                    glyphs += [RGlyph(g)]

        # space center selection
        if self.w.spaceCenter.get():
            spaceCenter = CurrentSpaceCenter(currentFontOnly=True)
            if spaceCenter is not None:
                g = spaceCenter.glyphLineView.getSelected()
                if g is not None and g not in glyphs:
                    glyphs += [RGlyph(g)]

        return glyphs
예제 #10
0
    def _updateWindows(self):

        # update glyph window
        UpdateCurrentGlyphView()

        # update font overview
        f = CurrentFont()
        if f is not None:
            f.changed()

        # update space center
        s = CurrentSpaceCenter()
        if s:
            i = s.glyphLineView.getSelection()
            s.updateGlyphLineView()
            if i is not None:
                s.glyphLineView.setSelection(i)
예제 #11
0
 def useBeamCallback(self, sender):
     '''Show/hide the beam according to checkbox selection.'''
     S = CurrentSpaceCenter()
     if not S:
         return
     value = sender.get()
     options = S.glyphLineView.getDisplayStates()
     options['Beam'] = value
     S.glyphLineView.setDisplayStates(options)
예제 #12
0
    def makeButton(self, notification):
        csc = CurrentSpaceCenter()
        gutter = 10
        b_w = 20
        inset_b = 1

        l, t, w, h = csc.top.glyphLineInput.getPosSize()
        b_h = h - inset_b * 2

        csc.top.glyphLineInput.setPosSize((l + b_w + gutter, t, w, h))
        l, t, w, h = csc.top.glyphLineInput.getPosSize()

        csc.save = ImageButton(
            (l - gutter - b_w, t + inset_b, b_w, b_h),
            imagePath=self.resources_path + '/_icon_Save.pdf',
            callback=self.saverCallback,
            sizeStyle='regular')
        csc.save.getNSButton().setBordered_(0)
        csc.save.getNSButton().setBezelStyle_(2)
예제 #13
0
    def glyphChanged(self, info):
        glyphs = []
        glyph = CurrentGlyph()

        if glyph is None:
            glyphs = []
        else:
            glyphName = glyph.name
            if glyphName in AccentDict:
                glyphList = AccentDict[glyphName]
                glyphs = [
                    font[glyphName].naked() for glyphName in glyphList
                    if glyphName in font
                ]
                SC = CurrentSpaceCenter()
                if SC is not None:
                    CurrentSpaceCenter().set(glyphList)

        self.w.glyphLineView.set(glyphs)
예제 #14
0
    def flip(self, sender=None):
        sp = CurrentSpaceCenter()
        sp.glyphLineView.contentView().setDisplayMode_("Upside Down")

        if not self.flipped:
            self.s.flipButton.setImage(imagePath=self.path2)
            self.flipped = True
        else:
            self.s.flipButton.setImage(imagePath=self.path1)
            self.flipped = False
예제 #15
0
    def saverCallback(self, sender):
        print("saving input text")
        csc = CurrentSpaceCenter()

        string = csc.getRaw()
        print("string is", string)

        before = getDefault("spaceCenterInputSamples")
        print("before is ", before)
        after = list(before)
        print("after is ", after)
        if string not in after:
            after.append(string)
            print("after2 is ", after)
            setDefault("spaceCenterInputSamples", after)
            print("saved input text.")
        else:
            print("did nothing.")

        preferencesChanged()
예제 #16
0
 def setSpaceCenter(self, font, text):
     currentSC = CurrentSpaceCenter()
     if currentSC is None:
         print('opening space center, click back into MM window')
         OpenSpaceCenter(font, newWindow=False)
         currentSC = CurrentSpaceCenter()
     currentSC.setRaw(text)
예제 #17
0
    def __init__(self):

        self.alphabetSet = alphabetSetLower

        # set up window
        self.w = vanilla.Window((420, 150), "Pangrammer Helper")
        # set up remaining letters display
        self.w.alphabet = vanilla.TextBox((15, 15, -15, 20), self.alphabetSet)
        # set up text field, inserting Space Center text if available
        if CurrentSpaceCenter() is None:
            pangram = "Type your pangram here"
        else:
            sp = CurrentSpaceCenter()
            pangram = sp.getRaw()
        self.w.pangramEditor = vanilla.TextEditor(
            (15, 40, -15, 70), pangram, callback=self.textEditorCallback)
        self.w.counter = vanilla.TextBox((-250, 112, -15, 20),
                                         "Pangram length: 0",
                                         alignment='right')
        self.w.checkBox = vanilla.CheckBox((15, 110, -15, 20),
                                           "",
                                           callback=self.checkBoxCallback,
                                           value=False)
        self.w.checkBoxLabel = vanilla.TextBox(
            # don’t know how to access the NSText of a Vanilla check box label
            (32, 112, -15, 20),
            "Mixed case")

        # set the editor font to be monospaced, and the rest to be system font
        monospace_font = NSFont.userFixedPitchFontOfSize_(12)
        system_font = NSFont.systemFontOfSize_(12)
        self.w.pangramEditor.getNSTextView().setFont_(monospace_font)
        self.w.alphabet.getNSTextField().setFont_(system_font)
        self.w.counter.getNSTextField().setFont_(system_font)
        self.w.checkBoxLabel.getNSTextField().setFont_(system_font)
        self.w.open()

        # set remaining letters and counter to reflect contents of text field
        self.textEditorCallback(self)
    def getImageForView(self, viewName):
        if viewName == "Glyph View":
            window = CurrentGlyphWindow()
            if window is None:
                return None
            view = window.getGlyphView().enclosingScrollView()
        elif viewName == "Space Center":
            window = CurrentSpaceCenter()
            if window is None:
                return None
            view = window.glyphLineView.getNSScrollView()

        data = self._getImageForView(view)
        data = data.bytes()
        if isinstance(data, memoryview):
            data = data.tobytes()
        return data
예제 #19
0
 def blurryfyerCallback(self, sender):
     # get the value from the slider
     value = sender.get()
     # get the current space center
     sp = CurrentSpaceCenter()
     # if there is no space center
     if sp is None:
         # do nothing
         return
     # get the line view (this is embedded into a scroll view)
     view = sp.glyphLineView.contentView()
     # create the filter
     blur = CIFilter.filterWithName_("CIGaussianBlur")
     # set the filter defaults
     blur.setDefaults()
     # change the input radius for the blur
     blur.setValue_forKey_(value, "inputRadius")
     # collect all filters in a list
     filters = [blur]
     # tel the view to use layers
     view.setWantsLayer_(True)
     # set the filters into the view
     view.setContentFilters_(filters)
예제 #20
0
from mojo.UI import CurrentSpaceCenter

# --------
# settings
# --------

pageSize = 'LetterLandscape'
margin = 40

# ------------
# calculations
# ------------

f = CurrentFont()
spaceCenter = CurrentSpaceCenter()

help(spaceCenter)

print(spaceCenter.getPosSize())

size(pageSize)

s = spaceCenter.getPointSize() / f.info.unitsPerEm  # scale factor
L = (f.info.unitsPerEm + f.info.descender) * s  # first line shift

w = width() - margin * 2
h = height() - margin * 2
x = margin
y = height() - margin - L
from os.path import expanduser
from mojo.UI import CurrentSpaceCenter, SpaceCenterToPDF

timestamp = datetime.datetime.now().strftime("%Y_%m_%d-%H_%M_%S")

home = expanduser("~")
# imagesDir = "Library/Mobile Documents/com~apple~CloudDocs/RoboFont/" # if you prefer iCloud
imagesDir = "Dropbox/-robofont-working_proofs"  # if you prefer DropBox

path = os.path.join(home, imagesDir)

if not os.path.exists(path):
    os.makedirs(path)

f = CurrentFont()
sp = CurrentSpaceCenter()

if f is not None and sp is not None:
    ufoName = os.path.basename(f.path)
    ufoName = ufoName.replace(".ufo", "_images")
    #print(ufoName)
    ufoImagesPath = os.path.join(path, ufoName)
    print("exporting to", ufoImagesPath)
    if not os.path.exists(ufoImagesPath):
        os.makedirs(ufoImagesPath)

    pdfName = os.path.join(ufoImagesPath,
                           f"{ufoName}-space_center-{timestamp}.pdf")

    SpaceCenterToPDF(pdfName, spaceCenter=None, currentFontOnly=False)
예제 #22
0
 def changedCallback(self, sender):
     UpdateCurrentGlyphView()
     sc = CurrentSpaceCenter()
     if sc:
         sc.refreshAllExept()
예제 #23
0
 def disableDrag(self):
     sp = CurrentSpaceCenter()
     sp.disableDrag(True)
 def changedCallback(self, sender):
     UpdateCurrentGlyphView()
     sc = CurrentSpaceCenter()
     if sc:
         sc.refreshAllExept()
예제 #25
0
    def getText(self):
        if CurrentFont() is None:
            NSBeep()
            self.showMessage("Open a font first.", "")
            return

        if not self.isConnected():
            NSBeep()
            self.showMessage("Required internet connection not found.", "")
            return

        values = {
            'chars':
            self.w.chars.get().encode('utf-8'),
            'script':
            scriptsTagDict[scriptsNameList[self.w.scriptsPopup.get()]],
            'tb':
            langsTagDict[langsNameDict[scriptsNameList[
                self.w.scriptsPopup.get()]][self.w.langsPopup.get()]]
        }

        if self.w.punctCheck.get():
            values['punct'] = True
        if self.w.figsCheck.get():
            values['figs'] = True
            if self.w.figsPopup.isVisible():
                figsOptTagsList = ["dflt", "locl"]
                values['figsOpt'] = figsOptTagsList[self.w.figsPopup.get()]
        if self.w.trimCheck.get() and self.w.trimCheck.isEnable():
            values['trim'] = True
        if self.w.caseCheck.get() and self.w.caseCheck.isEnable():
            values['case'] = True
        if self.w.casingCheck.get() and self.w.casingCheck.isEnable():
            values['casing'] = casingNameList[self.w.casingPopup.get()].lower()

        data = urlencode(values)
        data = data.encode('utf-8')
        print(data)
        request = Request(url, data)
        response = urlopen(request)
        text = response.read()
        textU = unicode(text, 'utf-8')

        if (msgStr in textU):
            textU = textU.replace(msgStr, "")
            NSBeep()
            self.showMessage(textU, "")
            return

        elif (wrnStr in textU):
            resultIndex = textU.find(rsltStr)
            secmsgIndex = textU.find(sndStr)
            frstmsgU = textU[:secmsgIndex].replace(wrnStr, "")
            scndmsgU = textU[secmsgIndex:resultIndex].replace(sndStr, "")
            textU = textU[resultIndex:].replace(rsltStr, "")
            NSBeep()
            self.showMessage(frstmsgU, scndmsgU)

        textList = textU.split()
        trimmedText = ' '.join(textList[:int(self.w.slider.get())])

        if CurrentSpaceCenter() is None:
            OpenSpaceCenter(CurrentFont(), newWindow=False)

        sp = CurrentSpaceCenter()
        print(trimmedText)
        sp.setRaw(trimmedText)

        # Toggle RTL-LTR
        try:
            sp.setLeftToRight(not self.scriptIsRTL)
            sp.setInputWritingDirection(
                'Right to Left' if self.scriptIsRTL else 'Left to Right')
        except AttributeError:
            pass

        return
예제 #26
0
    def wordsForMMPair(self, ):

        self.mixedCase = False

        ### temp comment out to check speed
        self.source = self.w.source.get()
        wordsAll = self.dictWords[self.textfiles[self.source]]

        #default values are hard coded for now
        #self.wordCount = self.getIntegerValue(self.w.wordCount)

        #v = self.getIntegerValue(self.w.wordCount)

        wordCountValue = int(self.wordCount)

        #print(v)

        #print ('self.wordCount', self.wordCount)

        #currently allows any word lenght, this could be customized later

        text = ''
        textList = []

        # try getting pairstring once in order to check if encoded
        pairstring = self.getPairstring(self.pair)

        #convert MM tuple into search pair to check uc, lc, mixed case. Maybe need a different var name here?
        pair2char = ''.join(self.pair2char(self.pair))

        #check Encoding

        #print (pairstring)

        #default value
        makeUpper = False

        if pair2char.isupper():
            #print (pairstring, 'upper')
            makeUpper = True
            #make lower for searching
            searchString = pair2char.lower()

        else:
            #print(pairstring, 'not upper')
            makeUpper = False
            searchString = pair2char
            pass

        #check for mixed case
        if self.pair2char(self.pair)[0].isupper():
            if self.pair2char(self.pair)[1].islower():
                if (self.leftEncoded == True) and (self.rightEncoded == True):
                    self.mixedCase = True

        try:
            currentSC = CurrentSpaceCenter()
            previousText = currentSC.getRaw()
        except:
            previousText = ''
            pass

        count = 0

        #self.usePhrases = False

        # more results for mixed case if we include lc words and capitalize
        if self.mixedCase == True:
            for word in self.randomly(wordsAll):

                # first look for words that are already mixed case
                if searchString in word:
                    #avoid duplicates
                    if not word in textList:

                        #print (word)
                        textList.append(word)
                        count += 1

                #then try capitalizing lowercase words
                if (searchString.lower() in word[:2]):
                    word = word.capitalize()
                    #avoid duplicates
                    if not word in textList:

                        #print (word)
                        textList.append(word)
                        count += 1

                #stop when you get enough results
                if count >= wordCountValue:
                    #print (text)

                    break

            pass

        else:
            for word in self.randomly(wordsAll):
                if searchString in word:

                    #avoid duplicates
                    if not word in textList:

                        #print (word)
                        textList.append(word)
                        count += 1

                #stop when you get enough results
                if count >= wordCountValue:
                    #print (text)

                    break

        if makeUpper == True:
            #make text upper again
            textList = list(text.upper() for text in textList)

        if not len(textList) == 0:
            #see if box is checked
            self.sorted = self.w.listOutput.get()

            #self.sorted = False
            if self.sorted == True:
                sortedText = self.sortWordsByWidth(textList)

                textList = sortedText

                joinString = "\\n"
                text = joinString.join([str(word) for word in textList])

                if self.w.mirroredPair.get(
                ) == True:  #if "start with mirrored pair" is checked, add this to text
                    text = self.pairMirrored(self.pair) + joinString + text
                if self.w.openCloseContext.get(
                ) == True:  # if "show open+close" is checked, add this to text
                    text = self.openCloseContext(self.pair) + text

            else:
                text = ' '.join([str(word) for word in textList])
                if self.w.mirroredPair.get(
                ) == True:  #if "start with mirrored pair" is checked, add this to text
                    text = self.pairMirrored(self.pair) + text
                if self.w.openCloseContext.get(
                ) == True:  # if "show open+close" is checked, add this to text
                    text = self.openCloseContext(self.pair) + text

        # if no words are found, show spacing string and previous text
        if len(text) == 0:

            #do i need to get pairstring again or can I used the previous one?
            #pairstring = self.getPairstring(self.pair)

            previousText = '\\n no words for pair ' + pairstring

            self.messageText = '😞 no words found: ' + pairstring
            self.w.myTextBox.set(self.messageText)

            if makeUpper == True:
                text = self.ucString(pairstring) + previousText
                if self.w.mirroredPair.get(
                ) == True:  #if "start with mirrored pair" is checked, add this to text
                    text = self.pairMirrored(self.pair) + text
                if self.w.openCloseContext.get(
                ) == True:  # if "show open+close" is checked, add this to text
                    text = self.openCloseContext(self.pair) + text

            else:
                text = self.lcString(pairstring) + previousText
                if self.w.mirroredPair.get(
                ) == True:  #if "start with mirrored pair" is checked, add this to text
                    text = self.pairMirrored(self.pair) + text
                if self.w.openCloseContext.get(
                ) == True:  # if "show open+close" is checked, add this to text
                    text = self.openCloseContext(self.pair) + text

            text = text.lstrip()  #remove whitespace
            self.setSpaceCenter(self.font, text)

        else:
            #set space center if words are found
            #not sure why there's always a /slash in from of the first word, added ' '+ to avoid losing the first word

            text = text.lstrip()  #remove whitespace

            self.setSpaceCenter(self.font, text)

            self.messageText = '😎 words found: ' + pairstring
            self.w.myTextBox.set(self.messageText)
	def getText(self):
		if CurrentFont() is None:
			NSBeep()
			self.showMessage("Open a font first.", "")
			return

		if not self.isConnected():
			NSBeep()
			self.showMessage("Required internet connection not found.", "")
			return

		values = {'chars' : self.w.chars.get().encode('utf-8'),
				  'script' : scriptsTagDict[scriptsNameList[self.w.scriptsPopup.get()]],
				  'tb' : langsTagDict[langsNameDict[scriptsNameList[self.w.scriptsPopup.get()]][self.w.langsPopup.get()]] }

		if self.w.punctCheck.get():
			values['punct'] = True
		if self.w.figsCheck.get():
			values['figs'] = True
			if self.w.figsPopup.isVisible():
				figsOptTagsList = ["dflt", "locl"]
				values['figsOpt'] = figsOptTagsList[self.w.figsPopup.get()]
		if self.w.trimCheck.get() and self.w.trimCheck.isEnable():
			values['trim'] = True
		if self.w.caseCheck.get() and self.w.caseCheck.isEnable():
			values['case'] = True
		if self.w.casingCheck.get() and self.w.casingCheck.isEnable():
			values['casing'] = casingNameList[self.w.casingPopup.get()].lower()

		data = urlencode(values)
		data = data.encode('utf-8')
		print(data)
		request = Request(url, data)
		response = urlopen(request)
		text = response.read()
		textU = unicode(text, 'utf-8')

		if (msgStr in textU):
			textU = textU.replace(msgStr, "")
			NSBeep()
			self.showMessage(textU, "")
			return

		elif (wrnStr in textU):
			resultIndex = textU.find(rsltStr)
			secmsgIndex = textU.find(sndStr)
			frstmsgU = textU[:secmsgIndex].replace(wrnStr, "")
			scndmsgU = textU[secmsgIndex:resultIndex].replace(sndStr, "")
			textU = textU[resultIndex:].replace(rsltStr, "")
			NSBeep()
			self.showMessage(frstmsgU, scndmsgU)

		textList = textU.split()
		trimmedText = ' '.join(textList[:int(self.w.slider.get())])

		if CurrentSpaceCenter() is None:
			OpenSpaceCenter(CurrentFont(), newWindow=False)

		sp = CurrentSpaceCenter()
		print(trimmedText)
		sp.setRaw(trimmedText)

		# Toggle RTL-LTR
		try:
			sp.setLeftToRight(not self.scriptIsRTL)
			sp.setInputWritingDirection('Right to Left' if self.scriptIsRTL else 'Left to Right')
		except AttributeError:
			pass

		return
예제 #28
0
 def disableDrag(self):
     sp = CurrentSpaceCenter()
     sp.disableDrag(True)
예제 #29
0
    def drawGlyphsInGroup(self, notification):
        '''Display all glyphs belonging to the same spacing group in the background.'''

        glyph = notification['glyph']

        font = glyph.font
        if font is None:
            return

        siblings = getSiblings(glyph, self.side)
        if not siblings:
            return

        if not notification['selected']:
            return

        S = CurrentSpaceCenter()
        if not S:
            return

        inverse = S.glyphLineView.getDisplayStates()['Inverse']

        # hide solid color glyph
        R, G, B, A = getDefault(
            "spaceCenterBackgroundColor") if not inverse else getDefault(
                "spaceCenterGlyphColor")
        bounds = glyph.bounds
        if bounds:
            save()
            fill(R, G, B, A)
            stroke(R, G, B, A)
            drawGlyph(glyph)
            restore()

        # draw side indicator
        save()
        stroke(1, 0, 0)
        strokeWidth(10)
        xPos = 0 if self.side == 'left' else glyph.width
        yMin = font.info.descender
        yMax = yMin + font.info.unitsPerEm
        line((xPos, yMin), (xPos, yMax))
        restore()

        # draw glyph and siblings
        R, G, B, A = getDefault(
            "spaceCenterGlyphColor") if not inverse else getDefault(
                "spaceCenterBackgroundColor")
        alpha = (1.0 / len(siblings) + self.opacity) / 2
        stroke(None)
        for glyphName in siblings:
            if glyphName not in glyph.layer:
                continue
            g = font[glyphName].getLayer(glyph.layer.name)
            save()
            if self.side == 'right':
                dx = glyph.width - g.width
                translate(dx, 0)
            color = (R, G, B, 0.4) if glyphName == glyph.name else (R, G, B,
                                                                    alpha)
            fill(*color)
            drawGlyph(g)
            restore()
예제 #30
0
 def updateViewsCallback(self, sender):
     '''Update the Space Center.'''
     S = CurrentSpaceCenter()
     if not S:
         return
     S.glyphLineView.refresh()
from mojo.UI import CurrentSpaceCenter

pointSize = 200
percentLineHeight = 1.2
tracking = 0

lineHeight = percentLineHeight * 1000 - 1000

spaceCenter = CurrentSpaceCenter()
spaceCenter.setPointSize(pointSize)
spaceCenter.setTracking(tracking)
spaceCenter.glyphLineView.setLineHeight(lineHeight)
예제 #32
0
 def beam(self):
     '''The beam’s y position in the Space Center.'''
     sp = CurrentSpaceCenter()
     if not sp:
         return
     return sp.beam()
예제 #33
0
	def buttonHitCallback(self, sender):
		if popUpItems[sender.get()] == "PDF":
			if getExtensionDefault(_PDFFolderKey) == 0:
				folder = os.path.dirname(os.path.realpath(CurrentFont().path))
			else: 
				folder = getExtensionDefault(_PDFFolderPathKey)
			
			if getExtensionDefault(_PDFTimeStampOnOffKey):
				from time import strftime
				timestamp = "_%s" % strftime('%s' % getExtensionDefault(_PDFTimeStampKey))
			else:
				timestamp = ""

			filename = '%s/%s%s.pdf' % (folder,getExtensionDefault(_PDFFileNameKey),timestamp)

			filename = filename.replace("%ufo", os.path.splitext(os.path.basename(CurrentFont().path))[0])
			
			SC = CurrentSpaceCenter()
			tsc = SC.get()
			t=""
			for i in tsc[0:int(getExtensionDefault(_PDFTextLimitKey))]:
				if i == "space":
					i = "_"
				if len(i) > 1:
					i=":%s" % i
				t+=i
			print t
			filename = filename.replace("%text", t)
			print filename

			
			SpaceCenterToPDF(filename, spaceCenter=SC)

			if getExtensionDefault(_PDFOpenPDFKey):
				try:
					os.system(u"open '%s'" % filename)
				except:
					subprocess.call(["open", "-R", filename])

		if popUpItems[sender.get()] == "Blur":
			Blurryfyer()
		if popUpItems[sender.get()] == "Tracking":
			Tracker()
		if popUpItems[sender.get()] == "Random":
			from random import shuffle

			SC = CurrentSpaceCenter()
			txt = CurrentSpaceCenter().get()
			shuffle(txt)
			l = []
			for i in range(len(txt)):
				l.append(txt.pop())
			SC.set(l)
		if popUpItems[sender.get()] == "Selection":
			txt = []
			f = CurrentFont()
			for gn in f.glyphOrder:
				if f[gn].selected:
					txt.append("/%s" % gn)
			SC = CurrentSpaceCenter()
			SC.set(txt)