From 46fa3e99a49b47c18836d44d806971192907c304 Mon Sep 17 00:00:00 2001 From: David Gow Date: Thu, 7 Aug 2014 21:40:33 +0800 Subject: [PATCH 1/1] Fix SVG rendering of glyphs.svg - Convert Quadratics -> Cubics properly - Correctly handle relative movements in LineTo. --- src/document.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index d4d8eac..a4b20d0 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -437,6 +437,11 @@ void Document::AddPathFromString(const string & d, const Rect & bounds) { x[3] = x[2]; y[3] = y[2]; + Real old_x1(x[1]), old_y1(y[1]); + x[1] = x[0] + Real(2) * (old_x1 - x[0])/ Real(3); + y[1] = y[0] + Real(2) * (old_y1 - y[0])/ Real(3); + x[2] = x[3] + Real(2) * (old_x1 - x[3])/ Real(3); + y[2] = y[3] + Real(2) * (old_y1 - y[3])/ Real(3); } unsigned index = AddBezierData(Bezier(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3])); @@ -458,8 +463,8 @@ void Document::AddPathFromString(const string & d, const Rect & bounds) assert(GetToken(d,token,i) == ","); Real dy = strtod(GetToken(d,token,i).c_str(),NULL) / bounds.h; - x[1] = (relative) ? x0 + dx : dx; - y[1] = (relative) ? y0 + dy : dy; + x[1] = (relative) ? x[0] + dx : dx; + y[1] = (relative) ? y[0] + dy : dy; x[2] = x[1]; y[2] = y[1]; -- 2.20.1