1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-09-11 05:05:23 +03:00

Merge pull request #687 from aapng/scientific-notation-parsing

Fix polyline and polygon points parsing
This commit is contained in:
Yuri Strot 2020-05-14 15:27:35 +07:00 committed by GitHub
commit c7c78266fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -986,15 +986,14 @@ open class SVGParser {
fileprivate func parsePoints(_ pointsString: String) -> [Double] { fileprivate func parsePoints(_ pointsString: String) -> [Double] {
var resultPoints: [Double] = [] var resultPoints: [Double] = []
let pointPairs = pointsString.replacingOccurrences(of: "-", with: " -").components(separatedBy: " ")
pointPairs.forEach { pointPair in let scanner = Scanner(string: pointsString)
let points = pointPair.components(separatedBy: ",") while !scanner.isAtEnd {
points.forEach { point in var resultPoint: Double = 0
if let resultPoint = Double(point) { if scanner.scanDouble(&resultPoint) {
resultPoints.append(resultPoint) resultPoints.append(resultPoint)
}
} }
_ = scanner.scanCharacters(from: [","], into: nil)
} }
if resultPoints.count % 2 == 1 { if resultPoints.count % 2 == 1 {