summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2015-03-14 02:36:53 +0100
committerMichael Schwarz <michi.schwarz@gmail.com>2015-03-15 12:12:01 +0100
commitb81d25712705661f7bab95252ff9cae97a9f4b37 (patch)
treec958ae8ce629bfe06921de6b09bcdfb153f566ec
parente03689f0ffab49baea0d0ebd667ae8a9438dfa3f (diff)
downloadpogojig-b81d25712705661f7bab95252ff9cae97a9f4b37.tar.gz
pogojig-b81d25712705661f7bab95252ff9cae97a9f4b37.tar.bz2
pogojig-b81d25712705661f7bab95252ff9cae97a9f4b37.zip
Fixed text on path export.
This fixes exporting SVG files which contain text on a path where the path is on a different layer than the text (which is necessary unless the path should also be combined with the text in a single layer).
-rw-r--r--support/dxf_export/__main__.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/support/dxf_export/__main__.py b/support/dxf_export/__main__.py
index c770a0e..22af532 100644
--- a/support/dxf_export/__main__.py
+++ b/support/dxf_export/__main__.py
@@ -38,16 +38,18 @@ def _unfuck_svg_document(temp_svg_path):
"""
layers_count = _get_inkscape_layer_count(temp_svg_path)
-
+
def iter_inkscape_verbs():
yield 'LayerUnlockAll'
yield 'LayerShowAll'
- # Go to the first layer
+ # Go to the first layer.
for _ in range(layers_count):
yield 'LayerPrev'
-
+
+ # Copy each layer and flatten it to a single path object.
for _ in range(layers_count):
+ yield 'LayerDuplicate'
yield 'EditSelectAll'
yield 'ObjectToPath'
yield 'EditSelectAll'
@@ -57,11 +59,26 @@ def _unfuck_svg_document(temp_svg_path):
yield 'EditSelectAll'
yield 'SelectionUnion'
yield 'LayerNext'
-
+
+ # Go to the first layer again.
+ for _ in range(2 * layers_count):
+ yield 'LayerPrev'
+
+ # Move the flattened shapes to the original layers.
+ for _ in range(layers_count):
+ yield 'EditSelectAll'
+ yield 'EditDelete'
+ yield 'LayerNext'
+
+ yield 'EditSelectAll'
+ yield 'LayerMoveToPrev'
+ yield 'LayerNext'
+ yield 'LayerDelete'
+
yield 'FileSave'
yield 'FileClose'
yield 'FileQuit'
-
+
_inkscape(temp_svg_path, list(iter_inkscape_verbs()))
@@ -70,7 +87,7 @@ def main(in_path, out_path):
temp_svg_path = os.path.join(temp_dir, 'temp.svg')
shutil.copyfile(in_path, temp_svg_path)
-
+
_unfuck_svg_document(temp_svg_path)
_export_dxf(temp_svg_path, out_path)