def build_names(self): """Build a list of glyph names shared between the fonts.""" if hasattr(self, 'names'): return stats = self.stats['unmatched'] names_a = set(self.font_a.getGlyphOrder()) names_b = set(self.font_b.getGlyphOrder()) if names_a != names_b: stats.append((self.basepath, names_a - names_b, names_b - names_a)) self.names = names_a & names_b stats = self.stats['unicode_mismatch'] reverse_cmap_a = hb_input.build_reverse_cmap(self.font_a) reverse_cmap_b = hb_input.build_reverse_cmap(self.font_b) mismatched = {} for name in self.names: unival_a = reverse_cmap_a.get(name) unival_b = reverse_cmap_b.get(name) if unival_a != unival_b: mismatched[name] = (unival_a, unival_b) if mismatched: stats.append((self.basepath, mismatched.items())) self.names -= set(mismatched.keys())
def build_reverse_cmap(self): """Build a map from glyph names to unicode values for the fonts.""" if hasattr(self, 'reverse_cmap'): return report = self.report reverse_cmaps = [hb_input.build_reverse_cmap(f) for f in self.fonts] mismatched = {} for name in self.names: unival_a, unival_b = [m.get(name) for m in reverse_cmaps] if unival_a != unival_b: mismatched[name] = (unival_a, unival_b) if mismatched: report.append("Glyph unicode values don't match") for name, univals in mismatched.items(): univals = [(('0x%04X' % v) if v else str(v)) for v in univals] report.append(' %s: %s in A, %s in B' % (name, univals[0], univals[1])) report.append('') # return cmap with only names used consistently between fonts self.reverse_cmap = { n: v for n, v in reverse_cmaps[0].items() if n in self.names and n not in mismatched }
def build_reverse_cmap(self): """Build a map from glyph names to unicode values for the fonts.""" if hasattr(self, 'reverse_cmap'): return stats = self.stats['unicode_mismatch'] reverse_cmaps = [hb_input.build_reverse_cmap(f) for f in self.fonts] mismatched = {} for name in self.names: unival_a, unival_b = [m.get(name) for m in reverse_cmaps] if unival_a != unival_b: mismatched[name] = (unival_a, unival_b) if mismatched: stats.append((self.basepath, mismatched.items())) # return cmap with only names used consistently between fonts self.reverse_cmap = {n: v for n, v in reverse_cmaps[0].items() if n in self.names and n not in mismatched}
def build_reverse_cmap(self): """Build a map from glyph names to unicode values for the fonts.""" if hasattr(self, 'reverse_cmap'): return stats = self.stats['unicode_mismatch'] reverse_cmaps = [hb_input.build_reverse_cmap(f) for f in self.fonts] mismatched = {} for name in self.names: unival_a, unival_b = [m.get(name) for m in reverse_cmaps] if unival_a != unival_b: mismatched[name] = (unival_a, unival_b) if mismatched: stats.append((self.basepath, mismatched.items())) # return cmap with only names used consistently between fonts self.reverse_cmap = { n: v for n, v in reverse_cmaps[0].items() if n in self.names and n not in mismatched }
def build_reverse_cmap(self): """Build a map from glyph names to unicode values for the fonts.""" if hasattr(self, 'reverse_cmap'): return report = self.report reverse_cmaps = [hb_input.build_reverse_cmap(f) for f in self.fonts] mismatched = {} for name in self.names: unival_a, unival_b = [m.get(name) for m in reverse_cmaps] if unival_a != unival_b: mismatched[name] = (unival_a, unival_b) if mismatched: report.append("Glyph unicode values don't match") for name, univals in mismatched.items(): univals = [(('0x%04X' % v) if v else str(v)) for v in univals] report.append(' %s: %s in A, %s in B' % (name, univals[0], univals[1])) report.append('') # return cmap with only names used consistently between fonts self.reverse_cmap = {n: v for n, v in reverse_cmaps[0].items() if n in self.names and n not in mismatched}