Skip to content

Commit a2d4905

Browse files
committed
PathParser: fix handling of a second decimal while parsing a float (closes #71)
A float can contain only one decimal, so this should be considered the start of a new float.
1 parent 1a78d7b commit a2d4905

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

format/svg/PathParser.hx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,34 @@ class PathParser {
9595
var code = ch<0 || ch>127 ? UNKNOWN :sCommandArgs[ch];
9696
if (code>FLOAT )
9797
break;
98-
if (code==FLOAT_DOT && seen_dot)
99-
break;
98+
if (code==FLOAT_DOT)
99+
{
100+
if (seen_dot) {
101+
// a second dot indicates the start of a new float
102+
break;
103+
}
104+
seen_dot = true;
105+
}
100106
if (e_pos>=0)
101107
{
102108
if (code==FLOAT_SIGN)
103109
{
104-
if (e_pos!=0)
105-
break;
110+
if (e_pos!=0)
111+
break;
106112
}
107113
else if (code!=FLOAT)
108-
break;
114+
break;
109115
e_pos++;
110116
}
111117
else if (code==FLOAT_EXP)
112118
{
113119
if (e_pos>=0)
114-
break;
120+
break;
115121
e_pos = 0;
116122
seen_dot = true;
117123
}
118124
else if (code==FLOAT_SIGN)
119-
break;
125+
break;
120126
end++;
121127
}
122128
if (current_command<0)
3.34 KB
Loading
Lines changed: 3 additions & 0 deletions
Loading

test/src/SvgGenerationTest.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ class SvgGenerationTest extends Test
6666
generateAndCompare("arc-radius-too-small.svg");
6767
}
6868

69+
public function testPathWithTwoFloatDecimals()
70+
{
71+
generateAndCompare("path-two-float-decimals.svg");
72+
}
73+
6974
public function testFancySunIconRendersCorrectly()
7075
{
7176
generateAndCompare("fancy-sun.svg");

0 commit comments

Comments
 (0)