Calculate the total coverage of an irregular polygon shape in InDesign
Written by Marc Autret. The source is here. Works only if splines do not auto-intersect.
In case your splines do not auto-intersect, the following image shall illustrate the problem:
The SplineItem is made of two path points whose tangents are strictly opposed (so the shape crosses itself.) Since the algorithm relies on an algebraic calculation of area elements along a closed path, it concludes that the entire area is zero. You may think that considering the absolute value of each sub-calculation and adding all these values would solve the problem, but this would simply destroy the integration routine. In integral terms the area above is actually zero — although that's obviously not what the user expects to be returned!
Click here to download the snippet.