#FLM: Interpol Preview """This script draws all incremental interpolations between 1% and 99% of a selected glyph into a new font. It requires two open source fonts in FontLab.""" from robofab.interface.all.dialogs import SelectFont, OneList, ProgressBar from robofab.world import NewFont src1 = SelectFont('Select source font one:') if src1: src2 = SelectFont('Select source font two:') if src2: # collect a list of all compatible glyphs common = [] for glyphName in src1.keys(): if src2.has_key(glyphName): if src1[glyphName].isCompatible(src2[glyphName]): common.append(glyphName) common.sort() selName = OneList(common, 'Select a glyph:') if selName: dest = NewFont() g1 = src1[selName] g2 = src2[selName] count = 1 bar = ProgressBar('Interpolating...', 100) # add the sourec one glyph for reference dest.newGlyph(selName + '_000') dest[selName + '_000'].width = src1[selName].width dest[selName + '_000'].appendGlyph(src1[selName]) dest[selName + '_000'].mark = 1
# MenuTitle: Copy Glyphs From Layer For Selection from __future__ import ( absolute_import, division, print_function, unicode_literals, ) from robofab.world import AllFonts, CurrentFont from robofab.interface.all.dialogs import SelectFont sm = SelectFont("Select source master") f = CurrentFont() selection_names = f.selection[:] print(sm) for n in selection_names: if n in sm: source_glyph = sm[n] target_glyph = f[n] # print source_glyph.name, len(source_glyph), "contours" f[n].clear() f[n].appendGlyph(source_glyph) f[n].width = source_glyph.width else: print("Glyph '%s' does not exist in source master %s." % (n, sm)) f.update()
from robofab.interface.all.dialogs import SelectFont # Test the interpolation compatibility for all glyphs in two fonts font1 = SelectFont("Select the first font") font2 = SelectFont("Now, Select the second font") # Each glyph in the first font: for glyphName in font1.glyphOrder: # If this glyph exists in the second font: if glyphName in font2: # Collect the glyph with the same name from both fonts glyph1 = font1[glyphName] glyph2 = font2[glyphName] # Get the glyph compatibility report report = glyph1.isCompatible(glyph2) # If something is incompatible, print the report if report[0] == False: print(glyphName, report)
from robofab.interface.all.dialogs import SelectFont markCounterpartsOfMissing = (1, 0, 0, 1) # mark color for glyphs missing in the other font # set to None for none, otherwise (r, g, b, a) tuple f1 = SelectFont("Select 'Master' font:") f2 = SelectFont("Select font to compare:") if f1 is not None and f2 is not None: missing = [] for glyph in f1: try: otherGlyph = f2[glyph.name] except: missing.append(glyph.name) print "%s misses the following glyphs compared to %s:" % (f2, f1) missing = sorted(missing) for m in missing: print m if markCounterpartsOfMissing is not None: f1[m].mark = markCounterpartsOfMissing else: print "aborted"
#FLM: Interpol Preview """This script draws all incremental interpolations between 1% and 99% of a selected glyph into a new font. It requires two open source fonts in FontLab.""" from robofab.interface.all.dialogs import SelectFont, OneList, ProgressBar from robofab.world import NewFont src1 = SelectFont('Select source font one:') if src1: src2 = SelectFont('Select source font two:') if src2: # collect a list of all compatible glyphs common = [] for glyphName in src1.keys(): if src2.has_key(glyphName): if src1[glyphName].isCompatible(src2[glyphName]): common.append(glyphName) common.sort() selName = OneList(common, 'Select a glyph:') if selName: dest = NewFont() g1 = src1[selName] g2 = src2[selName] count = 1 bar = ProgressBar('Interpolating...', 100) # add the sourec one glyph for reference dest.newGlyph(selName + '_000') dest[selName + '_000'].width = src1[selName].width dest[selName + '_000'].appendGlyph(src1[selName])
# [h] check compatibility for interpolation # imports from robofab.interface.all.dialogs import SelectFont from hTools2.modules.interpol import check_compatibility # get fonts f1 = SelectFont() f2 = SelectFont() # get glyphs if len(f1.selection) > 0: glyph_names = f1.selection else: glyph_names = f1.keys() # run! check_compatibility(f2, f1, names=glyph_names, report=False)
#FLM: Check opened font glyphs for MM # # Useful for testing to see if two fonts are compatible as as MM font # First import OpenFont, which allows the user open a font file # Also import RFont, so that a new font can be created from robofab.world import OpenFont, RFont from robofab.interface.all.dialogs import SelectFont # Get the two masters for the interpolated font minFont = SelectFont("First font") maxFont = SelectFont("Second font") for glyph in minFont: data = glyph.isCompatible(maxFont.getGlyph(glyph.name), report=True) print glyph print data print 'all done'