mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
IfcText - spacing in multiline text now depends on text size #2833
This commit is contained in:
@@ -674,22 +674,28 @@ class SvgWriter:
|
|||||||
variables = {}
|
variables = {}
|
||||||
if product != None:
|
if product != None:
|
||||||
for variable in re.findall("{{.*?}}", literal):
|
for variable in re.findall("{{.*?}}", literal):
|
||||||
literal = literal.replace(variable, str(ifcopenshell.util.selector.get_element_value(product, variable[2:-2]) or ""))
|
literal = literal.replace(
|
||||||
|
variable,
|
||||||
|
str(ifcopenshell.util.selector.get_element_value(product, variable[2:-2]) or "")
|
||||||
|
)
|
||||||
|
|
||||||
|
text_tag = self.svg.text(
|
||||||
|
"",
|
||||||
|
class_=" ".join(self.get_attribute_classes(text_obj)),
|
||||||
|
**{
|
||||||
|
"text-anchor": text_anchor,
|
||||||
|
"alignment-baseline": alignment_baseline,
|
||||||
|
"dominant-baseline": alignment_baseline,
|
||||||
|
"transform": transform,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
self.svg.add(text_tag)
|
||||||
|
|
||||||
for line_number, text_line in enumerate(literal.replace("\\n", "\n").split("\n")):
|
for line_number, text_line in enumerate(literal.replace("\\n", "\n").split("\n")):
|
||||||
self.svg.add(
|
t_span = self.svg.tspan(text_line, insert=(text_position * self.svg_scale))
|
||||||
self.svg.text(
|
# doing it here and not in tspan constructor because it adds unnecessary spaces
|
||||||
text_line,
|
t_span.update({"dy": f"{line_number}em"})
|
||||||
insert=tuple((text_position * self.svg_scale) + Vector((0, 3.5 * line_number))),
|
text_tag.add(t_span)
|
||||||
class_=" ".join(self.get_attribute_classes(text_obj)),
|
|
||||||
**{
|
|
||||||
"text-anchor": text_anchor,
|
|
||||||
"alignment-baseline": alignment_baseline,
|
|
||||||
"dominant-baseline": alignment_baseline,
|
|
||||||
"transform": transform,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def draw_break_annotations(self, obj):
|
def draw_break_annotations(self, obj):
|
||||||
x_offset = self.raw_width / 2
|
x_offset = self.raw_width / 2
|
||||||
|
|||||||
Reference in New Issue
Block a user