Repository: fonttools/fonttools

Issue:
ReemKufiInk crashes pyftsubset
```
pyftsubset --text=duck --output-file=/tmp/reem.otf ReemKufiInk-Bold.otf

Traceback (most recent call last):
  File "/tmp/venv/bin/pyftsubset", line 8, in <module>
    sys.exit(main())
  File "/tmp/venv/lib/python3.9/site-packages/fontTools/misc/loggingTools.py", line 372, in wrapper
    return func(*args, **kwds)
  File "/tmp/venv/lib/python3.9/site-packages/fontTools/subset/__init__.py", line 3104, in main
    subsetter.subset(font)
  File "/tmp/venv/lib/python3.9/site-packages/fontTools/subset/__init__.py", line 2908, in subset
    self._subset_glyphs(font)
  File "/tmp/venv/lib/python3.9/site-packages/fontTools/subset/__init__.py", line 2846, in _subset_glyphs
    retain = table.subset_glyphs(self)
  File "/tmp/venv/lib/python3.9/site-packages/fontTools/subset/__init__.py", line 2086, in subset_glyphs
    colorGlyphsV1 = unbuildColrV1(self.table.LayerList, self.table.BaseGlyphList)
  File "/tmp/venv/lib/python3.9/site-packages/fontTools/colorLib/unbuilder.py", line 6, in unbuildColrV1
    unbuilder = LayerListUnbuilder(layerV1List.Paint)
AttributeError: 'NoneType' object has no attribute 'Paint'
```

TTX handles the font just fine. File from https://github.com/aliftype/reem-kufi/commits/colr-v1 at 93d6dcd693ae42bb4295701e88a07cc4d04db73c


Discussion:
Summon @anthrotype 
Oh.. the LayerList is optional so we should check is not None. Strange that the font makes no use of PaintColrLayers, but still valid and subsetter should be fixed
> Strange that the font makes no use of PaintColrLayers

Yes, it is a placeholder font (all COLRv1 layers are single layers with solid colors)
I love that summoning Cosimo actually worked. And we found a bug, win/win!

Resolving patch:
diff --git a/Lib/fontTools/colorLib/unbuilder.py b/Lib/fontTools/colorLib/unbuilder.py
--- a/Lib/fontTools/colorLib/unbuilder.py
+++ b/Lib/fontTools/colorLib/unbuilder.py
@@ -2,11 +2,14 @@
 from .table_builder import TableUnbuilder
 
 
-def unbuildColrV1(layerV1List, baseGlyphV1List):
-    unbuilder = LayerListUnbuilder(layerV1List.Paint)
+def unbuildColrV1(layerList, baseGlyphList):
+    layers = []
+    if layerList:
+        layers = layerList.Paint
+    unbuilder = LayerListUnbuilder(layers)
     return {
         rec.BaseGlyph: unbuilder.unbuildPaint(rec.Paint)
-        for rec in baseGlyphV1List.BaseGlyphPaintRecord
+        for rec in baseGlyphList.BaseGlyphPaintRecord
     }
 
 


Test patch:
diff --git a/Tests/colorLib/unbuilder_test.py b/Tests/colorLib/unbuilder_test.py
--- a/Tests/colorLib/unbuilder_test.py
+++ b/Tests/colorLib/unbuilder_test.py
@@ -221,11 +221,16 @@
                 "Glyph": "glyph00012",
             },
         ],
-    },
+    }
 }
 
 
 def test_unbuildColrV1():
-    layersV1, baseGlyphsV1 = buildColrV1(TEST_COLOR_GLYPHS)
-    colorGlyphs = unbuildColrV1(layersV1, baseGlyphsV1)
+    layers, baseGlyphs = buildColrV1(TEST_COLOR_GLYPHS)
+    colorGlyphs = unbuildColrV1(layers, baseGlyphs)
     assert colorGlyphs == TEST_COLOR_GLYPHS
+
+def test_unbuildColrV1_noLayers():
+    _, baseGlyphsV1 = buildColrV1(TEST_COLOR_GLYPHS)
+    # Just looking to see we don't crash
+    unbuildColrV1(None, baseGlyphsV1)
\ No newline at end of file