def check_compatibility(f1, f2, names=None, report=True): ''' Checks if glyphs in ``f1`` and ``f2`` are compatible for interpolation. If ``names=None``, all glyphs in ``f1`` will be checked - otherwise, only the ones in the list ``names``. Glyph compatibility is indicated by colors in ``f1``: - ``green`` -> glyphs are compatible - ``red`` -> glyphs are not compatible - ``blue`` -> glyph does not exist in ``f2`` If ``report=True``, the check results will be printed to the output window. ''' # glyph names if names != None: gNames = names else: gNames = f1.keys() # colors clear_colors(f1) green = named_colors['green'] red = named_colors['red'] blue = named_colors['blue'] # check glyphs if report == True: print 'checking compatibility between %s and %s...\n' % (get_full_name(f1), get_full_name(f2)) for name in gNames: if f2.has_key(name): clear_color(f2[name]) # if not compatible if not f1[name].isCompatible(f2[name]): f2[name].markColor = red if report == True: print "\t### %s is not compatible" % name # if compatible else: f2[name].markColor = green if report == True: print "\t%s is compatible" % name # if glyphs not in f2 else: f1[name].markColor = blue if report == True: print "\t### %s is not in font 2" % name # update fonts f2.changed() f1.changed() if report == True: print '\n...done.\n'
def check_compatibility(f1, f2, names=None, report=True): """ Checks if glyphs in ``f1`` and ``f2`` are compatible for interpolation. If ``names=None``, all glyphs in ``f1`` will be checked - otherwise, only the ones in the list ``names``. Glyph compatibility is indicated by colors in ``f1``: glyphs marked with ``green`` are compatible, glyphs marked with ``red`` are not compatible (because contours and/or amount of points do not match), and glyphs marked with ``blue`` do not exist in ``f2``. If ``report=True``, the check results will be printed to the output window. """ # glyph names if names != None: gNames = names else: gNames = f1.keys() # colors clear_colors(f1) green = named_colors['green'] red = named_colors['red'] blue = named_colors['blue'] # check glyphs if report == True: print 'checking compatibility between %s and %s...\n' % ( get_full_name(f1), get_full_name(f2)) for name in gNames: if f2.has_key(name): clear_color(f2[name]) # if not compatible if f1[name].isCompatible(f2[name], False) is not True: f2[name].mark = red if report == True: print "\t### %s is not compatible" % name # if compatible else: f2[name].mark = green if report == True: print "\t%s is compatible" % name # if glyphs not in f2 else: f1[name].mark = blue if report == True: print "\t### %s is not in font 2" % name # update fonts f2.update() f1.update() if report == True: print '\n...done.\n'
def check_compatibility(f1, f2, names=None, report=True): """ Checks if glyphs in ``f1`` and ``f2`` are compatible for interpolation. If ``names=None``, all glyphs in ``f1`` will be checked - otherwise, only the ones in the list ``names``. Glyph compatibility is indicated by colors in ``f1``: glyphs marked with ``green`` are compatible, glyphs marked with ``red`` are not compatible (because contours and/or amount of points do not match), and glyphs marked with ``blue`` do not exist in ``f2``. If ``report=True``, the check results will be printed to the output window. """ # glyph names if names != None: gNames = names else: gNames = f1.keys() # colors clear_colors(f1) green = named_colors['green'] red = named_colors['red'] blue = named_colors['blue'] # check glyphs if report == True: print 'checking compatibility between %s and %s...\n' % (get_full_name(f1), get_full_name(f2)) for name in gNames: if f2.has_key(name): clear_color(f2[name]) # if not compatible if f1[name].isCompatible(f2[name], False) is not True: f2[name].mark = red if report == True: print "\t### %s is not compatible" % name # if compatible else: f2[name].mark = green if report == True: print "\t%s is compatible" % name # if glyphs not in f2 else: f1[name].mark = blue if report == True: print "\t### %s is not in font 2" % name # update fonts f2.update() f1.update() if report == True: print '\n...done.\n'
def clear_callback(self, sender): f = CurrentFont() if f is not None: glyph_names = get_glyphs(f) if len(glyph_names) > 0: print('clearing colors from selected glyphs...\n') print('\t\t', end=' ') for glyph_name in glyph_names: print(glyph_name, end=' ') clear_color(f[glyph_name]) print() print('\n...done.\n') # no glyph selected else: print(no_glyph_selected) # no font open else: print(no_font_open)
def clear_callback(self, sender): f = CurrentFont() if f is not None: glyph_names = get_glyphs(f) if len(glyph_names) > 0: print 'clearing colors from selected glyphs...\n' print '\t\t', for glyph_name in glyph_names: print glyph_name, clear_color(f[glyph_name]) print print '\n...done.\n' # no glyph selected else: print no_glyph_selected # no font open else: print no_font_open