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

Feature request: an "overlapRemoved" state or "wouldRemoveOverlap" check #55

Open skef opened 2 years ago

skef commented 2 years ago

pathops seems to be both much faster and more accurate than booleanOperations and seems far preferable for instancing a glyph. However, there are other cases where one wants to remove overlap from a glyph for purposes of analysis rather than final product, and one may only want to do so when there is overlap to be removed. For that, one would either want a state passed back with the output or -- given how fast the library is -- a method that can be called first to ask whether overlap will be removed.

(Simple analysis of the result doesn't answer the question because of the other changes -- combined lines, added inflection points, and so on.)

I haven't entirely convinced myself but I suspect this question is close enough to the question "Are there any inter-segment intersections?" that the latter could serve for the former. If that's accurate then maybe one could replicate the non-debugging portions of SkPathOpsSimplify.cpp:SimplifyDebug() up to before HandleCoincidence() and query the coincidence object.

I don't really expect the maintainers to do this work themselves -- I'm filing to track a desirable thing that I may try to implement in the future.

anthrotype commented 2 years ago

thanks, that would be desirable indeed. I'm thinking this could be useful for https://github.com/google/fonts/issues/4405

skef commented 2 years ago

Thinking about this, I suppose what just testing for intersections would miss is a contour with the same direction entirely within another contour. There might be corner cases in VF instances where such a thing could happen in a production font. However, maybe its a small enough concern to be ignored.

behdad commented 4 months ago

Thinking about this, I suppose what just testing for intersections would miss is a contour with the same direction entirely within another contour. There might be corner cases in VF instances where such a thing could happen in a production font. However, maybe its a small enough concern to be ignored.

Yeah but I don't think those cases are problematic. So, fine with me.