Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def DiffCoverage(font_filename1, font_filename2, subset):
"""Prints a comparison of the coverage of a given subset by two fonts.
Args:
font_filename1: The first font to compare.
font_filename2: The second font to compare.
subset: The lowercase name of the subset to compare coverage of.
"""
f1cps = fonts.CodepointsInFont(font_filename1)
f2cps = fonts.CodepointsInFont(font_filename2)
if subset != 'all':
subset_cps = fonts.CodepointsInSubset(subset)
f1cps &= subset_cps
f2cps &= subset_cps
else:
subset_cps = None
subset_cp_str = ('/%d' % len(subset_cps)) if subset_cps is not None else ''
print(' %s %+d (%d%s => %d%s)' % (
subset, len(f2cps) - len(f1cps), len(f1cps), subset_cp_str, len(f2cps),
subset_cp_str))
def _LeastSimilarCoverage(files, subset):
"""Returns pair of fonts having inconsistent coverage for a subset.
Args:
files: List of font files
subset: Name of subset
Returns:
3 tuple of (file1, file2, number of codepoints difference)
"""
worst = (None, None, 0)
subsetcps = fonts.CodepointsInSubset(subset, True)
for pair in itertools.combinations(files, 2):
inconsistency = _InconsistentSubsetSupport(pair[0], pair[1], subsetcps)
if inconsistency > worst[2]:
worst = (pair[0], pair[1], inconsistency)
return worst