aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-11-17 03:37:37 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-11-17 03:37:37 +0000
commit79cf2010c57d8b5ed0b242f0edd812e59bc50eb3 (patch)
tree52b2b1fe80bc84b56de0ce1d9c7accd9ed7d5b04
parent06febd39f257455a1326c0e236f061eac0512cb2 (diff)
parent84244ce0631fc0f7ae7d6ee7816b8728a9a62811 (diff)
downloadfonttools-79cf2010c57d8b5ed0b242f0edd812e59bc50eb3.tar.gz
Upgrade fonttools to 4.17.1 am: 5ad7e67a4f am: 84244ce063
Original change: https://android-review.googlesource.com/c/platform/external/fonttools/+/1500983 Change-Id: Iddc3612103fa1ac71e3662b2b35578bbde628fed
-rw-r--r--Lib/fontTools/__init__.py2
-rw-r--r--Lib/fontTools/colorLib/builder.py15
-rw-r--r--Lib/fonttools.egg-info/PKG-INFO9
-rw-r--r--METADATA6
-rw-r--r--NEWS.rst7
-rw-r--r--PKG-INFO9
-rw-r--r--Tests/colorLib/builder_test.py31
-rw-r--r--setup.cfg2
-rwxr-xr-xsetup.py2
9 files changed, 74 insertions, 9 deletions
diff --git a/Lib/fontTools/__init__.py b/Lib/fontTools/__init__.py
index 7712d6d6..c4ee2653 100644
--- a/Lib/fontTools/__init__.py
+++ b/Lib/fontTools/__init__.py
@@ -4,6 +4,6 @@ from fontTools.misc.loggingTools import configLogger
log = logging.getLogger(__name__)
-version = __version__ = "4.17.0"
+version = __version__ = "4.17.1"
__all__ = ["version", "log", "configLogger"]
diff --git a/Lib/fontTools/colorLib/builder.py b/Lib/fontTools/colorLib/builder.py
index 3d75567e..5e7d8c6e 100644
--- a/Lib/fontTools/colorLib/builder.py
+++ b/Lib/fontTools/colorLib/builder.py
@@ -296,13 +296,26 @@ def buildCPAL(
_DEFAULT_ALPHA = VariableFloat(1.0)
+def _is_colrv0_layer(layer: Any) -> bool:
+ # Consider as COLRv0 layer any sequence of length 2 (be it tuple or list) in which
+ # the first element is a str (the layerGlyph) and the second element is an int
+ # (CPAL paletteIndex).
+ # https://github.com/googlefonts/ufo2ft/issues/426
+ try:
+ layerGlyph, paletteIndex = layer
+ except (TypeError, ValueError):
+ return False
+ else:
+ return isinstance(layerGlyph, str) and isinstance(paletteIndex, int)
+
+
def _split_color_glyphs_by_version(
colorGlyphs: _ColorGlyphsDict,
) -> Tuple[_ColorGlyphsV0Dict, _ColorGlyphsDict]:
colorGlyphsV0 = {}
colorGlyphsV1 = {}
for baseGlyph, layers in colorGlyphs.items():
- if all(isinstance(l, tuple) and isinstance(l[1], int) for l in layers):
+ if all(_is_colrv0_layer(l) for l in layers):
colorGlyphsV0[baseGlyph] = layers
else:
colorGlyphsV1[baseGlyph] = layers
diff --git a/Lib/fonttools.egg-info/PKG-INFO b/Lib/fonttools.egg-info/PKG-INFO
index 280bf692..c85d381e 100644
--- a/Lib/fonttools.egg-info/PKG-INFO
+++ b/Lib/fonttools.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: fonttools
-Version: 4.17.0
+Version: 4.17.1
Summary: Tools to manipulate font files
Home-page: http://github.com/fonttools/fonttools
Author: Just van Rossum
@@ -264,6 +264,13 @@ Description: |Travis Build Status| |Appveyor Build status| |Coverage Status| |Py
Changelog
~~~~~~~~~
+ 4.17.1 (released 2020-11-16)
+ ----------------------------
+
+ - [colorLib] Fixed regression in 4.17.0 when building COLR v0 table; when color
+ layers are stored in UFO lib plist, we can't distinguish tuples from lists so
+ we need to accept either types (e5439eb9, googlefonts/ufo2ft/issues#426).
+
4.17.0 (released 2020-11-12)
----------------------------
diff --git a/METADATA b/METADATA
index d965a378..9448fc40 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://github.com/fonttools/fonttools/releases/download/4.17.0/fonttools-4.17.0.zip"
+ value: "https://github.com/fonttools/fonttools/releases/download/4.17.1/fonttools-4.17.1.zip"
}
- version: "4.17.0"
+ version: "4.17.1"
license_type: NOTICE
last_upgrade_date {
year: 2020
month: 11
- day: 12
+ day: 16
}
}
diff --git a/NEWS.rst b/NEWS.rst
index 04798b39..be8fb782 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -1,3 +1,10 @@
+4.17.1 (released 2020-11-16)
+----------------------------
+
+- [colorLib] Fixed regression in 4.17.0 when building COLR v0 table; when color
+ layers are stored in UFO lib plist, we can't distinguish tuples from lists so
+ we need to accept either types (e5439eb9, googlefonts/ufo2ft/issues#426).
+
4.17.0 (released 2020-11-12)
----------------------------
diff --git a/PKG-INFO b/PKG-INFO
index 280bf692..c85d381e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: fonttools
-Version: 4.17.0
+Version: 4.17.1
Summary: Tools to manipulate font files
Home-page: http://github.com/fonttools/fonttools
Author: Just van Rossum
@@ -264,6 +264,13 @@ Description: |Travis Build Status| |Appveyor Build status| |Coverage Status| |Py
Changelog
~~~~~~~~~
+ 4.17.1 (released 2020-11-16)
+ ----------------------------
+
+ - [colorLib] Fixed regression in 4.17.0 when building COLR v0 table; when color
+ layers are stored in UFO lib plist, we can't distinguish tuples from lists so
+ we need to accept either types (e5439eb9, googlefonts/ufo2ft/issues#426).
+
4.17.0 (released 2020-11-12)
----------------------------
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)],
diff --git a/setup.cfg b/setup.cfg
index d831bdc3..d00d4959 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 4.17.0
+current_version = 4.17.1
commit = True
tag = False
tag_name = {new_version}
diff --git a/setup.py b/setup.py
index 3e43fd31..4d705a0f 100755
--- a/setup.py
+++ b/setup.py
@@ -441,7 +441,7 @@ if ext_modules:
setup_params = dict(
name="fonttools",
- version="4.17.0",
+ version="4.17.1",
description="Tools to manipulate font files",
author="Just van Rossum",
author_email="just@letterror.com",