Skip to content

fix(compositor): on Linux, the subtitle plate hugs the text - #222

Merged
EtienneLescot merged 2 commits into
release/v1.8.0from
claude/subtitle-padding-linux-1.8.0
Aug 1, 2026
Merged

fix(compositor): on Linux, the subtitle plate hugs the text#222
EtienneLescot merged 2 commits into
release/v1.8.0from
claude/subtitle-padding-linux-1.8.0

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

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_plate box model (0.2em / 0.1em, radius in em) and the plate hugs the block. The Linux port never got that model — text_plate was there, Linux just didn't read it.

The fix

text_linux.rs:

  • layout now 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 actually laid out (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:

  • the mode-1 quad uses 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;
  • the plate is still revealed progressively by the typewriter animation, matching the backends that bake it into the texture.

Measurement

Caption band 1536x238, 48 px font, the text from the original screenshot:

before after
plate 1536 x 238 617 x 77

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.1em padding.

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).

⚠️ Not run on the machine that produced this patch: build.rs requires 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 of build_atlas against cosmic-text — the numbers above are its output. Please confirm with cargo test -p openscreen-compositor text_linux on a machine with the toolchain.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c2b7146f-c290-4631-80de-6351886c5d68

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EtienneLescot EtienneLescot changed the title fix(compositor): sous Linux, la plaque des sous-titres épouse le texte fix(compositor): on Linux, the subtitle plate hugs the text Aug 1, 2026
@EtienneLescot
EtienneLescot force-pushed the claude/subtitle-padding-linux-1.8.0 branch from ee30394 to e599c41 Compare August 1, 2026 12:02
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
EtienneLescot force-pushed the claude/subtitle-padding-linux-1.8.0 branch from e599c41 to 34981ab Compare August 1, 2026 14:01
@EtienneLescot
EtienneLescot merged commit cc1930c into release/v1.8.0 Aug 1, 2026
12 checks passed
@EtienneLescot
EtienneLescot deleted the claude/subtitle-padding-linux-1.8.0 branch August 1, 2026 14:14
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.

1 participant