Skip to content

Commit d18356f

Browse files
authored
Merge pull request #127 from kas-gui/push-kzkwxtmslvyv
Fix font breaks and h-tabs
2 parents b572543 + dbc18f3 commit d18356f

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/display/text_runs.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ impl TextDisplay {
236236
if !last_is_control {
237237
non_control_end = index;
238238
}
239-
let is_control = c.is_control();
240239
let is_htab = c == '\t';
241-
let mut require_break = is_htab;
240+
if is_htab {
241+
eprintln!("\\t at {index}");
242+
}
243+
let mut require_break = last_is_htab;
244+
let is_control = c.is_control();
242245

243246
// Is wrapping allowed at this position?
244247
let is_break = next_break == Some(index);
@@ -294,15 +297,7 @@ impl TextDisplay {
294297
if let Some(fmt) = next_fmt.as_ref()
295298
&& to_usize(fmt.start) == index
296299
{
297-
font = fmt.font;
298-
dpem = fmt.dpem;
299-
next_fmt = font_tokens.next();
300-
debug_assert!(
301-
next_fmt
302-
.as_ref()
303-
.map(|fmt| to_usize(fmt.start) > index)
304-
.unwrap_or(true)
305-
);
300+
require_break = true;
306301
}
307302

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

346+
if let Some(fmt) = next_fmt.as_ref()
347+
&& to_usize(fmt.start) == index
348+
{
349+
font = fmt.font;
350+
input.dpem = fmt.dpem;
351+
next_fmt = font_tokens.next();
352+
debug_assert!(
353+
next_fmt
354+
.as_ref()
355+
.map(|fmt| to_usize(fmt.start) > index)
356+
.unwrap_or(true)
357+
);
358+
}
359+
353360
last_is_control = is_control;
354361
last_is_htab = is_htab;
355362
emoji_start = new_emoji_start;
356-
input.dpem = dpem;
357363
if let Some(script) = new_script {
358364
input.script = script;
359365
}

0 commit comments

Comments
 (0)