MCPcopy Index your code
hub / github.com/arrowtype/recursive / makeSourceFontsGlyphCompatible

Function makeSourceFontsGlyphCompatible

mastering/prep_fonts.py:198–223  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

196
197
198def 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
226def decomposeNonExportingGlyphs(fonts):

Callers 1

prepFunction · 0.85

Calls 1

removeGlyphsFunction · 0.70

Tested by

no test coverage detected