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

Incorrect alignment when using Wrap::None #130

Closed
nickguletskii opened this issue May 16, 2023 · 0 comments · Fixed by #131
Closed

Incorrect alignment when using Wrap::None #130

nickguletskii opened this issue May 16, 2023 · 0 comments · Fixed by #131

Comments

@nickguletskii
Copy link

nickguletskii commented May 16, 2023

When calling layout with Wrap::None, the w property of VisualLine is not updated, which breaks alignment options such as Align::center:

cosmic-text/src/shape.rs

Lines 664 to 670 in bfb5eef

if wrap == Wrap::None {
for (span_index, span) in self.spans.iter().enumerate() {
current_visual_line
.ranges
.push((span_index, (0, 0), (span.words.len(), 0)));
}
} else {

Besides, I don't really understand why Wrap::None has to be handled differently from other wrapping options. I might be wrong here, but wouldn't replacing fit_x - word_width >= 0. with wrap == Wrap::None || fit_x - word_width >= 0. inside the second branch be sufficient? Is this done for performance reasons?

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.

1 participant