Rename backgrounds of layers with the same name#667
Rename backgrounds of layers with the same name#667moyogo wants to merge 9 commits intogooglefonts:mainfrom
Conversation
381dc42 to
69a9df6
Compare
80231a1 to
1492cc2
Compare
| if master.id == layer.associatedMasterId: | ||
| if layer.name not in layers_by_name: | ||
| layers_by_name[layer.name] = [] | ||
| layers_by_name[layer.name].append(layer) |
There was a problem hiding this comment.
you could use dict.setdefault or a defaultdict
| layer_name = f"{layer.name} #{n!r}" | ||
| n += 1 | ||
| ufo_layer = ufo_font.newLayer(layer_name) | ||
| if layer.name != "Color 1": |
There was a problem hiding this comment.
what's this "Color 1"? A new magic value? Why only 1?
| ( | ||
| l.name | ||
| for l in ufo_font.layers | ||
| if l.lib.get(LAYER_ID_KEY) == layer.layerId |
There was a problem hiding this comment.
maybe you could store a map from layerId to layer name in the builder instance instead of finding them like this each time
|
I’m not quite sure whether this is due to this specific branch, or due to other code, but in a font I’ve use Is there a way to prevent the additional layers from being created? I don’t really need them. If this would be better as a separate issue, please let me know, and I can move this comment. |

Same as #570 but for background of layers with the same name.
It fixes #573 and #588.