Skip to content

fix(text-style): apply --font-size, --color, --align, --x, --y without a preset - #166

Merged
renezander030 merged 2 commits into
renezander030:masterfrom
abdullahmalik853-web:fix/text-style-font-color-position
Nov 2, 2026
Merged

renezander030 merged 2 commits into
renezander030:masterfrom
abdullahmalik853-web:fix/text-style-font-color-position

Conversation

@abdullahmalik853-web

Copy link
Copy Markdown
Contributor

What

text-style now applies --font-size, --color, --align, --x and --y when no --preset is given.

Why

These flags are declared in text-style's spec (shared with add-text through TEXT_STYLE) and listed by capcut describe, but cmdTextStyle only honoured them through presetWithFlagOverrides, so only when --preset was also passed. Without a preset they were dropped silently. The command still exited 0, reporting only the other fields it applied:

$ capcut text-style <project> <id> --font-size 22 --color '#FFD60A' --y 0.35 --border-width 0.08 --shadow
{"ok":true,"id":"…","material_id":"…","applied":["shadow","border"]}

The text stayed at size 15, stayed white and kept its position. An agent driving the CLI has no signal that anything went wrong.

Changes

  • setTextStyle (src/decorators.ts) takes fontSize, color and alignment. Font size and colour go to the material (font_size, text_color) and to every block in content.styles, because CapCut renders from those blocks. This matches how presetWithFlagOverrides treats these flags as covering the whole text. --color must be #RRGGBB, otherwise the command fails before writing.
  • cmdTextStyle (src/index.ts) passes those flags through and moves the segment for --x/--y the same way restyle does. With --preset the explicit flags still win, as before.
  • compile (src/compile.ts): the text-style operation's style now validates fontSize, alignment (finite numbers) and color (#RRGGBB), since they now reach setTextStyle.
  • Tests (test/decorators.test.mjs): one test asserts the four fields land in the material, the content style block and the segment transform. Another asserts a non-hex --color is rejected.
  • CHANGELOG.md: entry under [Unreleased] → Fixed.

add-text is unchanged: textStyleOptsFromFlags still leaves out these keys, so add-text keeps setting them itself.

Testing

  • npm test passed through the pre-commit hook, on top of v0.32.0 with the editor closed (Windows 11, Node 26): 1353 tests, 1293 pass, 0 fail, 60 skipped.
  • Checked by hand against a real CapCut draft: after the fix, the same command reports "applied":["font_size","color","transform"], and capcut segment shows the new size, colour and position in both the material and content.styles[0].

Note for anyone running the suite on Windows with CapCut open: the editor-open write guard makes 31 tests in register, rename, sync-timelines and diagnose-media-registration fail. Plain master fails the same way, so this branch did not cause it.

🤖 Generated with Claude Code

abdullahmalik853-web and others added 2 commits October 31, 2026 01:46
…t a preset

text-style declared these flags (shared with add-text) but only honoured
them through --preset; without one they were silently dropped and the
command still exited 0 with "applied": ["shadow", "border"].

setTextStyle now writes font size and colour to the material and to every
content style block (CapCut renders from those), plus alignment, and
cmdTextStyle moves the segment for --x/--y the way restyle does. --color is
validated as #RRGGBB, and compile's text-style op accepts and validates
fontSize, alignment and color too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@renezander030

Copy link
Copy Markdown
Owner

Thanks a lot for the fix and the clear write-up, merged! The one red check is the runner image dropping Python 3.9, unrelated to your change.

@renezander030
renezander030 merged commit 5d4220a into renezander030:master Nov 2, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants