Merge pull request #8787 from dotCooCoo/fix/retype-skip-prohibited-tracking

Retype: a tracking that translucent glyphs cannot take no longer drops the tracked prefix already found
This commit is contained in:
BFlat authored and GitHub committed 2026-11-20 07:37:24 +07:00
commit 7a519eea68
2 files changed
+26 -1

No files matched your search

+1 -1
View File
@@ -531,7 +531,7 @@ impl Line {
continue;
}
if t < 0.0 && !paints_as_one(&self) {
return self;
continue;
}
let mut tracked = self.clone();
tracked.tracking = t;
+25
View File
@@ -1106,6 +1106,31 @@ fn tracking_near_a_whole_number_is_kept_as_measured_when_rounding_moves_glyphs()
assert_same_places(&before, &text_of(&s, r["ids"][0].as_u64().unwrap()));
}
#[test]
fn a_tracking_translucent_glyphs_cannot_take_keeps_the_tracking_that_fits() {
// The first three glyphs are tracked 50 and the last 150 further on. A tracking tighter than
// zero is not tried for glyphs that cannot be one object, and the tracked prefix is kept.
let mut s = session();
let id = s.execute("text.create", &json!({"x": 40, "y": 100, "text": "MMMM", "size": 30})).unwrap()["id"].as_u64().unwrap();
s.execute("text.setRangeStyle", &json!({"id": id, "start": 0, "end": 2, "tracking": 50})).unwrap();
s.execute("text.setRangeStyle", &json!({"id": id, "start": 2, "end": 3, "tracking": 150})).unwrap();
s.execute("select.set", &json!({"ids": [id]})).unwrap();
let g = s.execute("type.createOutlines", &json!({})).unwrap()["ids"][0].as_u64().unwrap();
let kids = children_of(&s, g);
s.edit("test", |d, _| {
for k in &kids {
d.node_mut(NodeId(*k)).unwrap().opacity = 0.5;
}
Ok(())
})
.unwrap();
s.execute("select.set", &json!({"ids": [g]})).unwrap();
let r = s.execute("type.retype", &json!({})).unwrap();
let texts: Vec<&str> = r["texts"].as_array().unwrap().iter().map(|t| t.as_str().unwrap()).collect();
assert_eq!(texts.concat(), "MMMM", "{r}");
assert!(texts.iter().any(|t| t.len() > 1), "the tracked glyphs stay one object: {r}");
}
#[test]
fn overlapping_translucent_glyphs_are_not_tracked_into_one_object() {
let mut s = session();