print runFontLabRemote(startNewFontCode)
 
# send a glyph to FontLab,
# it will be inserted in the CurrentFont.
transmitGlyph(f['A'])
f.removeGlyph('A')
 
# send instructions to remove overlap for this glyph
overlapCode = """from robofab.world import CurrentFont
from robofab.tools.remote import transmitGlyph
f = CurrentFont()
f["A"].removeOverlap()
f.update()
transmitGlyph(f['A'])
"""
 
# send the code and catch the output
x = runFontLabRemote(overlapCode)
# interpret the output
receiveGlyph(x, f)
print "Number of contours after: ", len(f['A'])
 
# send instructions to FontLab to close the font again.
closeFontCode = """from robofab.world import CurrentFont
f = CurrentFont()
f.close(None)
"""
print runFontLabRemote(closeFontCode)
print 'done!'
		if ancho_myfont < ancho_nuevo :
			diferencia = "+" + str(ancho_nuevo - ancho_myfont)
		if ancho_myfont == ancho_nuevo:
			diferencia = " - "

		# Imprimo
		print item + " " + str(ancho_nuevo) + " (" + str(diferencia) + ")"
		
		# Borro Lineas Guia Locales
		myfont[item].clearVGuides()
		myfont[item].clearHGuides()
		
		# Agrego Linea Guia en el nuevo Ancho
		myfont[item].appendVGuide(ancho_nuevo)
		
		# Pinto
		if ancho_myfont == ancho_nuevo:
			myfont[item].mark = 70
		if ancho_myfont < ancho_nuevo:
			myfont[item].mark = 130
		if ancho_myfont > ancho_nuevo:
			myfont[item].mark = 255					

# Cierro la fuente Original	
orignalFont.close()

#Updateo mi fuente		
myfont.update()

# Listo el pollo
print '------ Done ------';
	tickCount = len(orignalMetricsFont)
	bar = ProgressBar('Getting metrics', tickCount)
	tick = 0	
	
	if hasMM(orignalMetricsFont.naked()):
		layer = getLayer(orignalMetricsFont.naked(), 'Which layer do you want?')
		for glyph in orignalMetricsFont:
			advanceWidth = int(glyph.naked().GetMetrics(layer).x)
			glyphWidth = int(glyph.naked().GetBoundingRect(layer).width)
			glyphLeft = int(glyph.naked().GetBoundingRect(layer).x)
			glyphRight = advanceWidth - (glyphWidth + glyphLeft)
			orignalMetrics[glyph.name] = [glyphLeft, glyphRight]
			bar.tick(tick)
			tick = tick+1
		bar.close()
		orignalMetricsFont.close()
	else:
		for glyph in orignalMetricsFont:
			orignalMetrics[glyph.name] = [glyph.leftMargin, glyph.rightMargin]
			bar.tick(tick)
			tick = tick+1
		bar.close()
		orignalMetricsFont.close()
	
	layer = getLayer(fontToChange.naked(), 'Which layer to change?')
	tickCount = len(fontToChange)
	bar = ProgressBar('Changing Metrics', tickCount)
	tick = 0	
	for name, metrics in orignalMetrics.iteritems():
		if fontToChange.has_key(name):
			glyphWidth = int(fontToChange[name].naked().GetBoundingRect(layer).width)
Beispiel #4
0
    bar = ProgressBar('Getting metrics', tickCount)
    tick = 0

    if hasMM(orignalMetricsFont.naked()):
        layer = getLayer(orignalMetricsFont.naked(),
                         'Which layer do you want?')
        for glyph in orignalMetricsFont:
            advanceWidth = int(glyph.naked().GetMetrics(layer).x)
            glyphWidth = int(glyph.naked().GetBoundingRect(layer).width)
            glyphLeft = int(glyph.naked().GetBoundingRect(layer).x)
            glyphRight = advanceWidth - (glyphWidth + glyphLeft)
            orignalMetrics[glyph.name] = [glyphLeft, glyphRight]
            bar.tick(tick)
            tick = tick + 1
        bar.close()
        orignalMetricsFont.close()
    else:
        for glyph in orignalMetricsFont:
            orignalMetrics[glyph.name] = [glyph.leftMargin, glyph.rightMargin]
            bar.tick(tick)
            tick = tick + 1
        bar.close()
        orignalMetricsFont.close()

    layer = getLayer(fontToChange.naked(), 'Which layer to change?')
    tickCount = len(fontToChange)
    bar = ProgressBar('Changing Metrics', tickCount)
    tick = 0
    for name, metrics in orignalMetrics.iteritems():
        if fontToChange.has_key(name):
            glyphWidth = int(
def makeDestination(root):
    macPath = os.path.join(root, 'FabFonts', 'ForMac')
    makeFolder(macPath)
    return macPath


def generateOne(f, dstDir):
    print "generating %s" % f.info.fullName
    f.generate('otfcff', dstDir)


f = GetFolder()

if f is not None:
    paths = collectSources(f)
    dstDir = makeDestination(f)

    for f in paths:
        font = None
        print f
        try:
            font = OpenFont(f)
            generateOne(font, dstDir)

        finally:
            if font is not None:
                font.close(False)

    print 'done'
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()
Beispiel #7
0
print runFontLabRemote(startNewFontCode)

# send a glyph to FontLab,
# it will be inserted in the CurrentFont.
transmitGlyph(f['A'])
f.removeGlyph('A')

# send instructions to remove overlap for this glyph
overlapCode = """from robofab.world import CurrentFont
from robofab.tools.remote import transmitGlyph
f = CurrentFont()
f["A"].removeOverlap()
f.update()
transmitGlyph(f['A'])
"""

# send the code and catch the output
x = runFontLabRemote(overlapCode)
# interpret the output
receiveGlyph(x, f)
print "Number of contours after: ", len(f['A'])

# send instructions to FontLab to close the font again.
closeFontCode = """from robofab.world import CurrentFont
f = CurrentFont()
f.close(None)
"""
print runFontLabRemote(closeFontCode)
print 'done!'
Beispiel #8
0
		print "exporting features.."
		glyphOrder = []
		for nakedGlyph in f.naked().glyphs:
			glyph = RGlyph(nakedGlyph)
			glyphOrder.append(glyph.name)
		assert None not in glyphOrder, glyphOrder
		# We make a shallow copy if lib, since we add some stuff for export
		# that doesn't need to be retained in memory.
		fontLib = dict(f.lib)
		
		if supportHints:
			psh = PostScriptFontHintValues(f)
			d = psh.asDict()
			fontLib[postScriptHintDataLibKey] = d

		fontLib["org.robofab.glyphOrder"] = glyphOrder
		f._writeOpenTypeFeaturesToLib(fontLib)
		print "fontLib", fontLib
		u.writeLib(fontLib)
		f.close()

	else:
		print "Making a new UFO at", ufoPath
		f = OpenFont(p)
		f.writeUFO()
		f.close()

for p in paths:
	OpenFont(p)

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()
	if not os.path.exists(path):
		os.makedirs(path)

def makeDestination(root):
	macPath = os.path.join(root, 'FabFonts', 'ForMac')
	makeFolder(macPath)
	return macPath

def generateOne(f, dstDir):
	print "generating %s"%f.info.postscriptFullName
	f.generate('mactype1',  dstDir)
	

f = GetFolder()

if f is not None:
	paths = collectSources(f)
	dstDir = makeDestination(f)

	for f in paths:
		font = None
		try:
			font = OpenFont(f)
			generateOne(font, dstDir)

		finally:
			if font is not None:
				font.close(False)


	print 'done'