Closed 9110vlado closed 6 years ago
According to the SVG Specification
The only allowable decimal point is a Unicode U+0046 FULL STOP (".") character (also referred to in Unicode as PERIOD, dot and decimal point) and no other delimiter characters are allowed [UNICODE]. (For example, the following is an invalid numeric value in a path data stream: "13,000.56". Instead, say: "13000.56".)
So, to conform to this, the parser internally uses Regular Expressions which expect the dot character as the decimal separator.
I'm not fully sure if your workaround will work. However, you can use a similar workaround while constructing the pathData i.e. when you convert numbers to string format.
There is not problem with the SVG path, but there is problem with the CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator which is in my case ",". This decimal separator is used when the SVG path is parsed.
E. g.:
M 12,9.5
// MoveTo x:12, y:9.5CurrentCulture
is taken from the OS, in my case it is Slovak culture which decimal separator is ","Single.TryParse(match.Groups["Y"].Value, out _y)
[MoveToElement.cs, line: 131], parsing will fail and _y
variable remains 0.So my workaround temporarily set English culture which has decimal separator ".".
Fix in your code is really simple. You only change Single.TryParse
to the other overload which uses IFormatProvider
interface:
public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out float result)
E.g.: Single.TryParse(match.Groups["Y"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out _y);
I get your point. Thanks a lot. The fix will be included in the next update.
@9110vlado
This has been fixed in v0.8 release.
Hello,
Thank you, it is a great library, but I have found an issue when SVG path is parsed to CanvasGeometry. When CurrentCulture has other decimal separator than "." (e. g. ",") SVG path is not parsed correctly.
My workaround is: CultureInfo currentCulture = CultureInfo.CurrentCulture; CanvasGeometry icon = null;