exyte / Macaw

Powerful and easy-to-use vector graphics Swift library with SVG support
MIT License
6.01k stars 553 forks source link

Parsing failed in case text contains Emoji #722

Closed VictorSemenchuk closed 4 years ago

VictorSemenchuk commented 4 years ago

In SVGParser.swift in parseText method you're taking string's full range for regex matching in the following way: let fullRange = NSRange(location: 0, length: elementString.count)

In case text contains Emoji, elementString.count returns wrong count, because Emoji is composed character. So, count of UTF16 code unites can be different than count of composed characters.

So, I propose to replace elementString.count with elementString.utf16.count, or maybe you have any other ways to fix the issue.

VictorSemenchuk commented 4 years ago

The issue was fixed with 0.9.7 release