EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Clipboard: keyframe text gives a text layer's source as 1 x 1, as After Effects does (#1908)
tylerjenningswb40c1aff2274
diff --git a/crates/engine/src/keyframe_text.rs b/crates/engine/src/keyframe_text.rsindex 59367b19b..851b94ee3 100644--- a/crates/engine/src/keyframe_text.rs+++ b/crates/engine/src/keyframe_text.rs@@ -97,11 +97,12 @@ pub(crate) fn text(project: &Project, comp: &Comp, keys: &[KeyRef], statics: &[(if blocks.is_empty() {return None;}- // Layers without a source of their own (text, shapes, cameras) take the comp's size and- // pixel aspect.- let (w, h) = match effectcraft_render::eval::source_size(project, layer) {- (0, 0) => (comp.width, comp.height),- size => size,+ // After Effects writes a text layer's source as 1 × 1. Other layers without a source of+ // their own (shapes, cameras) take the comp's size, and all of them its pixel aspect.+ let (w, h) = match (&layer.source, effectcraft_render::eval::source_size(project, layer)) {+ (LayerSource::Text, _) => (1, 1),+ (_, (0, 0)) => (comp.width, comp.height),+ (_, size) => size,};let par = match layer.source {LayerSource::Footage { item } | LayerSource::Solid { item } | LayerSource::Comp { item } => match project.item(item).map(|i| &i.kind) {diff --git a/crates/engine/src/tests_keyframe_text.rs b/crates/engine/src/tests_keyframe_text.rsindex dfdbe23a1..0ca688466 100644--- a/crates/engine/src/tests_keyframe_text.rs+++ b/crates/engine/src/tests_keyframe_text.rs@@ -353,10 +353,14 @@ fn the_header_has_the_source_pixel_aspect() {let solid = LayerId(s.execute("layer.newSolid", json!({"width": 200, "height": 100, "pixelAspect": 1.5})).unwrap()["layer"].as_u64().unwrap());let text = copy_transform(&mut s, solid);assert!(text.contains("\tSource Pixel Aspect Ratio\t1.5\n\tComp Pixel Aspect Ratio\t1.2\n"), "{text}");- // A text layer has no source of its own: the comp's.+ // A text layer: 1 × 1, as After Effects 2019 wrote it, with the comp's pixel aspect.let t = LayerId(s.execute("layer.newText", json!({"text": "Hi"})).unwrap()["layer"].as_u64().unwrap());let text = copy_transform(&mut s, t);- assert!(text.contains("\tSource Width\t1920\n\tSource Height\t1080\n\tSource Pixel Aspect Ratio\t1.2\n"), "{text}");+ assert!(text.contains("\tSource Width\t1\n\tSource Height\t1\n\tSource Pixel Aspect Ratio\t1.2\n"), "{text}");+ // A shape layer has no source of its own: the comp's size.+ let shape = LayerId(s.execute("layer.newShape", json!({})).unwrap()["layer"].as_u64().unwrap());+ let text = copy_transform(&mut s, shape);+ assert!(text.contains("\tSource Width\t1920\n\tSource Height\t1080\n"), "{text}");}#[test]