@@ -6441,6 +6441,18 @@ fn math_script_host(index: usize, lines: &[VisualLine<'_>]) -> Option<usize> {
64416441 if dy < size * 0.08 || dy > size * 1.05 {
64426442 continue;
64436443 }
6444+ // A prose subscript drops well under half an em. Marks most of an em
6445+ // below a prose line (`⊤ −1` of the formula under `Definition 3`)
6446+ // belong to that formula, and gluing them in read `Info⊤r)m−a1tion`.
6447+ // A limit variable (`n` under a sum) still names its sentence.
6448+ if line.y < other.y
6449+ && !on_math
6450+ && dy > size * 0.5
6451+ && line.size < size * 0.85
6452+ && !line.text.chars().any(char::is_alphabetic)
6453+ {
6454+ continue;
6455+ }
64446456 if line.left < other.left - size || line.right > other.right + size {
64456457 continue;
64466458 }
@@ -12660,6 +12672,31 @@ mod tests {
1266012672 );
1266112673 }
1266212674
12675+ #[test]
12676+ fn formula_marks_far_below_a_heading_do_not_join_its_words() {
12677+ let mut head = wide(
12678+ 0,
12679+ 72.0,
12680+ 760.0,
12681+ "Definition 3 (Fisher Information Selection). Let",
12682+ 240.0,
12683+ 10.9,
12684+ );
12685+ head.font_name = "NimbusRomNo9L-Medi".into();
12686+ let mut top = wide(1, 180.0, 750.5, "\u{22a4}", 5.0, 8.0);
12687+ top.font_name = "CMSY8".into();
12688+ let mut inv = wide(2, 192.0, 752.6, "\u{2212}1", 10.0, 8.0);
12689+ inv.font_name = "CMSY8".into();
12690+ let mut eq = wide(3, 100.0, 745.0, "\u{39b}t = Id +", 60.0, 10.9);
12691+ eq.font_name = "CMMI10".into();
12692+ let segs = segment_glyphs(&[head, top, inv, eq]);
12693+ let texts: Vec<_> = segs.iter().map(|seg| seg.text.as_str()).collect();
12694+ assert!(
12695+ texts.iter().any(|t| t.contains("Information Selection")),
12696+ "{texts:?}"
12697+ );
12698+ }
12699+
1266312700 #[test]
1266412701 fn a_prose_line_with_a_times_sign_joins_the_paragraph() {
1266512702 let mut above = wide(
0 commit comments