diff --git a/crates/engine/src/cmd/retype.rs b/crates/engine/src/cmd/retype.rs index 7f0c5fd9a1..6cae9c30ee 100644 --- a/crates/engine/src/cmd/retype.rs +++ b/crates/engine/src/cmd/retype.rs @@ -500,7 +500,9 @@ impl Line { // (tracking is added after the glyph and after the space): the seed then places the spaces // from the extra less one space, shared by the two. It goes last, so a reading that fits // without it is kept (an untracked "a b c" has no such tracking). - let spaced_seed = lower.map(|e| (e - space) / 2.0); + // Where untracked type already draws the whole line, a space and a tracking of half its + // advance less draw it too: that reading is not tried. + let spaced_seed = lower.filter(|_| plain_miss.is_some()).map(|e| (e - space) / 2.0); let mut tries = vec![]; for seed in [lower, median(extra, true), spaced_seed].into_iter().flatten() { let Some(measured) = measure(seed) else { continue }; diff --git a/crates/engine/src/cmd/retype_tests.rs b/crates/engine/src/cmd/retype_tests.rs index 34ab6f515c..9b06e3dba8 100644 --- a/crates/engine/src/cmd/retype_tests.rs +++ b/crates/engine/src/cmd/retype_tests.rs @@ -1055,6 +1055,16 @@ fn a_word_space_between_kerned_letters_is_read_as_a_space() { assert_same_places(&before, &text_of(&s, r["ids"][0].as_u64().unwrap())); } +#[test] +fn an_untracked_word_is_not_read_as_spaced_letters_in_tight_tracking() { + // Letters, each followed by a space, at tracking of minus half a space, sit where the word's + // letters do. + let mut s = session(); + let (_, r) = retyped(&mut s, json!({"x": 40, "y": 100, "text": "Third", "size": 24}), &[]); + assert_eq!(r["texts"], json!(["Third"]), "{r}"); + assert_eq!(r["fonts"][0]["tracking"], json!(0.0), "{r}"); +} + #[test] fn glyphs_barely_ahead_of_each_other_stay_one_line() { let mut s = session();