From: Sam Moore Date: Tue, 12 Aug 2014 07:14:40 +0000 (+0800) Subject: SVG text and line elements X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=4166b2c124b0bc652e9f8e5245488cdd2b86ebf0;p=ipdf%2Fcode.git SVG text and line elements Totally not done properly but whatever --- diff --git a/src/document.cpp b/src/document.cpp index fe3482f..f23b406 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -291,6 +291,15 @@ void Document::ParseSVGNode(pugi::xml_node & root, const Rect & bounds, Real & w Debug("Path data attribute is \"%s\"", d.c_str()); ParseSVGPathData(d, Rect(bounds.x,bounds.y,width,height)); } + else if (strcmp(child.name(), "line") == 0) + { + Real x0(child.attribute("x1").as_float()/width + bounds.x); + Real y0(child.attribute("y1").as_float()/height + bounds.y); + Real x1(child.attribute("x2").as_float()/width + bounds.x); + Real y1(child.attribute("y2").as_float()/height + bounds.y); + unsigned index = AddBezierData(Bezier(x0,y0,x1,y1,x1,y1,x1,y1)); + Add(BEZIER, Rect(0,0,1,1), index); + } else if (strcmp(child.name(), "rect") == 0) { Real coords[4]; @@ -316,6 +325,13 @@ void Document::ParseSVGNode(pugi::xml_node & root, const Rect & bounds, Real & w Add(CIRCLE_FILLED, rect,0); Debug("Added Circle %s", rect.Str().c_str()); } + else if (strcmp(child.name(), "text") == 0) + { + Real x = child.attribute("x").as_float()/width + bounds.x; + Real y = child.attribute("y").as_float()/height + bounds.y; + Debug("Add text \"%s\"", child.child_value()); + AddText(child.child_value(), 0.05, x, y); + } } }