Skip to content

Commit a07a643

Browse files
committed
Script rows are not the next line under a stack, and a row of accents joins its bases
1 parent a497117 commit a07a643

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎crates/rpt-core/src/rewrite.rs‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16404,7 +16404,17 @@ fn open_leading_under_stacks(
1640416404
order.sort_by(|&left, &right| lines[right].y.total_cmp(&lines[left].y));
1640516405
for rank in 0..order.len().saturating_sub(1) {
1640616406
let line_index = order[rank];
16407-
let next = order[rank + 1];
16407+
// A script row drawn as its own small line (`1`, `2` of `C1 ⊗ C2`)
16408+
// is not the next body line. Measured against it, every gap looked
16409+
// 2pt tall and the paragraph was pushed into the one below.
16410+
let host = lines[line_index].size;
16411+
let Some(next) = order[rank + 1..]
16412+
.iter()
16413+
.copied()
16414+
.find(|&other| lines[other].size >= host * 0.8)
16415+
else {
16416+
continue;
16417+
};
1640816418
let mut below = 0.0f32;
1640916419
for &(hole_line, _, _, index, duplicate) in holes {
1641016420
if duplicate || hole_line != line_index || index >= stacks.len() {

‎crates/rpt-core/src/segment.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7120,7 +7120,13 @@ fn is_numeral_script(line: &VisualLine<'_>) -> bool {
71207120
}
71217121

71227122
fn is_math_script(line: &VisualLine<'_>) -> bool {
7123-
if line.glyphs.len() == 1 && is_math_mark(line.text.trim()) {
7123+
// `¯ ¯` over two `𝑡` in a row of `𝑒(𝑡̄)` is two accents, not a line.
7124+
if (1..=6).contains(&line.glyphs.len())
7125+
&& line
7126+
.glyphs
7127+
.iter()
7128+
.all(|glyph| is_math_mark(glyph.unicode.trim()))
7129+
{
71247130
return true;
71257131
}
71267132
let width = line.right - line.left;

0 commit comments

Comments
 (0)