def _updateExportFileList(self):
     if self.w.exportCurrentFontCheckBox.get():
         font = CurrentFont()
         if font is None:
             self.files = {}
         else:
             self.files = {font.path: font}
     else:
         self.files = {}
         for font in AllFonts():
             self.files[font.path] = font
     self._updateFileList()
def SelectFont(message="Select a font:", title='RoboFab', allFonts=None):
    if allFonts is None:
        from robofab.world import AllFonts
        fonts = AllFonts()
    else:
        fonts = allFonts

    data = dict()
    for font in fonts:
        data["%s" % font] = font

    items = data.keys()
    items.sort()
    w = _listController(items, message, title, showSearch=False)
    value = w.get()
    return data.get(value, None)
示例#3
0
# robothon 2006
# batch generate

from robofab.world import AllFonts

for font in AllFonts():
	font.generate('otfcff')
#FLM: AT Copy widths to open fonts
# Copy the selected widths to other fonts
from robofab.world import CurrentFont, AllFonts, CurrentGlyph
fonts = AllFonts()
forigen = CurrentFont()
sel = forigen.selection


def copiaWidth(myWidth, gtarget):
    anchoFinal = gtarget.width
    anchoActual = myWidth
    anchoDif = anchoActual - anchoFinal
    anchoSide = anchoDif / 2
    gtarget.leftMargin = gtarget.leftMargin + anchoSide
    gtarget.rightMargin = gtarget.rightMargin + anchoSide
    gtarget.width = myWidth
    print str(myWidth) + " > " + str(gtarget.width)


for f in fonts:
    for gname in sel:
        if gname in f:
            destino = f[gname]
            origen = forigen[gname]
            print f[gname]
            destino.mark = origen.mark
            copiaWidth(origen.width, destino)

            f.update()

print sel
示例#5
0
from robofab.world import CurrentFont, CurrentGlyph, AllFonts
from robofab.interface.all.dialogs import Message, GetFolder
from robofab.tools.glyphNameSchemes import glyphNameToShortFileName
import os

f = CurrentFont()
g = CurrentGlyph()

f.save()

todo = f.selection
print "selection", todo
if g is not None:
	todo.append(g.name)
		
for f in AllFonts():
	ufoPath = None
	print "f.path", f, f.path
	if f.path is None:
		# huh, in case there is a ghost font.
		print "skipping", f
		continue
	ufoPath = f.path.replace(".vfb", ".ufo")
	if not os.path.exists(ufoPath):
		ufoPath = GetFolder("Select a UFO to save the GLIF in:")
		if ufoPath.find(".ufo") == -1:
			Message("You need to select an UFO. Quitting.")
			ufoPath = None
	if ufoPath is None:
		continue
	for c in todo:
def importUFO(ufoPath,
              newFile=True,
              saveFile=True,
              closeFile=True,
              doInfo=True,
              doKerning=True,
              doGroups=True,
              doLib=True,
              doFeatures=True,
              doHints=False,
              doMarks=True,
              doMasks=True,
              glyphs=None):
    # get the VFB path
    vfbPath = os.path.splitext(ufoPath)[0] + ".vfb"
    if not newFile:
        font = None
        for font in AllFonts():
            if font.path == vfbPath:
                break
        if font is None:
            if not os.path.exists(vfbPath):
                Message("Could not find the FontLab file \"%s\"." %
                        os.path.basename(vfbPath))
                return
            font = OpenFont(vfbPath)
    else:
        if saveFile:
            if os.path.exists(vfbPath):
                vfbPath = _findAvailablePathName(vfbPath)
        font = NewFont()
    # make the font the top font in FL
    fl.ifont = font.fontIndex
    # read the UFO
    font.readUFO(ufoPath,
                 doHints=doHints,
                 doInfo=doInfo,
                 doKerning=doKerning,
                 doGroups=doGroups,
                 doLib=doLib,
                 doFeatures=doFeatures,
                 glyphs=glyphs)
    # load the masks and marks
    if doMasks or doMarks:
        for glyph in font:
            lib = glyph.lib
            if doMarks:
                if lib.has_key(MARK_LIB_KEY):
                    glyph.mark = lib[MARK_LIB_KEY]
                    del lib[MARK_LIB_KEY]
            if doMasks:
                if lib.has_key(MASK_LIB_KEY):
                    # open a glyph window
                    fl.EditGlyph(glyph.index)
                    # switch to the mask layer
                    fl.CallCommand(fl_cmd.ViewEditMask)
                    # add the mask data
                    instructions = lib[MASK_LIB_KEY]
                    pen = glyph.getPointPen()
                    instructionsDrawPoints(instructions, pen)
                    # switch back to the edit layer
                    fl.CallCommand(fl_cmd.ViewEditMask)
                    # clear the mask data from the glyph lib
                    del lib[MASK_LIB_KEY]
        # close all glyph windows. sometimes this actually works.
        fl.CallCommand(fl_cmd.WindowCloseAllGlyphWindows)
    # load the WWS names
    if doInfo:
        info = readPlist(os.path.join(ufoPath, "fontInfo.plist"))
        if "openTypeNameWWSFamilyName" in info:
            font.lib[WWS_FAMILY_KEY] = info["openTypeNameWWSFamilyName"]
        elif "openTypeNameWWSFamilyName" in font.lib:
            del font.lib[WWS_FAMILY_KEY]
        if "openTypeNameWWSSubfamilyName" in info:
            font.lib[WWS_SUBFAMILY_KEY] = info["openTypeNameWWSSubfamilyName"]
        elif "openTypeNameWWSSubfamilyName" in font.lib:
            del font.lib[WWS_SUBFAMILY_KEY]
    # update the font
    font.update()
    # save and close
    if saveFile:
        font.save(vfbPath)
        if closeFile:
            font.close()
#Get Path to write the results
f = CurrentFont()
path = f.path
dir, fileName = os.path.split(path)
# output = open(dir+'/Kern Cap to Cap.txt', 'w')
# output = open(dir+'/Kern Cap to Lower.txt', 'w')
# output = open(dir+'/Kern Cap to Punctuation.txt', 'w')
output = open(dir + '/Kern Lower to Lower.txt', 'w')
# output = open(dir+'/Kern Lower to Punctuation.txt', 'w')
# output = open(dir+'/Kern Punctuation to Cap', 'w')
# output = open(dir+'/Kern Punctuation to Lower.txt', 'w')
# output = open(dir+'/Kern Numbers to Numbers.txt', 'w')

# Get count of all open fonts
mytotal = sum(f.info.familyName != "" for f in AllFonts())
thresold = percentaje * mytotal / 100
print "Open Fonts: " + str(mytotal)
print "Searching for Kerning Pairs precent in more than " + str(
    thresold) + " fonts"

# Initialize Values all set to Zero
for f in AllFonts():
    kerning = f.kerning
    for (left, right), value in kerning.items():
        if left in myglyphs and right in myglyphs:
            results[left][right] = 0

# Now count again, this time adding 1 for each occureence
for f in AllFonts():
    print 'Analizing ' + str(f.info.familyName) + ' ' + str(
示例#8
0
from robofab.world import AllFonts

print "Compare all fonts in the  AllFonts list with each other:"

af = AllFonts()

results = []
line = []
for n in af:
    line.append( ` n.info.postscriptFullName `)
results.append(line)

for i in range(len(af)):
    one = af[i]
    line = []
    line.append(af[i].info.postscriptFullName)
    for j in range(len(af)):
        other = af[j]
        line.append( ` one == other `)
        if one == other:
            print "same: ", one.path, other.path
    results.append(line)

for n in results:
    print n
示例#9
0
# open a couple of fonts in FL first!
from robofab.world import AllFonts
print AllFonts()