Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(library): a preset card shows a word of its own writing, not "Aa"

Jareer491b3a45e5ac
diff --git a/src/crates/concat/src/presets.rs b/src/crates/concat/src/presets.rs
index b2a2ede2..c8d5a193 100644
--- a/src/crates/concat/src/presets.rs
+++ b/src/crates/concat/src/presets.rs
@@ -19,6 +19,7 @@
//! offsetY = 0.3 # optional: a frame-height fraction from centre
//! language = "Latin" # optional: the writing it is for; Latin when absent
//! order = 10 # optional: where it sorts; absent sorts last, by name
+//! sample = "Aa" # optional: what its card draws; see TextPreset::sample
//!
//! [style] # any of a title's fields; the rest default
//! fontFamily = "Big Red"
@@ -59,6 +60,10 @@ pub struct TextPreset {
/// "Latin", "Japanese", "Hebrew". What the library filters and sorts
/// presets by; a preset file that says nothing is Latin.
pub language: String,
+ /// What its card draws in the look: the file's `sample`, else "Aa" for
+ /// Latin and the first two characters of its words for any other
+ /// writing, so a Japanese card shows Japanese.
+ pub sample: String,
}
#[derive(Deserialize)]
@@ -75,6 +80,9 @@ struct PresetFile {
/// Where it sorts among its neighbours; absent sorts last, by name.
#[serde(default)]
order: Option<i64>,
+ /// What the card draws; see [`TextPreset::sample`].
+ #[serde(default)]
+ sample: Option<String>,
#[serde(default)]
style: PresetStyle,
}
@@ -217,6 +225,28 @@ fn parse(text: &str, folder: Option<&Path>) -> Option<(i64, TextPreset)> {
.filter(|name| !name.trim().is_empty())
.and_then(|name| folder.map(|folder| folder.join(name.trim())));
let order = file.order.unwrap_or(i64::MAX);
+ let language = file
+ .language
+ .map(|language| language.trim().to_owned())
+ .filter(|language| !language.is_empty())
+ .unwrap_or_else(|| "Latin".to_owned());
+ let style = file.style.over(&file.name);
+ let sample = file
+ .sample
+ .map(|sample| sample.trim().to_owned())
+ .filter(|sample| !sample.is_empty())
+ .unwrap_or_else(|| {
+ if language.eq_ignore_ascii_case("latin") {
+ "Aa".to_owned()
+ } else {
+ style
+ .content
+ .chars()
+ .filter(|c| !c.is_whitespace())
+ .take(2)
+ .collect()
+ }
+ });
Some((
order,
TextPreset {
@@ -226,14 +256,11 @@ fn parse(text: &str, folder: Option<&Path>) -> Option<(i64, TextPreset)> {
file.name.trim().to_owned()
},
id,
- style: file.style.over(&file.name),
+ style,
offset_y: file.offset_y,
font,
- language: file
- .language
- .map(|language| language.trim().to_owned())
- .filter(|language| !language.is_empty())
- .unwrap_or_else(|| "Latin".to_owned()),
+ language,
+ sample,
},
))
}
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 7a649f30..88f79e1e 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -9121,6 +9121,7 @@ impl Studio {
id: preset.id.as_str().into(),
name: preset.name.as_str().into(),
language: preset.language.as_str().into(),
+ sample: preset.sample.as_str().into(),
family: preset.style.font_family.trim_matches('"').into(),
weight: preset.style.font_weight.round() as i32,
italic: preset.style.italic,
diff --git a/src/crates/concat/ui/workspace/media-pane.slint b/src/crates/concat/ui/workspace/media-pane.slint
index 45caa5ad..3fd640c0 100644
--- a/src/crates/concat/ui/workspace/media-pane.slint
+++ b/src/crates/concat/ui/workspace/media-pane.slint
@@ -53,6 +53,8 @@ export struct TextPresetData {
name: string,
/// The writing its face is made for: "Latin", "Japanese", "Hebrew".
language: string,
+ /// What the card draws in the look: "Aa", or a word of its own writing.
+ sample: string,
family: string,
weight: int,
italic: bool,
@@ -1168,7 +1170,8 @@ component TextPage inherits Rectangle {
}
}
-// One preset, as a card: the same "Aa" drawn in every look, on a dark
+// One preset, as a card: its sample - "Aa", or a word of its own writing -
+// drawn in its look, on a dark
// square so a white title reads as it will on footage, with the plate
// behind it when the look has one. The same two letters at the same size
// on every card so the looks compare - a caption preset is small on the
@@ -1219,7 +1222,7 @@ component PresetCard inherits Rectangle {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
width: Math.min(parent.width - 12px, self.preferred-width);
- text: "Aa";
+ text: root.preset.sample;
color: root.preset.fill;
font-family: root.preset.family;
font-weight: root.preset.weight;