[svgPathPen] Document coordinate system

Fixes https://github.com/fonttools/fonttools/issues/2388
This commit is contained in:
Behdad Esfahbod 2022-08-20 11:00:34 -06:00
parent 82a523cc17
commit 5674a0bfc8

View File

@ -23,6 +23,18 @@ class SVGPathPen(BasePen):
used to resolve component references in composite glyphs. used to resolve component references in composite glyphs.
ntos: a callable that takes a number and returns a string, to ntos: a callable that takes a number and returns a string, to
customize how numbers are formatted (default: str). customize how numbers are formatted (default: str).
Note:
Fonts have a coordinate system where Y grows up, whereas in SVG,
Y grows down. As such, rendering path data from this pen in
SVG typically results in upside-down glyphs. You can fix this
by wrapping the data from this pen in an SVG group element with
transform, or wrap this pen in a transform pen. For example:
spen = svgPathPen.SVGPathPen(glyphset)
pen= TransformPen(spen , (1, 0, 0, -1, 0, 0))
glyphset[glyphname].draw(pen)
print(tpen.getCommands())
""" """
def __init__(self, glyphSet, ntos: Callable[[float], str] = str): def __init__(self, glyphSet, ntos: Callable[[float], str] = str):
BasePen.__init__(self, glyphSet) BasePen.__init__(self, glyphSet)