[qu2cuPen] Change stats

To count number of quadratic vs cubic segments.
This commit is contained in:
Behdad Esfahbod 2023-02-21 13:01:04 -07:00
parent b355b59c2c
commit 085b489012
2 changed files with 5 additions and 4 deletions

View File

@ -51,7 +51,8 @@ class Qu2CuPen(ContourFilterPen):
def _quadratics_to_curve(self, q): def _quadratics_to_curve(self, q):
curves = quadratic_to_curves(q, self.max_err, all_cubic=self.all_cubic) curves = quadratic_to_curves(q, self.max_err, all_cubic=self.all_cubic)
if self.stats is not None: if self.stats is not None:
n = str(len(curves)) for curve in curves:
n = str(len(curve))
self.stats[n] = self.stats.get(n, 0) + 1 self.stats[n] = self.stats.get(n, 0) + 1
for curve in curves: for curve in curves:
if len(curve) == 4: if len(curve) == 4:

View File

@ -86,8 +86,8 @@ class _TestPenMixin(object):
self.convert_glyph(source, stats=stats) self.convert_glyph(source, stats=stats)
self.assertTrue(stats) self.assertTrue(stats)
self.assertTrue("1" in stats) self.assertTrue("4" in stats)
self.assertEqual(type(stats["1"]), int) self.assertEqual(type(stats["4"]), int)
def test_addComponent(self): def test_addComponent(self):
pen = self.Pen() pen = self.Pen()