summaryrefslogtreecommitdiff
path: root/lib/extensions/palette_split_text.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-06-30 22:49:18 +0200
committerGitHub <noreply@github.com>2024-06-30 22:49:18 +0200
commite52886a64a4e76c3fdc49df95c85655da3c4f7f4 (patch)
tree88a4edee630df0947553ced79fb6eb9dc510ccea /lib/extensions/palette_split_text.py
parent7c06dee44ac7951a5db406eb829100a5bc3e5887 (diff)
Various fixes (#3028)
* several thread palette extension fixes * fix svg tartan when original shape is invalid * tartan stroke spaces * style * fix tartan color substituion at pattern start * ripple: do not render too small paths * use less space for params warning headline * fix clone shape path * zip export template fix (typo) * add realistic stitch plan output warning (help tab)
Diffstat (limited to 'lib/extensions/palette_split_text.py')
-rw-r--r--lib/extensions/palette_split_text.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/extensions/palette_split_text.py b/lib/extensions/palette_split_text.py
index 19b70782..67549f4f 100644
--- a/lib/extensions/palette_split_text.py
+++ b/lib/extensions/palette_split_text.py
@@ -3,10 +3,13 @@
# Copyright (c) 2022 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+from tempfile import TemporaryDirectory
+
import inkex
from ..i18n import _
from .base import InkstitchExtension
+from .utils.inkex_command import inkscape
class PaletteSplitText(InkstitchExtension):
@@ -30,7 +33,14 @@ class PaletteSplitText(InkstitchExtension):
transform = text.transform
text.pop('transform')
- bbox = text.get_inkscape_bbox()
+ # the inkex command `bbox = text.get_inkscape_bbox()` is causing problems for our pyinstaller bundled
+ # releases, this code block is taken from inkex/elements/_text
+ with TemporaryDirectory(prefix="inkscape-command") as tmpdir:
+ svg_file = inkex.command.write_svg(text.root, tmpdir, "input.svg")
+ bbox = inkscape(svg_file, "-X", "-Y", "-W", "-H", query_id=text.get_id())
+ bbox = list(map(text.root.viewport_to_unit, bbox.splitlines()))
+ bbox = inkex.BoundingBox.new_xywh(*bbox[1:])
+
x = bbox.left
y = bbox.bottom
height = bbox.height / (len(lines))