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

Remove soft break tofu in cairo #362

Closed
wants to merge 1 commit into from

Conversation

richard-uk1
Copy link
Collaborator

I still need to figure out how to regenerate the snapshots.

@richard-uk1
Copy link
Collaborator Author

It might be that this has to wait until proper shaping, but I will try to land something sensible sooner.

Copy link
Member

@cmyr cmyr left a 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"))
Copy link
Member

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;

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

@cmyr
Copy link
Member

cmyr commented Feb 17, 2021

going to close this since we'll resolve in #389.

@cmyr cmyr closed this Feb 17, 2021
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.

2 participants