Copied and slightly adapted from: https://github.com/typesupply/ufo2svg/blob/master/Lib/ufo2svg/svgPathPen.py