aboutsummaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-11-16 17:42:16 -0800
committerHaibo Huang <hhb@google.com>2020-11-16 17:42:16 -0800
commit5ad7e67a4fae992c0775829298e3846987a98c16 (patch)
tree52b2b1fe80bc84b56de0ce1d9c7accd9ed7d5b04 /Tests
parentaf6cd2e5e079d8013e48aabcc196c47c223610f9 (diff)
downloadfonttools-5ad7e67a4fae992c0775829298e3846987a98c16.tar.gz
Upgrade fonttools to 4.17.1
Test: make Change-Id: If6e8c002b874435c2e9804978bbe2b638bbcac45
Diffstat (limited to 'Tests')
-rw-r--r--Tests/colorLib/builder_test.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Tests/colorLib/builder_test.py b/Tests/colorLib/builder_test.py
index 41684cfd..86b5f9e9 100644
--- a/Tests/colorLib/builder_test.py
+++ b/Tests/colorLib/builder_test.py
@@ -27,6 +27,37 @@ def test_buildCOLR_v0():
assert colr.ColorLayers["b"][1].colorID == 0
+def test_buildCOLR_v0_layer_as_list():
+ # when COLRv0 layers are encoded as plist in UFO lib, both python tuples and
+ # lists are encoded as plist array elements; but the latter are always decoded
+ # as python lists, thus after roundtripping a plist tuples become lists.
+ # Before FontTools 4.17.0 we were treating tuples and lists as equivalent;
+ # with 4.17.0, a paint of type list is used to identify a PaintColrLayers.
+ # This broke backward compatibility as ufo2ft is simply passing through the
+ # color layers as read from the UFO lib plist, and as such the latter use lists
+ # instead of tuples for COLRv0 layers (layerGlyph, paletteIndex) combo.
+ # We restore backward compat by accepting either tuples or lists (of length 2
+ # and only containing a str and an int) as individual top-level layers.
+ # https://github.com/googlefonts/ufo2ft/issues/426
+ color_layer_lists = {
+ "a": [["a.color0", 0], ["a.color1", 1]],
+ "b": [["b.color1", 1], ["b.color0", 0]],
+ }
+
+ colr = builder.buildCOLR(color_layer_lists)
+
+ assert colr.tableTag == "COLR"
+ assert colr.version == 0
+ assert colr.ColorLayers["a"][0].name == "a.color0"
+ assert colr.ColorLayers["a"][0].colorID == 0
+ assert colr.ColorLayers["a"][1].name == "a.color1"
+ assert colr.ColorLayers["a"][1].colorID == 1
+ assert colr.ColorLayers["b"][0].name == "b.color1"
+ assert colr.ColorLayers["b"][0].colorID == 1
+ assert colr.ColorLayers["b"][1].name == "b.color0"
+ assert colr.ColorLayers["b"][1].colorID == 0
+
+
def test_buildCPAL_v0():
palettes = [
[(0.68, 0.20, 0.32, 1.0), (0.45, 0.68, 0.21, 1.0)],