Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TitleEditor: Support SVG contain tspan element without style attribute #4781

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/windows/title_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def load_svg_template(self, filename_field=None):
title_text.append(text)

# Set font size (for possible font dialog)
s = node.attributes["style"].value
s = node.getAttribute("style")
ard = style_to_dict(s)
fs = ard.get("font-size")
if fs and fs.endswith("px"):
Expand Down Expand Up @@ -451,7 +451,7 @@ def update_font_color_button(self):
for node in self.text_nodes + self.tspan_nodes:

# Get the value in the style attribute and turn into a dict
s = node.attributes["style"].value
s = node.getAttribute("style")
ard = style_to_dict(s)
# Get fill color or default to white
color = ard.get("fill", "#FFF")
Expand Down Expand Up @@ -495,7 +495,7 @@ def get_ref_color(self, id):
for stop_node in ref_node.childNodes:
if stop_node.nodeName == "stop":
# get color from stop
ard = style_to_dict(stop_node.attributes["style"].value)
ard = style_to_dict(stop_node.getAttribute("style"))
if "stop-color" in ard:
return ard.get("stop-color")
return ""
Expand All @@ -505,7 +505,7 @@ def update_background_color_button(self):

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

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

if self.rect_node:
# Turn the style attribute into a dict for modification
s = self.rect_node[0].attributes["style"].value
s = self.rect_node[0].getAttribute("style")
ard = style_to_dict(s)
ard.update({
"fill": color,
Expand All @@ -564,7 +564,7 @@ def set_font_color_elements(self, color, alpha):
# Loop through each TEXT element
for text_child in self.text_nodes + self.tspan_nodes:
# SET TEXT PROPERTIES
s = text_child.attributes["style"].value
s = text_child.getAttribute("style")
ard = style_to_dict(s)
ard.update({
"fill": color,
Expand Down