Exemplo n.º 1
0
 def exportPairList(self, sender=None):
     # Save the list of found touching pairs in a text file which can be read by MetricsMachine as a pair list
     path = PutFile("Choose save location", "TouchingPairs.txt")
     if path is not None:
         reportString = "#KPL:P: TouchingPairs\n"
         for g1, g2 in self.touchingPairs:
             reportString += "%s %s\n" % (g1, g2)
         fi = open(path, 'w+')
         fi.write(reportString)
         fi.close()
Exemplo n.º 2
0
def main():
    StartTime = time.clock()
    font = fl.font

    path = font.file_name
    if path is None:
        from robofab.interface.all.dialogs import PutFile
        path = PutFile("Please choose a name for the .glyph")
        if path is None:
            return
    path = os.path.splitext(path)[0]
    path = path + ".glyphs"
    print "Will write font to:", path.decode("utf-8", 'ignore')
    Dict = makePlist(font)
    Dict = writeFeatures(font, Dict)
    Dict.write(path)
    print "export Time:", (time.clock() - StartTime), "s."
Exemplo n.º 3
0
    def runButtonCallback(self, sender):

        testsToRun = self.testFunctions[self.chosenTest]
        rightNow = datetime.now()

        fileNameProposal = '{}{:0>2d}{:0>2d}_{}_{}.txt'.format(
            rightNow.year, rightNow.month, rightNow.day,
            os.path.basename(self.chosenFont.path)[:-4],
            self.testOptionsAbbr[self.testOptions.index(self.chosenTest)])

        progressWindow = self.startProgress('Running Tests')
        with open(PutFile('Choose where to save the report', fileNameProposal),
                  'w') as reportFile:
            for eachFunc in testsToRun:
                errorLines, missingGlyphs = eachFunc(self.chosenFont)
                report = convertLinesToString(errorLines, missingGlyphs,
                                              self.showMissingGlyph)
                reportFile.write(report)
        progressWindow.close()
Exemplo n.º 4
0
def dump(font):
    # Give the user a default name to save
    defaultName = font.info.fontName + '.txt'
    filePath = PutFile('Save dump file', defaultName)

    if filePath is not None:
        tickCount = len(font)
        bar = ProgressBar('Writing dump file', tickCount)
        tick = 0
        outList = []
        for glyph in font:
            bar.tick(tick)
            tick = tick + 1
            if len(glyph.components) != 0:
                output = glyph.name + ';' + str(int(glyph.width))
                componentNumber = 0
                while componentNumber < len(glyph.components):
                    x, y = glyph.components[componentNumber].offset
                    output = output + ';' + glyph.components[
                        componentNumber].baseGlyph + ';' + str(
                            int(x)) + ';' + str(int(y))
                    componentNumber = componentNumber + 1
                output = output + '\n'
                outList.append((glyph.index, output))

        # Create a dictionary for sorting the glyphs by GID
        outDictionary = dict(outList)
        outKeys = outDictionary.keys()
        outKeys.sort()

        # Write out the file
        file = open(filePath, 'w')
        keyCount = 0
        while keyCount < len(outKeys):
            file.write(outDictionary[outKeys[keyCount]])
            keyCount = keyCount + 1
        file.close()
        bar.close()
        Message('Dump file written')
Exemplo n.º 5
0
# robothon 2006
# get info attributes for all fonts
# and dump them to a text file

from robofab.world import AllFonts
from robofab.interface.all.dialogs import PutFile

text = []

for font in AllFonts():
	text.append(str(font.path))
	text.append(str(font.info.familyName))
	text.append(str(font.info.styleName))
	text.append(str(font.info.fullName))
	text.append(str(font.info.unitsPerEm))
	text.append(str(font.info.ascender))
	text.append(str(font.info.descender))
	text.append('')

text = '\n'.join(text)
path = PutFile('Save file as:')
if path:
	file = open(path, 'w')
	file.write(text)
	file.close()
Exemplo n.º 6
0
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


#Imports
from robofab.world import CurrentFont
from robofab.interface.all.dialogs import PutFile, Message, ProgressBar

#Script
font = CurrentFont()
filePath = PutFile()
file = open(filePath, 'w')
tickCount = len(font)
bar = ProgressBar('Writing dump file', tickCount)
tick = 0
outList = []
for glyph in font:
	bar.tick(tick)
	tick = tick+1
	if len(glyph.components) != 0:
		output = glyph.name + ';' + str(glyph.width)
		componentNumber = 0
		while componentNumber < len(glyph.components):
			x, y = glyph.components[componentNumber].offset
			output = output + ';' + glyph.components[componentNumber].baseGlyph + ';' + str(x) + ';' + str(y)
			componentNumber = componentNumber + 1
Exemplo n.º 7
0
# robofab manual
# 	Makeufo howto
#	Makeufo from a font binary examples

from robofab.tools.toolsAll import fontToUFO
from robofab.interface.all.dialogs import GetFile, PutFile

srcPath = GetFile('Select the source')
dstPath = PutFile('Save as...')

fontToUFO(srcPath, dstPath)
Exemplo n.º 8
0
from cgDocument.cgDocument import newDocument
from cgDocument.cgPen import CoreGraphicsPen
from robofab.world import CurrentGlyph, CurrentFont
from robofab.interface.all.dialogs import PutFile

import cgDocument.cgPen
reload(cgDocument.cgPen)

f = CurrentFont()
g = CurrentGlyph()

doc = newDocument((1000, 1000), "pdf")

pen = CoreGraphicsPen(f)
doc.setFillCMYK((1, 1, 0, 1, 1))

doc.scale((1, -1))
doc.rect((10, 10, 100, 100))

g.draw(pen)
pen.addToDocument(doc)

dst = PutFile("Save the pdf:")
if dst is not None:
    print dst
    doc.save(dst)
Exemplo n.º 9
0
#FLM: Make Kerning Proof of selection
"""Generate an InDesign 2.0 tagged text file
for every possible glyph combination in the current font."""

from robofab.tools.proof import IDTaggedText
from robofab.world import CurrentFont

f = CurrentFont()

fontSize = 36

id = IDTaggedText(f.info.familyName, f.info.styleName, size=fontSize)

names = f.selection
names.sort()

for l in names:
    left = f[l]
    for r in names:
        right = f[r]
        id.addGlyph(left.index)
        id.addGlyph(right.index)
        id.add(' ')
    print 'finished all pairs starting with', left.name

from robofab.interface.all.dialogs import PutFile
path = PutFile("Save the tagged file:", "KerningProofTags.txt")
if path:
    id.save(path)
Exemplo n.º 10
0
#FLM: Export Current Font to UFO Format
"""
	Export the current font to UFO format. 

"""

from robofab.world import CurrentFont

f = CurrentFont()
if f.path is None:
    from robofab.interface.all.dialogs import PutFile
    path = PutFile("Please choose a name for the .ufo")
    if path is None:
        path = -1  # signal the code below the user has cancelled
else:
    # writeUFO() will firgure out the destination .ufo path
    path = None
if path != -1:
    f.writeUFO(path, doProgress=True)
    print 'DONE!'
Exemplo n.º 11
0
"""

from robofab.glifLib import writeGlyphToString
from robofab.world import CurrentFont, CurrentGlyph
from robofab.interface.all.dialogs import PutFile
from robofab.tools.glyphNameSchemes import glyphNameToShortFileName
import os

f = CurrentFont()
g = CurrentGlyph()

if g is not None:
    todo = [g.name]
else:
    todo = f.selection

for c in todo:
    g = f[c]
    result = True
    data = writeGlyphToString(g.name, g, g.drawPoints)
    filename = glyphNameToShortFileName(g.name, None)
    file = PutFile("Save this glif as:")
    if file is not None:
        path = os.path.join(os.path.dirname(file), filename)
        print "saving to", path
        f = open(path, "w")
        f.write(data)
        f.close()

print 'done'
 def saveMatrix(self, sender):
     pathToSave = PutFile()
Exemplo n.º 13
0
                'c': color[0],
                'm': color[1],
                'y': color[2],
                'k': color[3]
            }))


if __name__ == "__main__":
    from random import randint
    id = IDTaggedText("Minion", "Regular", size=40, leading=50)

    id.addStyle(color=(0, 0, 0, 1))
    id.add("Hello")

    id.addStyle(weight="Bold", color=(0, 0.5, 1, 0))
    id.add(" Everybody")
    id.addStyle(weight="Regular", size=100, color=(0, 1, 1, 0))
    id.addGlyph(102)
    id.addGlyph(202)

    from robofab.interface.all.dialogs import PutFile
    path = PutFile("Save the tagged file:", "TaggedText.txt")
    if path:
        id.save(path)

    # 	then: open a document in Adobe InDesign
    #	select "Place" (cmd-D on Mac)
    #	select the text file you just generated
    #	place the text

    #
Exemplo n.º 14
0
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


#Imports
from robofab.world import CurrentFont
from robofab.interface.all.dialogs import PutFile, Message, ProgressBar

#Script
font = CurrentFont()
defaultName = font.info.fontName + '.txt'
filePath = PutFile('Save dump file', defaultName)
file = open(filePath, 'w')
tickCount = len(font)
bar = ProgressBar('Writing dump file', tickCount)
tick = 0
outList = []
for glyph in font:
	bar.tick(tick)
	tick = tick+1
	if len(glyph.components) != 0:
		output = glyph.name + ';' + str(glyph.width)
		componentNumber = 0
		while componentNumber < len(glyph.components):
			x, y = glyph.components[componentNumber].offset
			output = output + ';' + glyph.components[componentNumber].baseGlyph + ';' + str(x) + ';' + str(y)
			componentNumber = componentNumber + 1