From 40aa7d90154ed3245b603e53c9f380167e48d6dd Mon Sep 17 00:00:00 2001 From: clover caruso Date: Mon, 30 Nov 2026 14:52:38 -0800 Subject: [PATCH] Parse StyledText-tagged BezierSpline text keyframes (#17) --- crates/model/src/comp.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/crates/model/src/comp.rs b/crates/model/src/comp.rs index d093107a3cc5ed65ca1aa5e37b04f95ae45c2986..d22bea5a044426309a44fd4d3743b16602504cf4 100644 --- a/crates/model/src/comp.rs +++ b/crates/model/src/comp.rs @@ -2153,7 +2153,7 @@ fn try_parse_text_keyframes(table: &LuaTable) -> Option> { }; let kt = v.as_table()?; let val = kt.get_table("Value")?; - if val.tag.as_deref() == Some("Text") { + if matches!(val.tag.as_deref(), Some("Text" | "StyledText")) { let s = val.get_str("Value").unwrap_or("").to_owned(); texts.push((time, s)); } else { @@ -3087,4 +3087,32 @@ mod expression_modifier_tests { assert!((reloaded.eval_number(r_inst, "Blend", 5.0, 1.0, &expr) - 0.5).abs() < 1e-6); assert_eq!(r_inst.connected_node("EffectMask"), None); } + + #[test] + fn parses_styled_text_and_text_bezier_spline_keyframes() { + let src = r#"Composition { + Tools = ordered() { + Text_1 = TextPlus { + Inputs = { + StyledText = Input { + SourceOp = "Text_1StyledText", + Source = "Value", + }, + }, + }, + Text_1StyledText = BezierSpline { + KeyFrames = { + [10] = { 0, Value = StyledText { Value = "first line" } }, + [20] = { 1, Value = Text { Value = "second line" } }, + }, + }, + }, + }"#; + let comp = Comp::from_fusion_str(src).expect("parse styled text spline"); + let expr = ExprEngine::new(); + let node = comp.node(comp.find_node("Text_1").unwrap()); + assert_eq!(comp.eval_text(node, "StyledText", 5.0, "", &expr), "first line"); + assert_eq!(comp.eval_text(node, "StyledText", 10.0, "", &expr), "first line"); + assert_eq!(comp.eval_text(node, "StyledText", 25.0, "", &expr), "second line"); + } } -- 2.54.1