Resolve more todos

This commit is contained in:
Mikayla 2024-01-09 15:08:05 -08:00
parent 80790d921d
commit ed263a7b5c
No known key found for this signature in database
8 changed files with 47 additions and 29 deletions

View file

@ -258,7 +258,7 @@ impl TextSystem {
pub fn shape_text(
&self,
text: &str, // todo!("pass a SharedString and preserve it when passed a single line?")
text: SharedString,
font_size: Pixels,
runs: &[TextRun],
wrap_width: Option<Pixels>,
@ -268,8 +268,8 @@ impl TextSystem {
let mut lines = SmallVec::new();
let mut line_start = 0;
for line_text in text.split('\n') {
let line_text = SharedString::from(line_text.to_string());
let mut process_line = |line_text: SharedString| {
let line_end = line_start + line_text.len();
let mut last_font: Option<Font> = None;
@ -335,6 +335,24 @@ impl TextSystem {
}
font_runs.clear();
};
let mut split_lines = text.split('\n');
let mut processed = false;
if let Some(first_line) = split_lines.next() {
if let Some(second_line) = split_lines.next() {
processed = true;
process_line(first_line.to_string().into());
process_line(second_line.to_string().into());
for line_text in split_lines {
process_line(line_text.to_string().into());
}
}
}
if !processed {
process_line(text);
}
self.font_runs_pool.lock().push(font_runs);