Exemplo n.º 1
0
 def _get_folder(self):
     """select a folder with .ufo fonts"""
     try:
         self._folder = getFolder()[0]
     # no folder selected
     except TypeError:
         self._folder = None
Exemplo n.º 2
0
 def _get_folder(self):
     '''select a folder with .ufo fonts'''
     try:
         self._folder = getFolder()[0]
     # no folder selected
     except TypeError:
         self._folder = None
Exemplo n.º 3
0
 def otfs_get_folder_callback(self, sender):
     folder_otfs = getFolder()
     if folder_otfs is not None:
         self._otfs_folder = folder_otfs[0]
         print 'otfs folder: %s' % self._otfs_folder
     else:
         print 'no folder selected.\n'
Exemplo n.º 4
0
 def otfs_get_folder_callback(self, sender):
     folder_otfs = getFolder()
     if folder_otfs is not None:
         self._otfs_folder = folder_otfs[0]
         print 'otfs folder: %s' % self._otfs_folder
     else:
         print 'no folder selected.\n'
Exemplo n.º 5
0
    def reportButtonCallback(self, sender):
        popUpIndex = self.w.fontsPopUp.get()
        if popUpIndex == 0:  # all fonts
            fontsToProcess = self.allFonts
        else:
            fontsToProcess = [self.allFonts[popUpIndex]]

        PDF_folder = getFolder('Choose where to save the reports')[0]
        templateFont = OpenFont(TEMPLATE_FONT_PATH, showUI=False)
        justNow = datetime.now()

        self._drawReport(
            referenceFont=templateFont,
            someFonts=fontsToProcess,
            glyphNames=templateFont.glyphOrder,
            reportPath=os.path.join(
                PDF_folder,
                '{:0>4d}{:0>2d}{:0>2d}_templateCompliant.pdf'.format(
                    justNow.year, justNow.month, justNow.day)),
            caption='Template Compliant')

        allGlyphNames = set()
        for eachFont in fontsToProcess:
            allGlyphNames = allGlyphNames | set(eachFont.glyphOrder)
        leftovers = allGlyphNames - set(templateFont.glyphOrder)

        self._drawReport(referenceFont=templateFont,
                         someFonts=fontsToProcess,
                         glyphNames=leftovers,
                         reportPath=os.path.join(
                             PDF_folder,
                             '{:0>4d}{:0>2d}{:0>2d}_extraTemplate.pdf'.format(
                                 justNow.year, justNow.month, justNow.day)),
                         caption='Extra Template')
Exemplo n.º 6
0
 def get_folder_callback(self, sender):
     folder = getFolder(
         messageText='choose a folder for the output files',
         title=self.title,
         allowsMultipleSelection=False)
     if folder is not None:
         folder = folder[0]
         if len(folder) > 0:
             self.folder = folder
             if os.path.exists(self.folder):
                 setExtensionDefault('%s.folder' % self.extension_key, self.folder)
                 self.w.folder_status.set('%s' % unichr(10003))
Exemplo n.º 7
0
 def selectFontFolder(self, sender=None):
     result = getFolder(messageText='Select fonts folder',
                        title='Select',
                        allowsMultipleSelection=False)
     if result:
         path = result[0]
         fontNames = []
         for filePath in os.listdir(path):
             if filePath.startswith('.') or not filePath.endswith('.ufo'):
                 continue
             fontNames.append(filePath)
         self.w.fontList.set(fontNames)
         return path + '/'
     return None
Exemplo n.º 8
0
 def convertButtonCallback(self, sender):
     if self.chosenMode == 'Single File':
         inputPath = getFile('Choose the file to convert')[0]
         if inputPath.endswith('.vfb') or inputPath.endswith('.ufo'):
             executeCommand(['vfb2ufo', '-fo', inputPath], shell=True)
         else:
             message('input file path is not correct')
     else:
         inputFolder = getFolder('Choose a folder with files to convert')[0]
         if inputFolder:
             for eachPath in catchFilesAndFolders(inputFolder,
                                                  self.chosenSuffix):
                 executeCommand(['vfb2ufo', '-fo', eachPath], shell=True)
         else:
             message('input folder path is not correct')
def main():
    currentFont = CurrentFont()
    if currentFont == None:
        print "no font is open, aborting"
        return

    folder_path = getFolder()
    if folder_path:
        pathToDir = folder_path[0]
        files = [ f for f in os.listdir(pathToDir) if isfile(join(pathToDir,f)) and f[0] != '.']
        dictOfImages = parseFiles(pathToDir, files)
        addImages(currentFont, dictOfImages)

        print "all done"
    else:
        print "operation canceled"
Exemplo n.º 10
0
 def openTextsFolderButtonCallback(self, sender):
     textFolder = u'{}'.format(getFolder('Choose a folder for texts files')[0])
     # handling kerning words
     self.kerningWordsDB = loadKerningTexts(textFolder)
     self.kerningTextBaseNames = self.kerningWordsDB.keys()
     self.activeKerningTextBaseName = self.kerningTextBaseNames[0]
     # this is the list used for data manipulation
     self.wordsWorkingList = self.kerningWordsDB[self.activeKerningTextBaseName]
     # this list instead is used for data visualization in the ctrl
     self._makeWordsDisplayList(self.activeKerningTextBaseName)
     self.activeWord = self.wordsWorkingList[0]['word']
     self.wordFilter = ''
     self._filterDisplayList()
     self._updateInfoCaption()
     # ctrls to be updated
     self.kerningVocabularyPopUp.setItems(self.kerningTextBaseNames)
     self.wordsListCtrl.set(self.wordsDisplayList)
     self.wordsFilterCtrl.set(self.wordFilter)
     self.callback(self)
Exemplo n.º 11
0
 def loadFontsFromFolder(self, sender):
     ### LOADING FONTS FROM FOLDER
     folder_imported_OTFs = getFolder()
     if folder_imported_OTFs != None:
         ### closing all previous opened fonts from folder! + clearing the output
         if len(self.loadedFontList) != 0:
             for f in self.loadedFontList:
                 f.close()
             self.loadedFontList = []
         self.imported_files_folder = folder_imported_OTFs[0]
     else:
         return
     if self.imported_files_folder is not None:
         _imported_OTF_path = self.walk(self.imported_files_folder)
         if len(_imported_OTF_path) > 0:
             for i, imported_OTF_path in enumerate(_imported_OTF_path):
                 progressBar = ProgressBar(
                     title="opening font %s of %s" %
                     (str(i + 1), str(len(_imported_OTF_path))),
                     label="...")
                 self.loadedFontList.append(
                     OpenFont(imported_OTF_path, showUI=False))
                 progressBar.close()
     self.w.amountOfLoadedFonts.set(len(self.loadedFontList))
Exemplo n.º 12
0
 def getFolder(self, sender):
     print("result", dialogs.getFolder())
 def otfs_get_folder_callback(self, sender):
     folder_otfs = getFolder()
     self.w.otfs_folder_value.set(folder_otfs[0])
 def ufos_get_folder_callback(self, sender):
     folder_ufos = getFolder()
     self.w.ufos_folder_value.set(folder_ufos[0])
Exemplo n.º 15
0
 def otfs_get_folder_callback(self, sender):
     folder_otfs = getFolder()
     self.otfs_folder = folder_otfs[0]
Exemplo n.º 16
0
 def ufos_get_folder_callback(self, sender):
     folder_ufos = getFolder()
     self.ufos_folder = folder_ufos[0]
Exemplo n.º 17
0
 def _settingsPutPath(self, sender):
     path = getFolder('Where do you store your observers?')[0]
     setExtensionDefault(_pathObsFolder, path)
     self.s.currentPath.set(path)
Exemplo n.º 18
0
 def otfs_get_folder_callback(self, sender):
     folder_otfs = getFolder()
     self.w.otfs_folder_value.set(folder_otfs[0])
Exemplo n.º 19
0
import os
from PIL import Image, ImageChops
import tempfile

from testSupport import compareImages, testDataDir

import drawBot
import sys

if len(sys.argv) == 3:
    root = sys.argv[1]
    dest = sys.argv[2]
else:
    from vanilla import dialogs
    root = dialogs.getFolder()[0]
    dest = dialogs.putFile(["pdf"])

tests = [
    os.path.join(root, filename) for filename in os.listdir(root)
    if os.path.splitext(filename)[-1].lower() == ".png"
]

drawBot.newDrawing()
for path in tests:
    fileName = os.path.basename(path)
    if not fileName.startswith("example_"):
        fileName = "expected_" + fileName

    localPath = os.path.join(testDataDir, fileName)
    if not os.path.exists(localPath):
        continue
Exemplo n.º 20
0
 def _exportProject_button_callback(self, sender):
     getFolder(messageText=u"Select the project Repository/Folder",
               allowsMultipleSelection=False,
               parentWindow=self.w,
               resultCallback=self._finalizeExport_callback)
Exemplo n.º 21
0
 def _test_get_folder_callback(self, sender):
     _folder = getFolder()
     self.w.test_folder_value.set(_folder[0])
Exemplo n.º 22
0
	def changeFolderPath(self,sender):
		newPath = getFolder()
		self.w.folderPath.set(newPath[0])
		setExtensionDefault(_PDFFolderPathKey, newPath[0])
Exemplo n.º 23
0
 def woffs_get_folder_callback(self, sender):
     folder_woffs = getFolder()
     self.woffs_folder = folder_woffs[0]
Exemplo n.º 24
0
 def getFolderSheet(self, sender):
     dialogs.getFolder(parentWindow=self.w,
                       resultCallback=self.dummyCallback)
Exemplo n.º 25
0
 def ufos_get_folder_callback(self, sender):
     folder_ufos = getFolder()
     self.w.ufos_folder_value.set(folder_ufos[0])
Exemplo n.º 26
0
            ):
                for aeIndex, (aeName, atomicOutline) in enumerate(atomicElements):
                    if dcIndex in dcSelection:
                        if aeIndex in aeSelection:
                            db.fill(1, 0, 0, 0.3)
                        else:
                            db.fill(0, 0, 1, 0.3)
                    else:
                        db.fill(0, 0.3)
                    drawOutline(atomicOutline)
        db.endDrawing()

    def displayDrawing(self):
        context = DrawBotContext()
        _drawBotDrawingTool._drawInContext(context)
        self.w.dbView.setPDFDocument(context.getNSPDFDocument())


def drawOutline(outline):
    bez = db.BezierPath()
    outline.drawPoints(bez)
    db.drawPath(bez)


if __name__ == "__main__":
    from vanilla.dialogs import getFolder

    result = getFolder("Please select a .rcjk project folder")
    if result:
        RoboCJKPreviewer(result[0])
Exemplo n.º 27
0
 def otfs_get_folder_callback(self, sender):
     folder_otfs = getFolder()
     self.otfs_folder = folder_otfs[0]
Exemplo n.º 28
0
 def woffs_get_folder_callback(self, sender):
     folder_woffs = getFolder()
     self.woffs_folder = folder_woffs[0]
Exemplo n.º 29
0
 def ufos_get_folder_callback(self, sender):
     folder_ufos = getFolder()
     self.ufos_folder = folder_ufos[0]
Exemplo n.º 30
0
import os
import random
import string
from vanilla.dialogs import getFolder
from fontTools.ttLib import TTFont

# specify the word dictionary
wordPath = '/usr/share/dict/words' # use the mac’s native dictionary
#wordPath = 'italian.txt' # use a custom file

# Do we want to be promted to provide a folder of fonts
# or to specify the fonts in a list
useFolder = False

if useFolder:
    pathToFonts = getFolder('folder with fonts')[0]
    # find all the font files in a provided folder
    paths = []
    for root, dirs, files in os.walk(pathToFonts):
        for filename in files:
            basePath, ext = os.path.splitext(filename)
            if ext in ['.otf', '.ttf']:
                paths.append(os.path.join(root, filename))
else:
    # this is a list of fonts
    # can be a font name for an installed font
    # or a path to a OTF or TTF font
    paths = [
        'Verdana'
        ]