Skip to content

Conversation

kidd0717
Copy link

Issue

Any SVG string start with 0, has a whitespace after, and comes with dot, will make the zero being ignored.

For example, if there is a SVG string "0 0 0 .25", it will get "0" "0" "0.25", which we expect "0" "0" "0" "0.25"

Root cause

In pathDefinitionParser we setup the scanner to skip whitespace, which make this string "0 .25" to be recognised as "0.25"

Fix

  • Update skip characters to only newline
  • Ignore whitespace in the parser

Test

Before

Screenshot 2025-05-15 at 17 57 07

Simulator Screenshot - iPhone 16 Pro - 2025-05-15 at 17 54 58

After

No error
Simulator Screenshot - iPhone 16 Pro - 2025-05-15 at 17 52 49

}
for (NSUInteger i = 0; i < zeros; ++i) { _operands.push_back(0.0); }

while ([scanner scanCharactersFromSet:[NSCharacterSet whitespaceCharacterSet] intoString:NULL]) { }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there an empty while loop here? isn't this an infinite loop

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an infinite loop. It will move the scanner to next char if the current char is a whitespace.

@kidd0717 kidd0717 closed this Oct 1, 2025
@kidd0717 kidd0717 reopened this Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants