Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions src/display/text_runs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,12 @@ impl TextDisplay {
if !last_is_control {
non_control_end = index;
}
let is_control = c.is_control();
let is_htab = c == '\t';
let mut require_break = is_htab;
if is_htab {
eprintln!("\\t at {index}");
}
let mut require_break = last_is_htab;
let is_control = c.is_control();

// Is wrapping allowed at this position?
let is_break = next_break == Some(index);
Expand Down Expand Up @@ -294,15 +297,7 @@ impl TextDisplay {
if let Some(fmt) = next_fmt.as_ref()
&& to_usize(fmt.start) == index
{
font = fmt.font;
dpem = fmt.dpem;
next_fmt = font_tokens.next();
debug_assert!(
next_fmt
.as_ref()
.map(|fmt| to_usize(fmt.start) > index)
.unwrap_or(true)
);
require_break = true;
}

let mut new_script = None;
Expand Down Expand Up @@ -345,15 +340,26 @@ impl TextDisplay {
input.script = script;
breaks = Default::default();
} else if is_break && !is_control {
// We do break runs when hitting control chars, but only when
// encountering the next non-control character.
breaks.push(shaper::GlyphBreak::new(to_u32(index)));
}

if let Some(fmt) = next_fmt.as_ref()
&& to_usize(fmt.start) == index
{
font = fmt.font;
input.dpem = fmt.dpem;
next_fmt = font_tokens.next();
debug_assert!(
next_fmt
.as_ref()
.map(|fmt| to_usize(fmt.start) > index)
.unwrap_or(true)
);
}

last_is_control = is_control;
last_is_htab = is_htab;
emoji_start = new_emoji_start;
input.dpem = dpem;
if let Some(script) = new_script {
input.script = script;
}
Expand Down
Loading