mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Fixed top and center alignment in the schedule
Solves #3599 Before - https://i.imgur.com/9s7MxH5.png After - https://i.imgur.com/ojDj09G.png Inkscape - https://i.imgur.com/pWF4Ouy.png
This commit is contained in:
@@ -402,12 +402,27 @@ class Scheduler:
|
|||||||
else:
|
else:
|
||||||
wrapped_lines = text_lines
|
wrapped_lines = text_lines
|
||||||
|
|
||||||
for line_number, text_line in enumerate(wrapped_lines[::-1]):
|
if box_alignment.startswith("top"):
|
||||||
|
dy_dir = 1
|
||||||
|
line_number = 0
|
||||||
|
elif box_alignment.startswith("bot"):
|
||||||
|
dy_dir = -1
|
||||||
|
line_number = 0
|
||||||
|
else: # middle row
|
||||||
|
# the idea is that the middle row should always stay in the center
|
||||||
|
# e.g. dy offset for 3 lines is: 1, 0, -1
|
||||||
|
# for 2 lines: 0.5, -0.5
|
||||||
|
dy_dir = -1
|
||||||
|
line_number = (len(wrapped_lines) - 1) / 2
|
||||||
|
|
||||||
|
for text_line in wrapped_lines[::dy_dir]:
|
||||||
# position has to be inserted at tspan to avoid x offset between tspans
|
# position has to be inserted at tspan to avoid x offset between tspans
|
||||||
tspan = self.svg.tspan(text_line, insert=(x, y), **text_params)
|
tspan = self.svg.tspan(text_line, insert=(x, y), **text_params)
|
||||||
# doing it here and not in tspan constructor because constructor adds unnecessary spaces
|
# doing it here and not in tspan constructor because constructor adds unnecessary spaces
|
||||||
tspan.update({"dy": f"-{line_number}em"})
|
tspan.update({"dy": f"{line_number}em"})
|
||||||
text_tag.add(tspan)
|
text_tag.add(tspan)
|
||||||
|
line_number += dy_dir
|
||||||
|
|
||||||
self.svg.add(text_tag)
|
self.svg.add(text_tag)
|
||||||
|
|
||||||
def convert_to_mm(self, value):
|
def convert_to_mm(self, value):
|
||||||
|
|||||||
Reference in New Issue
Block a user