Decompose anything that is scaled or built from nested components. This replaces the fix from Recursive Issue #297, as it will catch issues occurring in #412 and #427.
(fonts)
| 251 | |
| 252 | |
| 253 | def decomposeScaledNested(fonts): |
| 254 | """ |
| 255 | Decompose anything that is scaled or built from nested components. |
| 256 | This replaces the fix from Recursive Issue #297, as it will catch |
| 257 | issues occurring in #412 and #427. |
| 258 | """ |
| 259 | |
| 260 | local_report = report.get("Decomposed scaled, flipped, and nested components", []) |
| 261 | for font in fonts: |
| 262 | |
| 263 | changed_glyphs = [] |
| 264 | |
| 265 | for glyph in font: |
| 266 | if len(glyph.components) != 0: |
| 267 | changed = False |
| 268 | for c in glyph.components: |
| 269 | if c.scale != (1, 1): |
| 270 | try: |
| 271 | c.decompose() |
| 272 | changed = True |
| 273 | except KeyError: |
| 274 | print(font.path) |
| 275 | print(glyph.name) |
| 276 | elif len(font[c.baseGlyph].components) != 0: |
| 277 | try: |
| 278 | c.decompose() |
| 279 | changed = True |
| 280 | except KeyError: |
| 281 | print(font.path) |
| 282 | print(glyph.name) |
| 283 | if changed: |
| 284 | changed_glyphs.append(glyph.name) |
| 285 | |
| 286 | if len(changed_glyphs) != 0: |
| 287 | local_report.append((font.info.familyName + " " + font.info.styleName, changed_glyphs)) |
| 288 | |
| 289 | report["Decomposed scaled, flipped, and nested components"] = local_report |
| 290 | |
| 291 | |
| 292 | def sortGlyphOrder(fonts): |