Skip to content

fix(captions): keep Cyrillic captions inside the frame - #215

Open
stephanvoytov wants to merge 3 commits into
mutonby:mainfrom
stephanvoytov:fix/cyrillic-captions
Open

stephanvoytov wants to merge 3 commits into
mutonby:mainfrom
stephanvoytov:fix/cyrillic-captions

Conversation

@stephanvoytov

Copy link
Copy Markdown

Problem

Cyrillic captions could exceed the 9:16 frame. libass may substitute a wider fallback face for Cyrillic, while subtitles.line_fitter measures the bundled Anton/Montserrat; a line the fitter accepted then clipped on both edges (for example И ВОТ В ЧЁМ,).

Fix

Clamp a Cyrillic caption block to 10 characters before the line fitter runs (_CYRILLIC_LANGUAGES, _CYRILLIC_MAX_CHARS). A lone long word still uses the existing narrowing (\fscx), and Latin captions are unchanged.

Testing

  • New tests/test_cyrillic_captions.py checks that a Cyrillic line is split and no block exceeds the limit.
  • pytest tests/ -q: 2711 passed, 43 skipped (before the new test; run the subtree in CI).
  • cd dashboard && npm run build && npm run lint.

libass may fall back to a wider face than the measured Anton/Montserrat for Cyrillic, so the line fitter allowed lines that clip on both edges. Clamp a Cyrillic caption block to 10 characters before fitting; lone long words keep the existing narrowing. Latin captions are unchanged.
The editor preview rendered caption text at 58% of its burned size (it treated PlayRes units as CSS pixels of a scaled-down player), so a size that clipped in the export looked fine in the modal. Compose at 1080x1920 scale, clamp Cyrillic to the same 10 characters the burn uses, anchor at the same 15% margins, and re-base the size presets around the new 20 default.
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