Skip to content

Commit

Permalink
Add comment and check for newline before multiline layout
Browse files Browse the repository at this point in the history
  • Loading branch information
afishhh committed Dec 5, 2024
1 parent 25da822 commit f406701
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/epaint/src/text/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,11 @@ impl GalleyCache {
cached.galley.clone()
}
std::collections::hash_map::Entry::Vacant(entry) => {
if job.break_on_newline {
// If the text contains newlines that will always break into a new row then
// we can easily lay out all the lines separately and then merge the `Galley`s.
// This allows individual lines to be cached separately which means small
// modifications to the source text will only cause impacted lines to be laid out again.
if job.break_on_newline && job.text.contains('\n') {
let galley = self.layout_multiline(fonts, job);
let galley = Arc::new(galley);
self.cache.insert(
Expand Down

0 comments on commit f406701

Please sign in to comment.