Skip to content

Add rounded backgrounds to qtext - #1303

Closed
1996fanrui wants to merge 1 commit into
mltframework:masterfrom
1996fanrui:feature/qtext-background-radius
Closed

1996fanrui wants to merge 1 commit into
mltframework:masterfrom
1996fanrui:feature/qtext-background-radius

Conversation

@1996fanrui

Copy link
Copy Markdown

Add an animatable bg_radius property to qtext.

A value of 0 preserves the existing rectangular background. Positive values render rounded corners, clamped to half of the background rectangle's shortest side.

The property is also exposed by text services that delegate to qtext, including subtitle, dynamictext, timer, gpstext, and the subtitle producer.

Tested with plain text, rich text, subtitle rendering, the full test suite, metadata validation, and clang-format checks.

@bmatherly

Copy link
Copy Markdown
Member

Can you share some screenshots that show the property in action?

Having the underscore in "bg_raduis" does not match the existing property name pattern which does not have an underscore.

One of my regrets about the outline property is that it is specified in pixels. Specifying the size in pixels does not scale well when the user changes the project resolution or the font size. Do you have any ideas for how to do this differently for this property? Maybe percentage? Or maybe it is best to use pixel units since outline already does that.

@ddennedy

Copy link
Copy Markdown
Member

I am inclined to reject this because it a step on the slippery slope to bloat these filters. These are only supposed to be about text, and it can be argued that the background color is legacy baggage. I can already predict what's next: a background outline thickness and color, gradient fill. Then, everything that is In kdenlivetitle. If you want a fancier background, draw it with something else and layer and composite it. There is an infinite number of tools and ways to produce image files, but probably the most convenient thing here is a script to generate SVG that is compatible with Qt or the Glaxnimate producer. If you need to be able to manually, visually draw it and then adapt it for the specific use case; then draw it in Glaxnimate. Next, modify it lightly to use with any number of text templating tools and/or scripting languages. I will leave open for a couple of weeks for justification or appeals.

@bmatherly

Copy link
Copy Markdown
Member

I am inclined to agree with your comments, Dan. On the other hand, there is a popular trend of animated subtitles on Facebook/Instagram (background highlighting and animated size). We do not currently have an easy way to generate that style. I wonder if this feature could lead to something like that (without all the slippery slope bloat you correctly mention). That is why I had asked for the screenshot/demonstration.

@ddennedy

Copy link
Copy Markdown
Member

We do not have a way to determine the timing of words in a phrase for much of that trend, but backgrounds for something that changes size frequently like subtitles is a valid use case.

@1996fanrui

Copy link
Copy Markdown
Author

Thanks for the feedback. I tested the suggested approach with an unmodified MLT 7.22.0 build: generating one SVG per subtitle cue and compositing it using qimage and qtblend, with timing supplied externally from MFA/SRT. This handles the dynamically sized rounded subtitle backgrounds required by my use case without extending qtext.

Based on that result, I agree that the background styling is better kept as a separate composited layer, so I will close this PR. Thanks for pointing me in the right direction.

@1996fanrui 1996fanrui closed this Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants