Fix handling of [Ss] command’s control point calculation

This commit is contained in:
Christopher Kohnert 2017-06-09 11:04:23 -07:00
parent c2ab38d9e5
commit 5827e10bdd
1 changed files with 10 additions and 5 deletions

View File

@ -139,15 +139,16 @@ static bool buildFromPath(Shape &shape, const char *pathDef, double size) {
char nodeType;
Point2 prevNode(0, 0);
bool nodeTypePreread = false;
Point2 startPoint;
Point2 controlPoint[2];
Point2 node;
char prevNodeType = '\0';
while (nodeTypePreread || readNodeType(nodeType, pathDef)) {
nodeTypePreread = false;
Contour &contour = shape.addContour();
bool contourStart = true;
Point2 startPoint;
Point2 controlPoint[2];
Point2 node;
while (*pathDef) {
switch (nodeType) {
case 'M': case 'm':
@ -213,6 +214,9 @@ static bool buildFromPath(Shape &shape, const char *pathDef, double size) {
contour.addEdge(new CubicSegment(prevNode, controlPoint[0], controlPoint[1], node));
break;
case 'S': case 's':
if (prevNodeType != 'c' && prevNodeType != 'C' && prevNodeType != 's' && prevNodeType != 'S')
controlPoint[0] = node;
else
controlPoint[0] = node+node-controlPoint[1];
REQUIRE(readCoord(controlPoint[1], pathDef));
consumeOptionalComma(pathDef);
@ -260,6 +264,7 @@ static bool buildFromPath(Shape &shape, const char *pathDef, double size) {
else
contour.addEdge(new LinearSegment(prevNode, startPoint));
}
prevNodeType = nodeType;
prevNode = startPoint;
}
return true;