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

Bidi behavior of set_text() vs. set_rich_text() #291

Open
JayTee42 opened this issue Jul 25, 2024 · 0 comments
Open

Bidi behavior of set_text() vs. set_rich_text() #291

JayTee42 opened this issue Jul 25, 2024 · 0 comments

Comments

@JayTee42
Copy link

Since 0cfd9b6, Buffer::set_text() uses the new LineIter to break the input text into paragraphs while Buffer::set_rich_text() relies on BidiParagraphs. This has some surprising repercussions since the two iterators behave slightly different.

For example, BidiParagraphs breaks at the U+2029 paragraph separator while LineIter does not. ShapeLine::new_in_buffer() joins paragraphs based on BidiInfo, but expects them to have matching directions. As a result, two paragraphs with different directions separated by U+2029 will cause a panic through Buffer::set_text(), but not through Buffer::set_rich_text():

// Paragraphs are separated early by `BidiParagraphs` -> no panic in `ShapeLine::new_in_buffer()`
buffer.set_rich_text([("Reuven Rivlin\u{2029}ראובן ריבלין", attrs)], attrs, Shaping::Advanced);

// Paragraphs stick together through `LineIter` -> panic in `ShapeLine::new_in_buffer()`
buffer.set_text("Reuven Rivlin\u{2029}ראובן ריבלין", attrs, Shaping::Advanced);
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

No branches or pull requests

1 participant