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
2026-11-13 07:06:04 +01:00
committed by GitHub
parent 8f21de0a0c
commit 78eb99583a
3 changed files with 60 additions and 3 deletions
+11 -3
View File
@@ -79,9 +79,10 @@ BlendingMode.SILHOUETTE_ALPHA = BlendingMode.SILHOUETE_ALPHA;
var KeyframeInterpolationType = __enum("KeyframeInterpolationType", ["LINEAR", "BEZIER", "HOLD"], 6612);
var TrackMatteType = __enum("TrackMatteType", ["NO_TRACK_MATTE", "ALPHA", "ALPHA_INVERTED", "LUMA", "LUMA_INVERTED"], 5012);
var LightType = __enum("LightType", ["PARALLEL", "SPOT", "POINT", "AMBIENT", "ENVIRONMENT"], 4412);
// In After Effects' order and numbers (26.3): right comes before centre.
var ParagraphJustification = __enum("ParagraphJustification", [
"LEFT_JUSTIFY", "CENTER_JUSTIFY", "RIGHT_JUSTIFY", "FULL_JUSTIFY_LASTLINE_LEFT", "FULL_JUSTIFY_LASTLINE_CENTER",
"FULL_JUSTIFY_LASTLINE_RIGHT", "FULL_JUSTIFY_LASTLINE_FULL", "MULTIPLE_JUSTIFICATIONS"], 7413);
"MULTIPLE_JUSTIFICATIONS", "LEFT_JUSTIFY", "RIGHT_JUSTIFY", "CENTER_JUSTIFY", "FULL_JUSTIFY_LASTLINE_LEFT",
"FULL_JUSTIFY_LASTLINE_RIGHT", "FULL_JUSTIFY_LASTLINE_CENTER", "FULL_JUSTIFY_LASTLINE_FULL"], 7412);
var PropertyValueType = __enum("PropertyValueType", [
"NO_VALUE", "ThreeD_SPATIAL", "ThreeD", "TwoD_SPATIAL", "TwoD", "OneD", "COLOR", "CUSTOM_VALUE", "MARKER",
"LAYER_INDEX", "MASK_INDEX", "SHAPE", "TEXT_DOCUMENT"], 6412);
@@ -120,7 +121,14 @@ function __blendLabel(v) {
var __interpKey = { 6612: "linear", 6613: "bezier", 6614: "hold" };
var __matteKind = { 5013: "alpha", 5014: "alphaInverted", 5015: "luma", 5016: "lumaInverted" };
var __matteEnum = { Alpha: 5013, AlphaInverted: 5014, Luma: 5015, LumaInverted: 5016 };
var __justKey = { 7413: "left", 7414: "center", 7415: "right", 7416: "justifyLeft", 7417: "justifyCenter", 7418: "justifyRight", 7419: "justifyAll" };
var __justKey = {};
__justKey[ParagraphJustification.LEFT_JUSTIFY] = "left";
__justKey[ParagraphJustification.CENTER_JUSTIFY] = "center";
__justKey[ParagraphJustification.RIGHT_JUSTIFY] = "right";
__justKey[ParagraphJustification.FULL_JUSTIFY_LASTLINE_LEFT] = "justifyLeft";
__justKey[ParagraphJustification.FULL_JUSTIFY_LASTLINE_CENTER] = "justifyCenter";
__justKey[ParagraphJustification.FULL_JUSTIFY_LASTLINE_RIGHT] = "justifyRight";
__justKey[ParagraphJustification.FULL_JUSTIFY_LASTLINE_FULL] = "justifyAll";
// ------------------------------------------------------------------ output, $ and dialogs
+1
View File
@@ -16,6 +16,7 @@ mod ease_presets;
mod evalfile;
mod include;
mod panels;
mod paragraph_justification;
#[cfg(not(target_arch = "wasm32"))]
mod render_wait;
#[cfg(not(windows))]
@@ -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);
}