diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2018-11-14 20:23:06 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-14 20:23:06 -0500 |
| commit | f5c85183d9c874fca806917e50992daea4101496 (patch) | |
| tree | a2450e2e37a7d94625a917240e78eadc939fd65b /lib/svg/path.py | |
| parent | 238ad843dd658de6c7afd5b8697c0e080b1cf965 (diff) | |
basic lettering (#344)
Can handle multiple lines of text and routes the stitching in alternating directions on each line.
Diffstat (limited to 'lib/svg/path.py')
| -rw-r--r-- | lib/svg/path.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/svg/path.py b/lib/svg/path.py index 6212211f..d2b4aee1 100644 --- a/lib/svg/path.py +++ b/lib/svg/path.py @@ -1,3 +1,4 @@ +import inkex import simpletransform from .units import get_viewbox_transform @@ -12,6 +13,19 @@ def apply_transforms(path, node): return path +def compose_parent_transforms(node, mat): + # This is adapted from Inkscape's simpletransform.py's composeParents() + # function. That one can't handle nodes that are detached from a DOM. + + trans = node.get('transform') + if trans: + mat = simpletransform.composeTransform(simpletransform.parseTransform(trans), mat) + if node.getparent() is not None: + if node.getparent().tag == inkex.addNS('g', 'svg'): + mat = compose_parent_transforms(node.getparent(), mat) + return mat + + def get_node_transform(node): # start with the identity transform transform = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]] @@ -19,7 +33,7 @@ def get_node_transform(node): # this if is because sometimes inkscape likes to create paths outside of a layer?! if node.getparent() is not None: # combine this node's transform with all parent groups' transforms - transform = simpletransform.composeParents(node, transform) + transform = compose_parent_transforms(node, transform) # add in the transform implied by the viewBox viewbox_transform = get_viewbox_transform(node.getroottree().getroot()) |
