TextAlignment is the vertical alignment, while Justification is the
horizontal alignment. here, get_text was passed the vertical, while it
expected the horizontal. This caused the alignment of a Label to be
wrong in the resulting SVG (e.g. in a TechDraw draft view).
This seems to have been broken since SVG support for Labels was first
introduced in commit 3391a5ea4b (Initial work, only text (no lines)).
Label objects would produce invalid SVG XML, because the stroke-linecap
property was added as if it was a style (with : and ;), but it was
inserted in the XML tag directly, rather than inside the style attribute
value. The invalid SVG prevented for example a TechDraw draft view from
rendering when it contained a label.
This was added in commit d8c74c06fd (Draft: Using square endcaps for
lines in SVG output).
This stroke-linecap is supported both as a presentation attribute inside
the style or a XML attribute, so for consistency with the surrounding
attributes, it is made a normal attribute, rather than putting it inside
the style.
See also https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap
An AttributeError is raised when `direction=Vector(0,0,0)` and obj is
an Arch::Space on line: bead9bb938/src/Mod/Draft/draftfunctions/svg.py (L799)
This patch checks if early on if the direction vector and raises a
ValueError with a description of what has gone wrong.
A caveat with this solution is that this new behaviour might break old
code which depends on that invalid directions can be used.
The name of the argument, `projection`, in the old function
is incorrect; it should be `direction`, which was the original
argument's name when this method was split into its own module
(c79f890).
If it's not a circle nor ellipse nor straight line
convert the curve to BSpline. Move into a subfunction.
Improve a few varible names to be more verbose, like `vertex`
and `edge`.
The angle between the curve and plane is tested for being coplanar,
0 or 180 degrees. The negative test is done earlier so that the
return is done earlier, and the rest of the code is not indented.
For the try-except blocks we should trap a specific `Exception`,
not just any type. It seems string handling was an issue
with Python 2, so the string needed UTF8 decoding.
When the software no longer supports Python 2, these
blocks can be removed.