Skip to content

Commit

Permalink
LayerListBuilder: don't emit useless PaintColrLayers of length=1
Browse files Browse the repository at this point in the history
We already filter len(layers)==1 out upfront, but these can sneak in after the layer reuse code when input contains two base glyphs that refer to the same list of layers. This ensure that duplicate base glyphs get the same PaintColrLayers, rather than a wrapper PaintColrLayers of length=1 pointing to the underlying shared PaintColrLayer...
  • Loading branch information
anthrotype committed Jan 21, 2022
1 parent e68a5a1 commit afc5b0b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Lib/fontTools/colorLib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ def listToColrLayers(layer):

layers = [listToColrLayers(l) for l in layers]

# No reason to have a colr layers with just one entry
if len(layers) == 1:
return layers[0], {}

paint = ot.Paint()
paint.Format = int(ot.PaintFormat.PaintColrLayers)
paint.NumLayers = len(layers)
Expand Down

0 comments on commit afc5b0b

Please sign in to comment.