mirror of https://github.com/Chlumsky/msdfgen.git
Fix handling of [Ss] command’s control point calculation
This commit is contained in:
parent
c2ab38d9e5
commit
5827e10bdd
|
|
@ -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,7 +214,10 @@ 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':
|
||||
controlPoint[0] = node+node-controlPoint[1];
|
||||
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);
|
||||
REQUIRE(readCoord(node, 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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue