Exemple #1
0
def run():
    f = CurrentFont()
    if f != None:
        myPath = os.path.dirname(f.path)
        fdkPath = setDirectory(myPath, 'fdk')
        exportFDKFiles(f, fdkPath)
        myFile = f.path
        f.naked().modified = 0
        f.close(False)
        OpenFont(myFile)  # revert font
    else:
        myPath = GetFolder('Select folder with vfb source files')
        if myPath:
            fdkPath = setDirectory(myPath, 'fdk')
            allFiles = getFilePaths(myPath, '.vfb')
            for myFile in allFiles:
                f = OpenFont(myFile)
                print ''
                print 'Processing %s...' % os.path.basename(f.path)
                exportFDKFiles(f, fdkPath)
                f.naked().modified = 0
                f.close(False)

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'
"""

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'