mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 14:31:39 +00:00
fill-bg for text instead of the entire symbol by default #3594
Before - https://i.imgur.com/OsQycgW.png After - https://i.imgur.com/rZvXIoT.png
This commit is contained in:
@@ -774,11 +774,14 @@ class SvgWriter:
|
|||||||
"text-anchor": text_anchor,
|
"text-anchor": text_anchor,
|
||||||
}
|
}
|
||||||
|
|
||||||
def add_fill_bg(self, element):
|
def add_fill_bg(self, element, copy=True):
|
||||||
element = element.copy()
|
if copy:
|
||||||
|
element = element.copy()
|
||||||
if hasattr(element, "xml"):
|
if hasattr(element, "xml"):
|
||||||
attrib = element.xml.attrib
|
attrib = element.xml.attrib
|
||||||
else:
|
elif isinstance(element, ET.Element):
|
||||||
|
attrib = element.attrib
|
||||||
|
else: # assuming it's svgwrite.base.BaseElement
|
||||||
attrib = element.attribs
|
attrib = element.attribs
|
||||||
attrib["filter"] = "url(#fill-background)"
|
attrib["filter"] = "url(#fill-background)"
|
||||||
return element
|
return element
|
||||||
@@ -831,7 +834,12 @@ class SvgWriter:
|
|||||||
field.attrib["class"] = classes_str
|
field.attrib["class"] = classes_str
|
||||||
|
|
||||||
if fill_bg:
|
if fill_bg:
|
||||||
self.svg.add(self.add_fill_bg(symbol_svg))
|
symbol_copied = symbol_svg.copy()
|
||||||
|
for text_tag in symbol_copied.xml.findall("text"):
|
||||||
|
self.add_fill_bg(text_tag, copy=False)
|
||||||
|
# NOTE: in case we'll later need to add fill-bg for the entire symbol:
|
||||||
|
# self.add_fill_bg(symbol_svg, copy=False)
|
||||||
|
self.svg.add(symbol_copied)
|
||||||
self.svg.add(symbol_svg)
|
self.svg.add(symbol_svg)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user