Draft: fix multiline offset for rotated SVG texts

Forum topic:
https://forum.freecad.org/viewtopic.php?p=711184#p711184
This commit is contained in:
Roy-043
2023-10-05 12:21:55 +02:00
committed by Yorik van Havre
parent 0a6c0cb224
commit 3395b2e2f6

View File

@@ -29,6 +29,7 @@
import math
import FreeCAD as App
import DraftVecUtils
import draftutils.utils as utils
## \addtogroup draftfunctions
@@ -48,6 +49,9 @@ def _get_text_techdraw(text, tcolor, fontsize, anchor,
"""
svg = ""
for i in range(len(text)):
delta = App.Vector(0, -i * linespacing, 0)
point = base + DraftVecUtils.rotate(delta, angle)
_t = text[i].replace("&", "&")
_t = _t.replace("<", "&lt;")
t = _t.replace(">", "&gt;")
@@ -60,10 +64,10 @@ def _get_text_techdraw(text, tcolor, fontsize, anchor,
svg += 'font-family:{}" '.format(fontname)
svg += 'transform="'
svg += 'rotate({},{},{}) '.format(math.degrees(angle),
base.x,
base.y - i * linespacing)
svg += 'translate({},{}) '.format(base.x,
base.y - i * linespacing)
point.x,
point.y)
svg += 'translate({},{}) '.format(point.x,
point.y)
svg += 'scale(1,-1)"'
# svg += 'freecad:skip="1"'
svg += '>\n'