bodoni / svg

Composer and parser for SVG
Other
302 stars 44 forks source link

How does one add Text? #47

Closed russelldb closed 3 years ago

russelldb commented 3 years ago

Sorry this isn't really an issue (or it's a documentation issue?) but I can't figure out how to use the Text Node to actually add text to a document. Can you help, please?

russelldb commented 3 years ago

I figured it out.

There are element::Text and node::Text and the latter is the text that is the value for the former.

lukepighetti commented 2 years ago

Can you please provide a code sample? I'm trying to figure this out and I'm not fully understanding your closing comment.

casperlamboo commented 1 year ago

For future reference if someone has the same question as @lukepighetti, here is a small example.

let mut node = svg::node::element::Text::new();
node.assign("x", 100.0);
node.assign("y", 100.0);
node.append(svg::node::Text::new("hello world"));