fonttools / skia-pathops

Python bindings for the Skia library's Path Ops
https://skia.org/docs/dev/present/pathops/
BSD 3-Clause "New" or "Revised" License
47 stars 14 forks source link

path ops fails with no on-curve contours #45

Closed typemytype closed 1 year ago

typemytype commented 3 years ago

This should work somehow... even with the added oncurves after the boolean operation

  File "src/python/pathops/_pathops.pyx", line 903, in pathops._pathops.PathPen.qCurveTo
  File "src/python/pathops/_pathops.pyx", line 906, in pathops._pathops.PathPen._qCurveToOne
TypeError: 'NoneType' object is not subscriptable
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="C" format="2">
  <advance width="500"/>
  <outline>
    <contour>
      <point x="92" y="121"/>
      <point x="374" y="381"/>
      <point x="379" y="131"/>
      <point x="74" y="357"/>
    </contour>
  </outline>
</glyph>
anthrotype commented 3 years ago

PathPen doesn't know about these special kinds of paths, needs to be thought how to handle them. The SkPath.quadTo expects two points, one off-curve and one on-curve defining a single quadratic bezier, the latter on-curve can't be None, hence the TypeError. Support for these should probably be added in decompose_quadratic_segment function which handles translating between FontTools Pen's qCurve segments (which can have implied on-curves) and SkPath atomic quadratic bezier curves (which can't).

https://github.com/fonttools/skia-pathops/blob/746870053357a6457ceedfe8a3a159152272619c/src/python/pathops/_pathops.pyx#L1257-L1271