From: David Gow Date: Wed, 13 Aug 2014 13:38:56 +0000 (+0800) Subject: Support some more SVG stuff. X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=c1b5126edfd81846a0ecf19c6dcb9c0476df2196;p=ipdf%2Fcode.git Support some more SVG stuff. Can now get a dodgy, slightly hacked bit of gnuplot output to render. --- diff --git a/src/document.cpp b/src/document.cpp index 9cb5aa8..dab0868 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -540,9 +540,9 @@ void Document::ParseSVGPathData(const string & d, const SVGMatrix & transform) bool start = false; - static string delims("()[],{}<>;:=LlmMqQzZcC"); + static string delims("()[],{}<>;:=LlHhVvmMqQzZcC"); - while (i < d.size() && GetToken(d, token, i).size() > 0) + while (i < d.size() && GetToken(d, token, i, delims).size() > 0) { if (isalpha(token[0])) command = token; @@ -620,16 +620,32 @@ void Document::ParseSVGPathData(const string & d, const SVGMatrix & transform) } - else if (command == "l" || command == "L") + else if (command == "l" || command == "L" || command == "h" || command == "H" || command == "v" || command == "V") { Debug("Construct lineto command, relative %d", relative); Real dx = Real(strtod(GetToken(d,token,i,delims).c_str(),NULL)); - assert(GetToken(d,token,i,delims) == ","); - Real dy = Real(strtod(GetToken(d,token,i,delims).c_str(),NULL)); + Real dy; + if (command == "l" || command == "L") + { + assert(GetToken(d,token,i,delims) == ","); + dy = Real(strtod(GetToken(d,token,i,delims).c_str(),NULL)); + } + else if (command == "v" || command == "V") + { + swap(dx,dy); + } x[1] = (relative) ? x[0] + dx : dx; y[1] = (relative) ? y[0] + dy : dy; + if (command == "v" || command == "V") + { + x[1] = x[0]; + } + else if (command == "h" || command == "H") + { + y[1] = y[0]; + } Real x1(x[1]); Real y1(y[1]);