def test_subelement_tspan(self): txt = TextPath('#test', 'text') txt.add(TSpan('subtext')) self.assertEqual( txt.tostring(), '<textPath xlink:href="#test">text<tspan>subtext</tspan></textPath>' )
def test_constructor(self): tref = TextPath('#test', 'The Text', startOffset=10, spacing='auto', method='stretch') self.assertEqual(tref.tostring(), '<textPath method="stretch" spacing="auto"' \ ' startOffset="10" xlink:href="#test">The Text</textPath>')
def draw_name(drawing, x, y, node): name = getattr(node, "name", None) if name is not None: drawing.add( Text(name, insert=(x, y + NODE_RADIUS + SCALE), text_anchor="middle")) if EXPERIMENTAL: (start, end) = calc.calc_text_path(x, y) text_anchor = "text-anchor: start" if start[0] < WIDTH / 2: tmp = start start = end end = tmp text_anchor = "text-anchor: end" path_string = "M {} {} L {} {}".format(start[0], start[1], end[0], end[1]) p = Path(d=path_string) tp = TextPath(path=p, text=name, style=text_anchor) # TextPath has to be child of Text text = svgwrite.text.Text("") text.add(tp) drawing.add(p) drawing.add(text)
def test_subelement_tspan(self): txt = TextPath('#test', 'text') txt.add(TSpan('subtext')) self.assertEqual(txt.tostring(), '<textPath xlink:href="#test">text<tspan>subtext</tspan></textPath>')