diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2021-03-04 18:40:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-04 18:40:53 +0100 |
| commit | e84a86d4ac0caf29d6074728376ff0a594243fec (patch) | |
| tree | 888c79ed0094ba2916a1d329861a85515959913c /lib/lettering/glyph.py | |
| parent | b39575a50191307b3b56eab6455626398eec6397 (diff) | |
Update for Inkscape 1.0 (#880)
* update for inkscape 1.0
* add about extension
* Build improvements for the inkscape1.0 branch (#985)
* zip: export real svg not stitch plan
* #411 and #726
* Tools for Font Creators (#1018)
* ignore very small holes in fills
* remove embroider (#1026)
* auto_fill: ignore shrink_or_grow if result is empty (#589)
* break apart: do not ignore small fills
Co-authored-by: Hagen Fritsch <rumpeltux-github@irgendwo.org>
Co-authored-by: Lex Neva <github.com@lexneva.name>
Diffstat (limited to 'lib/lettering/glyph.py')
| -rw-r--r-- | lib/lettering/glyph.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/lettering/glyph.py b/lib/lettering/glyph.py index 061a930c..84517474 100644 --- a/lib/lettering/glyph.py +++ b/lib/lettering/glyph.py @@ -1,9 +1,9 @@ from copy import copy -import cubicsuperpath -import simpletransform +from inkex import paths, transforms -from ..svg import apply_transforms, get_guides +from ..svg import get_guides +from ..svg.path import get_correction_transform from ..svg.tags import SVG_GROUP_TAG, SVG_PATH_TAG @@ -37,8 +37,9 @@ class Glyph(object): def _process_group(self, group): new_group = copy(group) - new_group.attrib.pop('transform', None) - del new_group[:] # delete references to the original group's children + # new_group.attrib.pop('transform', None) + # delete references to the original group's children + del new_group[:] for node in group: if node.tag == SVG_GROUP_TAG: @@ -47,11 +48,9 @@ class Glyph(object): node_copy = copy(node) if "d" in node.attrib: - # Convert the path to absolute coordinates, incorporating all - # nested transforms. - path = cubicsuperpath.parsePath(node.get("d")) - apply_transforms(path, node) - node_copy.set("d", cubicsuperpath.formatPath(path)) + transform = -transforms.Transform(get_correction_transform(node, True)) + path = paths.Path(node.get("d")).transform(transform).to_absolute() + node_copy.set("d", str(path)) # Delete transforms from paths and groups, since we applied # them to the paths already. @@ -71,16 +70,18 @@ class Glyph(object): self.baseline = 0 def _process_bbox(self): - left, right, top, bottom = simpletransform.computeBBox(self.node.iterdescendants()) - + bbox = [paths.Path(node.get("d")).bounding_box() for node in self.node.iterdescendants(SVG_PATH_TAG)] + left, right = min([box.left for box in bbox]), max([box.right for box in bbox]) self.width = right - left self.min_x = left def _move_to_origin(self): translate_x = -self.min_x translate_y = -self.baseline - transform = "translate(%s, %s)" % (translate_x, translate_y) + transform = transforms.Transform("translate(%s, %s)" % (translate_x, translate_y)) for node in self.node.iter(SVG_PATH_TAG): - node.set('transform', transform) - simpletransform.fuseTransform(node) + path = paths.Path(node.get("d")) + path = path.transform(transform) + node.set('d', str(path)) + node.attrib.pop('transform', None) |
