Fix an error when importing old topology without color for label

Fix #736
This commit is contained in:
Julien Duponchelle 2016-10-24 14:58:14 +02:00
parent ac1eef256f
commit 10e7b32409
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 3 additions and 1 deletions

View File

@ -431,7 +431,7 @@ def _convert_label(label):
"""
Convert a label from 1.X to the new format
"""
style = qt_font_to_style(label.get("font"), label["color"])
style = qt_font_to_style(label.get("font"), label.get("color"))
return {
"text": label["text"],
"rotation": 0,

View File

@ -33,6 +33,8 @@ def qt_font_to_style(font, color):
if font_info[5] == "1":
style += "font-style: italic;"
if color is None:
color = "000000"
if len(color) == 9:
style += "fill: #" + color[-6:] + ";"
style += "fill-opacity: {};".format(round(1.0 / 255 * int(color[:3][-2:], base=16), 2))