Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when trying to render ideographic space character #427

Closed
Majora320 opened this issue Mar 26, 2021 · 1 comment · Fixed by #428
Closed

Panic when trying to render ideographic space character #427

Majora320 opened this issue Mar 26, 2021 · 1 comment · Fixed by #428

Comments

@Majora320
Copy link
Contributor

Note: This was a bug I observed when building something with druid, but since the traceback led to this library I'm filing it here as that is likely where the issue lies.

When rendering the character U+3000 IDEOGRAPHIC SPACE ( ) at the end of a line or by itself, the program panics and this a message similar to this one is printed (this specific example is for a string containing the character alone):

thread 'main' panicked at 'byte index 2 is not a char boundary; it is inside '\u{3000}' (bytes 0..3) of ` `', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/piet-cairo-0.3.0/src/text.rs:313:45

I'm not sure if this is a bug in piet, cairo, or what have you, but I would appreciate it being looked into.

@raphlinus
Copy link
Contributor

Quick look through the code reveals the likely culprit: count_trailing_whitespace in text/lines.rs is returning count which is a number of code points, but it's being interpreted as utf-8 code units. The count should be replaced by something like a sum of len_utf8.

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 a pull request may close this issue.

2 participants