Scripting: ParagraphJustification has After Effects' numbers (#3610)

After Effects 26.3 numbers MULTIPLE_JUSTIFICATIONS 7412, LEFT_JUSTIFY 7413,
RIGHT_JUSTIFY 7414, CENTER_JUSTIFY 7415, and the justified variants with
the last line left, right, centred and full 7416-7419. EffectCraft had
centre before right (and last-line centre before last-line right), so a
script setting 7414 got a centred paragraph instead of a right-aligned
one, silently.
This commit is contained in:
Sean Hawkey authored and GitHub committed 2026-11-13 07:06:04 +01:00
1 parent 8f21de0a0c
commit 78eb99583a
3 files changed
+60 -3

No files matched your search

@@ -0,0 +1,48 @@
//! `ParagraphJustification` has After Effects' numbers (26.3): MULTIPLE_JUSTIFICATIONS 7412,
//! LEFT 7413, RIGHT 7414, CENTER 7415, then the justified variants with the last line left (7416),
//! right (7417), centred (7418) and full (7419). A script that stores or compares the numbers gets
//! the same paragraph in both applications.
use serde_json::json;
use super::{comp_named, ok, session};
use effectcraft_engine::keyframe::{Justify, Value as KV};
#[test]
fn the_numbers_are_after_effects() {
let mut s = session();
let o = ok(
&mut s,
r#"
var P = ParagraphJustification;
[P.MULTIPLE_JUSTIFICATIONS, P.LEFT_JUSTIFY, P.RIGHT_JUSTIFY, P.CENTER_JUSTIFY, P.FULL_JUSTIFY_LASTLINE_LEFT,
P.FULL_JUSTIFY_LASTLINE_RIGHT, P.FULL_JUSTIFY_LASTLINE_CENTER, P.FULL_JUSTIFY_LASTLINE_FULL]
"#,
);
assert_eq!(o.result, json!([7412, 7413, 7414, 7415, 7416, 7417, 7418, 7419]));
}
#[test]
fn each_number_sets_and_reads_its_paragraph() {
let mut s = session();
let o = ok(
&mut s,
r#"
var c = app.project.items.addComp("J", 200, 100, 1, 2, 30);
var t = c.layers.addText("ab");
var st = t.property("ADBE Text Properties").property("ADBE Text Document");
var back = [];
for (var n = 7413; n <= 7419; n++) {
var d = st.value; d.justification = n; st.setValue(d);
back.push(st.value.justification);
}
var d = st.value; d.justification = 7414; st.setValue(d);
back
"#,
);
assert_eq!(o.result, json!([7413, 7414, 7415, 7416, 7417, 7418, 7419]));
// 7414 is right-aligned, as in After Effects.
let (_, c) = comp_named(&s, "J");
let KV::Text(d) = &c.layers[0].props.prop("text/sourceText").unwrap().value else { panic!("not text") };
assert_eq!(d.justify, Justify::Right);
}