-
Notifications
You must be signed in to change notification settings - Fork 96
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
Remove soft break tofu in cairo #362
Conversation
06dd773
to
7705860
Compare
Changes in `piet-cairo`.
7705860
to
e3321ab
Compare
It might be that this has to wait until proper shaping, but I will try to land something sensible sooner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, definitely worth getting this cleaned up.
There are instructions for adding snapshots somewhere, I think in CONTRIBUTING.md
. Ping me on zulip if you need help!
@@ -132,10 +132,17 @@ pub(crate) fn calculate_line_metrics(text: &str, font: &ScaledFont, width: f64) | |||
} | |||
|
|||
// now do the hard break | |||
let mut line_end = line_break; | |||
// Remove any trailing newline characters from the line. | |||
while matches!(text.get(line_end - 1..line_end), Some("\n") | Some("\r")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was slightly confused here for a second; I couldn't tell that this wouldn't screw up in cases where there were multiple newlines in a row, which should be treated as actual newlines.
Since this is linux I'm also not sure we care about \r
?
just for fun I'd have probably written something like,
let line_text = &text[line_start..line_end];
let newline_len = line_text.as_bytes().rev().take_while(|b| b == b'\n'').count();
let line_end = line_end - newline_len;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah \r
is probably overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think your solution is better.
going to close this since we'll resolve in #389. |
I still need to figure out how to regenerate the snapshots.