Skip to content

Commit 006a2ee

Browse files
authored
TitleEditor: Support SVG contain tspan without style attr. (#4781)
Use Element#getAttribute method to get style attribute.
1 parent 627b2e1 commit 006a2ee

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/windows/title_editor.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def load_svg_template(self, filename_field=None):
297297
title_text.append(text)
298298

299299
# Set font size (for possible font dialog)
300-
s = node.attributes["style"].value
300+
s = node.getAttribute("style")
301301
ard = style_to_dict(s)
302302
fs = ard.get("font-size")
303303
if fs and fs.endswith("px"):
@@ -459,7 +459,7 @@ def update_font_color_button(self):
459459
for node in self.text_nodes + self.tspan_nodes:
460460

461461
# Get the value in the style attribute and turn into a dict
462-
s = node.attributes["style"].value
462+
s = node.getAttribute("style")
463463
ard = style_to_dict(s)
464464
# Get fill color or default to white
465465
color = ard.get("fill", "#FFF")
@@ -503,7 +503,7 @@ def get_ref_color(self, id):
503503
for stop_node in ref_node.childNodes:
504504
if stop_node.nodeName == "stop":
505505
# get color from stop
506-
ard = style_to_dict(stop_node.attributes["style"].value)
506+
ard = style_to_dict(stop_node.getAttribute("style"))
507507
if "stop-color" in ard:
508508
return ard.get("stop-color")
509509
return ""
@@ -513,7 +513,7 @@ def update_background_color_button(self):
513513

514514
if self.rect_node:
515515
# All backgrounds should be the first (index 0) rect tag in the svg
516-
s = self.rect_node[0].attributes["style"].value
516+
s = self.rect_node[0].getAttribute("style")
517517
ard = style_to_dict(s)
518518

519519
# Get fill color or default to black + full opacity
@@ -538,7 +538,7 @@ def set_font_style(self):
538538
# Loop through each TEXT element
539539
for text_child in self.text_nodes + self.tspan_nodes:
540540
# set the style elements for the main text node
541-
s = text_child.attributes["style"].value
541+
s = text_child.getAttribute("style")
542542
ard = style_to_dict(s)
543543
set_if_existing(ard, "font-style", self.font_style)
544544
set_if_existing(ard, "font-family", f"'{self.font_family}'")
@@ -557,7 +557,7 @@ def set_bg_style(self, color, alpha):
557557

558558
if self.rect_node:
559559
# Turn the style attribute into a dict for modification
560-
s = self.rect_node[0].attributes["style"].value
560+
s = self.rect_node[0].getAttribute("style")
561561
ard = style_to_dict(s)
562562
ard.update({
563563
"fill": color,
@@ -572,7 +572,7 @@ def set_font_color_elements(self, color, alpha):
572572
# Loop through each TEXT element
573573
for text_child in self.text_nodes + self.tspan_nodes:
574574
# SET TEXT PROPERTIES
575-
s = text_child.attributes["style"].value
575+
s = text_child.getAttribute("style")
576576
ard = style_to_dict(s)
577577
ard.update({
578578
"fill": color,

0 commit comments

Comments
 (0)