Merge #17973 into the merge queue batch

Type: name each Anti-Alias History state after its method (#17959)
This commit is contained in:
David Mann committed 2026-11-30 12:09:07 +01:00
commit f0e0822474
2 files changed
+48 -1

No files matched your search

@@ -0,0 +1,33 @@
//! #17959: each Type › Anti-Alias method adds one History state named after the method, as the
//! reference application names it ("Anti Alias Crisp"), instead of one shared name for all seven.
use serde_json::json;
use crate::Session;
/// A document with one type layer, and that layer's id.
fn session() -> (Session, u64) {
let mut s = crate::session();
s.execute("file.new", json!({"width": 300, "height": 200})).unwrap();
let layer = s.execute("type.create", json!({"text": "Ab", "x": 40, "y": 120})).unwrap()["layer"].as_u64().unwrap();
(s, layer)
}
#[test]
fn each_method_names_its_own_history_state() {
let (mut s, layer) = session();
// New text is Smooth, so every command here changes the method.
for (cmd, name) in [
("type.antiAlias.none", "Anti Alias None"),
("type.antiAlias.sharp", "Anti Alias Sharp"),
("type.antiAlias.crisp", "Anti Alias Crisp"),
("type.antiAlias.strong", "Anti Alias Strong"),
("type.antiAlias.smooth", "Anti Alias Smooth"),
("type.antiAlias.windowsLcd", "Anti Alias Windows LCD"),
("type.antiAlias.windows", "Anti Alias Windows"),
] {
let before = s.active().unwrap().history.entries().len();
s.execute(cmd, json!({"layer": layer})).unwrap();
assert_eq!(s.active().unwrap().history.entries()[before..], [name], "{cmd}");
}
}
+15 -1
View File
@@ -137,7 +137,17 @@ pub fn aa_name(a: AntiAlias) -> &'static str {
}
fn set_aa(s: &mut Session, p: &Value, aa: AntiAlias) -> Result<Value> {
with_text_targets(s, p, "Anti-Alias", |t, _| {
// The History state is named after the method, as in the reference application (#17959).
let label = match aa {
AntiAlias::None => "Anti Alias None",
AntiAlias::Sharp => "Anti Alias Sharp",
AntiAlias::Crisp => "Anti Alias Crisp",
AntiAlias::Strong => "Anti Alias Strong",
AntiAlias::Smooth => "Anti Alias Smooth",
AntiAlias::WindowsLcd => "Anti Alias Windows LCD",
AntiAlias::Windows => "Anti Alias Windows",
};
with_text_targets(s, p, label, |t, _| {
t.antialias = aa;
Ok(())
})?;
@@ -1127,3 +1137,7 @@ pub fn specs() -> Vec<CommandSpec> {
#[cfg(test)]
#[path = "type_extra_cmds/tests.rs"]
mod tests;
#[cfg(test)]
#[path = "type_anti_alias_history_tests.rs"]
mod anti_alias_history_tests;