From cd58eb327632747961ad3e4c99700b34bb242a43 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 26 Feb 2019 14:23:32 -0800 Subject: [PATCH 1/7] README: remove Landscape.io badge It's no longer working since we moved to the new fonttools organization, and it wasn't that useful after all (I never used it myself), so I'm removing it from the main page. --- README.rst | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.rst b/README.rst index f36084ad5..846775869 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,4 @@ -|Travis Build Status| |Appveyor Build status| |Health| |Coverage Status| -|PyPI| |Gitter Chat| +|Travis Build Status| |Appveyor Build status| |Coverage Status| |PyPI| |Gitter Chat| What is this? ~~~~~~~~~~~~~ @@ -407,8 +406,6 @@ Have fun! :target: https://travis-ci.org/fonttools/fonttools .. |Appveyor Build status| image:: https://ci.appveyor.com/api/projects/status/0f7fmee9as744sl7/branch/master?svg=true :target: https://ci.appveyor.com/project/fonttools/fonttools/branch/master -.. |Health| image:: https://landscape.io/github/behdad/fonttools/master/landscape.svg?style=flat - :target: https://landscape.io/github/behdad/fonttools/master .. |Coverage Status| image:: https://codecov.io/gh/fonttools/fonttools/branch/master/graph/badge.svg :target: https://codecov.io/gh/fonttools/fonttools .. |PyPI| image:: https://img.shields.io/pypi/v/fonttools.svg From cbb75283954921420824d18f340dc688b4548bbb Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 27 Feb 2019 14:08:14 -0800 Subject: [PATCH 2/7] varLib.plot: fix IndexError when specifying anonymous locations on the commandline Don't write title with the source's name where we don't have one --- Lib/fontTools/varLib/plot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/varLib/plot.py b/Lib/fontTools/varLib/plot.py index b03744e91..c8ba7666f 100644 --- a/Lib/fontTools/varLib/plot.py +++ b/Lib/fontTools/varLib/plot.py @@ -35,7 +35,7 @@ def plotLocationsSurfaces(locations, fig, names=None, **kwargs): assert len(locations[0].keys()) == 2 if names is None: - names = [''] + names = [None] * len(locations) n = len(locations) cols = math.ceil(n**.5) @@ -45,10 +45,11 @@ def plotLocationsSurfaces(locations, fig, names=None, **kwargs): names = [names[model.reverseMapping[i]] for i in range(len(names))] ax1, ax2 = sorted(locations[0].keys()) - for i, (support,color, name) in enumerate(zip(model.supports, cycle(pyplot.cm.Set1.colors), cycle(names))): + for i, (support, color ,name) in enumerate(zip(model.supports, cycle(pyplot.cm.Set1.colors), cycle(names))): axis3D = fig.add_subplot(rows, cols, i + 1, projection='3d') - axis3D.set_title(name) + if name is not None: + axis3D.set_title(name) axis3D.set_xlabel(ax1) axis3D.set_ylabel(ax2) pyplot.xlim(-1.,+1.) From a979af2019c5c8813e2ed4b9f6ab3d7100aa0209 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 27 Feb 2019 14:09:29 -0800 Subject: [PATCH 3/7] designspaceLib: use axis maps with normalizeLocation fixes https://github.com/fonttools/fonttools/issues/1226 --- Lib/fontTools/designspaceLib/__init__.py | 30 ++++++++---------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/Lib/fontTools/designspaceLib/__init__.py b/Lib/fontTools/designspaceLib/__init__.py index b8b962fc2..6490a47c3 100644 --- a/Lib/fontTools/designspaceLib/__init__.py +++ b/Lib/fontTools/designspaceLib/__init__.py @@ -1188,31 +1188,21 @@ class DesignSpaceDocument(LogMixin, AsDictMixin): return None def normalizeLocation(self, location): - # adapted from fontTools.varlib.models.normalizeLocation because: - # - this needs to work with axis names, not tags - # - this needs to accomodate anisotropic locations - # - the axes are stored differently here, it's just math + from fontTools.varLib.models import normalizeValue + new = {} for axis in self.axes: if axis.name not in location: # skipping this dimension it seems continue - v = location.get(axis.name, axis.default) - if type(v) == tuple: - v = v[0] - if v == axis.default: - v = 0.0 - elif v < axis.default: - if axis.default == axis.minimum: - v = 0.0 - else: - v = (max(v, axis.minimum) - axis.default) / (axis.default - axis.minimum) - else: - if axis.default == axis.maximum: - v = 0.0 - else: - v = (min(v, axis.maximum) - axis.default) / (axis.maximum - axis.default) - new[axis.name] = v + value = location[axis.name] + # 'anisotropic' location, take first coord only + if isinstance(value, tuple): + value = value[0] + triple = [ + axis.map_forward(v) for v in (axis.minimum, axis.default, axis.maximum) + ] + new[axis.name] = normalizeValue(value, triple) return new def normalize(self): From 0475246eef2fad0bb60c67d6c50da6207655ba2b Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 27 Feb 2019 14:22:35 -0800 Subject: [PATCH 4/7] designspaceLib_test: fix test_normalization4 expected results --- Tests/designspaceLib/designspace_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/designspaceLib/designspace_test.py b/Tests/designspaceLib/designspace_test.py index 2044f00ba..ffa5a69b1 100644 --- a/Tests/designspaceLib/designspace_test.py +++ b/Tests/designspaceLib/designspace_test.py @@ -619,7 +619,7 @@ def test_normalise4(): for axis in doc.axes: r.append((axis.name, axis.map)) r.sort() - assert r == [('ddd', [(0, 0.1), (300, 0.5), (600, 0.5), (1000, 0.9)])] + assert r == [('ddd', [(0, 0.0), (300, 0.5), (600, 0.5), (1000, 1.0)])] def test_axisMapping(): # note: because designspance lib does not do any actual @@ -638,7 +638,7 @@ def test_axisMapping(): for axis in doc.axes: r.append((axis.name, axis.map)) r.sort() - assert r == [('ddd', [(0, 0.1), (300, 0.5), (600, 0.5), (1000, 0.9)])] + assert r == [('ddd', [(0, 0.0), (300, 0.5), (600, 0.5), (1000, 1.0)])] def test_rulesConditions(tmpdir): # tests of rules, conditionsets and conditions From 2dfb7bf0fffad4b6b124d3fc158956307b40f62c Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 27 Feb 2019 15:24:35 -0800 Subject: [PATCH 5/7] whitespace [skip ci] --- Lib/fontTools/varLib/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/fontTools/varLib/plot.py b/Lib/fontTools/varLib/plot.py index c8ba7666f..ff6c0f99b 100644 --- a/Lib/fontTools/varLib/plot.py +++ b/Lib/fontTools/varLib/plot.py @@ -45,7 +45,7 @@ def plotLocationsSurfaces(locations, fig, names=None, **kwargs): names = [names[model.reverseMapping[i]] for i in range(len(names))] ax1, ax2 = sorted(locations[0].keys()) - for i, (support, color ,name) in enumerate(zip(model.supports, cycle(pyplot.cm.Set1.colors), cycle(names))): + for i, (support, color, name) in enumerate(zip(model.supports, cycle(pyplot.cm.Set1.colors), cycle(names))): axis3D = fig.add_subplot(rows, cols, i + 1, projection='3d') if name is not None: From fdb3974dd9f5328d8b4a982eb98d3e5e5a734cd2 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 27 Feb 2019 16:30:20 -0800 Subject: [PATCH 6/7] add identifier parameter to PointToSegmentPen.addComponent method 'identifier' param is part of the AbstractPointPen interface. Even though it is unused by the segment pen protocol, the caller may attempt to pass it by positional argument instead of keyword argument, e.g. https://github.com/robotools/fontMath/blob/2920ddd07c14ef50ae2a666f90e724df53ee077e/Lib/fontMath/mathGlyph.py#L486 this patch avoids the resulting TypeError exception --- Lib/fontTools/pens/pointPen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/fontTools/pens/pointPen.py b/Lib/fontTools/pens/pointPen.py index 415972f68..6299e8637 100644 --- a/Lib/fontTools/pens/pointPen.py +++ b/Lib/fontTools/pens/pointPen.py @@ -200,7 +200,8 @@ class PointToSegmentPen(BasePointToSegmentPen): else: pen.endPath() - def addComponent(self, glyphName, transform, **kwargs): + def addComponent(self, glyphName, transform, identifier=None, **kwargs): + del identifier # unused self.pen.addComponent(glyphName, transform) From a288bbf580e8342233397890bac094add0cdbfce Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 27 Feb 2019 17:09:31 -0800 Subject: [PATCH 7/7] requirements.txt: pin munkres to latest py2 compatible version As of version 1.1.0, munkres no longer supports Python 2. https://github.com/bmc/munkres hence it fails on pypy2 on Travis: https://travis-ci.org/fonttools/fonttools/jobs/498219661 so we tell pyup bot to ignore it. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index acfd0fd42..7d5ee69ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,6 @@ brotli==1.0.7; platform_python_implementation != "PyPy" brotlipy==0.7.0; platform_python_implementation == "PyPy" unicodedata2==11.0.0; python_version < '3.7' and platform_python_implementation != "PyPy" scipy==1.2.1; platform_python_implementation != "PyPy" -munkres==1.0.12; platform_python_implementation == "PyPy" +munkres==1.0.12; platform_python_implementation == "PyPy" # pyup: ignore zopfli==0.1.6 fs==2.3.1