Compares the glyphs of all *fonts* and removes glyphs that are not common to all the provided *fonts*. *fonts* is a `list` of font objects (Defcon or FontParts).
(fonts)
| 196 | |
| 197 | |
| 198 | def makeSourceFontsGlyphCompatible(fonts): |
| 199 | """ |
| 200 | Compares the glyphs of all *fonts* and removes glyphs that are not |
| 201 | common to all the provided *fonts*. |
| 202 | |
| 203 | *fonts* is a `list` of font objects (Defcon or FontParts). |
| 204 | """ |
| 205 | |
| 206 | local_report = report.get("Removed Glyphs", []) |
| 207 | |
| 208 | # Get a list of all glyphs in each font |
| 209 | glyphSets = [font.keys() for font in fonts] |
| 210 | |
| 211 | # Use set intersection to get all common glyph from each list |
| 212 | commonGlyphs = set.intersection(*map(set, glyphSets)) |
| 213 | |
| 214 | for font in fonts: |
| 215 | removed = [] |
| 216 | for name in font.keys(): |
| 217 | if name not in commonGlyphs: |
| 218 | removed.append(name) |
| 219 | if len(removed) != 0: |
| 220 | removeGlyphs(font, removed) |
| 221 | local_report.append((font.info.familyName + " " + font.info.styleName, |
| 222 | removed)) |
| 223 | report["Removed Glyphs"] = local_report |
| 224 | |
| 225 | |
| 226 | def decomposeNonExportingGlyphs(fonts): |