[metapost] Feature Request: Get envelope of path stroked with arbitrary pen

mskala at ansuz.sooke.bc.ca mskala at ansuz.sooke.bc.ca
Fri Feb 9 01:36:59 CET 2018


On Thu, 8 Feb 2018, Kevin Keith wrote:
> It would be of immense use if it were possible to get the path of the
> outline of some arbitrary pen stroke.
> Since metapost already outputs bezier curves, instead of bitmaps, it would
> seem that the machinery to compute the envelope is already in place, so it
> shouldn't be too difficult to expose this as an operator in the language
> itself.

I agree this would be nice.  However, I don't think it's so easy to do.
METATYPE1 (used by the Latin Modern project and my own Tsukurimashou) has
an implementation in Metapost macros; it usually works, but requires
handholding, and when it fails it's difficult to debug.  FontForge also
has an implementation of a similar feature, which has always been buggy
and a cause of user complaints.  If it were to be a Metapost language
feature, I hope that the implementation would be at the standard of
quality and non-bugginess that we expect of "engine" code in the TeX
ecosystem - and I think algorithms to actually achieve that on the "expand
stroke" problem may be an open research problem.  Among other issues, the
envelope of a path defined by cubic splines is not itself a cubic spline,
so you need to do some approximation, and coming up with rules for how
close the approximation needs to be, that cover all cases, is difficult.

-- 
Matthew Skala
mskala at ansuz.sooke.bc.ca                 People before principles.
http://ansuz.sooke.bc.ca/


More information about the metapost mailing list