Commit b0030e1a authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Bugfixes:

- Fixed RuntimeError when clearing items from ViewBox
- SVG exporter adds generic font-family names to text items
parent f32a04a4
......@@ -17,6 +17,9 @@ class SVGExporter(Exporter):
self.params = Parameter(name='params', type='group', children=[
#{'name': 'width', 'type': 'float', 'value': tr.width(), 'limits': (0, None)},
#{'name': 'height', 'type': 'float', 'value': tr.height(), 'limits': (0, None)},
#{'name': 'viewbox clipping', 'type': 'bool', 'value': True},
#{'name': 'normalize coordinates', 'type': 'bool', 'value': True},
#{'name': 'normalize line width', 'type': 'bool', 'value': True},
])
#self.params.param('width').sigValueChanged.connect(self.widthChanged)
#self.params.param('height').sigValueChanged.connect(self.heightChanged)
......@@ -335,6 +338,18 @@ def correctCoordinates(node, item):
#fs = (fs**2).sum()**0.5
#ch.setAttribute('font-size', str(fs))
## Correct some font information
families = ch.getAttribute('font-family').split(',')
if len(families) == 1:
font = QtGui.QFont(families[0].strip('" '))
if font.style() == font.SansSerif:
families.append('sans-serif')
elif font.style() == font.Serif:
families.append('serif')
elif font.style() == font.Courier:
families.append('monospace')
ch.setAttribute('font-family', ', '.join([f if ' ' not in f else '"%s"'%f for f in families]))
## correct line widths if needed
if removeTransform and ch.getAttribute('vector-effect') != 'non-scaling-stroke':
w = float(grp.getAttribute('stroke-width'))
......
......@@ -63,7 +63,10 @@ class GraphicsItem(object):
if self._viewBox is None:
p = self
while True:
p = p.parentItem()
try:
p = p.parentItem()
except RuntimeError: ## sometimes happens as items are being removed from a scene and collected.
return None
if p is None:
vb = self.getViewWidget()
if vb is None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment