fix(compositor): on Linux, the subtitle plate hugs the text - #222
Merged
EtienneLescot merged 2 commits intoAug 1, 2026
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
EtienneLescot
force-pushed
the
claude/subtitle-padding-linux-1.8.0
branch
from
August 1, 2026 12:02
ee30394 to
e599c41
Compare
EtienneLescot
force-pushed
the
release/v1.8.0
branch
from
August 1, 2026 13:42
82d5e96 to
58ba61d
Compare
The Linux backend drew a text block's background plate over the annotation's BOX. For a subtitle, that box is the caption band -- 22% of the frame height (`CAPTION_BAND_HEIGHT_PCT`) -- so the fill extended far above and below the text, where Windows and macOS keep it within `0.1em` of the block since 889c068. The shared box model (`text_plate`) was already there; Linux simply did not read it. It does now, like the other two rasterizers: - layout runs on `text_plate::layout_width` (the box inset by the plate padding) instead of the full width, otherwise lines break somewhere other than where the plate is sized, and left/right-aligned text sticks to the edge; - the rasterizer measures the block it laid out and returns the plate rect alongside the atlas (`TextAtlas` / `RasterizedGlyphs::plate`) -- only it knows where cosmic-text placed the lines; - the compositor draws that rect instead of the box quad, with `text_plate::radius` (in em, clamped by the plate) instead of the hardcoded `4.0 * rh / 1080`, and the plate is still revealed progressively by the typewriter animation. Measured on the caption band (1536x238, 48 px font): the plate is 617x77 px instead of 1536x238, with the ink occupying y101..142.
EtienneLescot
force-pushed
the
claude/subtitle-padding-linux-1.8.0
branch
from
August 1, 2026 14:01
e599c41 to
34981ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
On Linux, subtitles get a huge amount of padding above and below in the editor preview.
The Linux backend drew a text block's background plate over the annotation's box (
compositor_linux.rs,dst: anim_dst). For an ordinary annotation that mostly passes; for a subtitle, that box is the caption band — 22% of the frame height (CAPTION_BAND_HEIGHT_PCT) — so the fill extends far above and below the text.Windows and macOS don't do this: since 889c068 they go through the shared
text_platebox model (0.2em / 0.1em, radius in em) and the plate hugs the block. The Linux port never got that model —text_platewas there, Linux just didn't read it.The fix
text_linux.rs:text_plate::layout_width(the box inset by the plate padding) instead of the full width — otherwise lines break somewhere other than where the plate is sized, and left/right-aligned text sticks to the edge;line_w,line_top + line_height) and returns the plate rect alongside the atlas (TextAtlas/RasterizedGlyphs::plate): only it knows where cosmic-text placed the lines. Windows and macOS bake the plate into the texture; the R8 atlas here carries coverage only, hence the rect travelling separately.compositor_linux.rs:text_plate::radius(in em, clamped by the plate) instead of the hardcoded4.0 * rh / 1080;Measurement
Caption band 1536x238, 48 px font, the text from the original screenshot:
The ink occupies y101..142, the plate y80..157 — vertical slack drops from roughly 80 px on each side to ~20 px, of which 15 px is line height and 4.8 px is the
0.1empadding.Tests
Two tests added in
text_linux.rs:the_plate_hugs_the_text_instead_of_filling_the_box— in a deliberately over-tall box, the plate stays tight around the text and still covers all of it;the_plate_follows_the_alignment_and_stays_in_the_box— all three alignments put the plate on the correct side, never overflowing (beyond the box it would be cut off flat by the texture edge and lose its rounded corners).build.rsrequires the ffmpeg headers, which aren't installed there, and there is no Linux Rust job in CI. The geometry was validated with a standalone harness replaying the CPU half ofbuild_atlasagainst cosmic-text — the numbers above are its output. Please confirm withcargo test -p openscreen-compositor text_linuxon a machine with the toolchain.🤖 Generated with Claude Code