diff options
author | Haibo Huang <hhb@google.com> | 2020-11-17 04:05:26 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-11-17 04:05:26 +0000 |
commit | 27fe8070aec4aa9f90ab934c5a0ef44e3733cee1 (patch) | |
tree | 52b2b1fe80bc84b56de0ce1d9c7accd9ed7d5b04 | |
parent | fb15f40514d3a102156c2ed878d255424c9f8631 (diff) | |
parent | d31461f60a328fbf5e33572aa4fff9eeafe5d29f (diff) | |
download | fonttools-27fe8070aec4aa9f90ab934c5a0ef44e3733cee1.tar.gz |
Upgrade fonttools to 4.17.1 am: 5ad7e67a4f am: 84244ce063 am: 79cf2010c5 am: d31461f60a
Original change: https://android-review.googlesource.com/c/platform/external/fonttools/+/1500983
Change-Id: Ibe6c1b6de9728923874c5f2f68de6a1a358b41ba
-rw-r--r-- | Lib/fontTools/__init__.py | 2 | ||||
-rw-r--r-- | Lib/fontTools/colorLib/builder.py | 15 | ||||
-rw-r--r-- | Lib/fonttools.egg-info/PKG-INFO | 9 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | NEWS.rst | 7 | ||||
-rw-r--r-- | PKG-INFO | 9 | ||||
-rw-r--r-- | Tests/colorLib/builder_test.py | 31 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rwxr-xr-x | setup.py | 2 |
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) ---------------------------- @@ -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 } } @@ -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) ---------------------------- @@ -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)], @@ -1,5 +1,5 @@ [bumpversion] -current_version = 4.17.0 +current_version = 4.17.1 commit = True tag = False tag_name = {new_version} @@ -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", |