Files
SubMiner/backlog/tasks/task-11 - Break-up-the-applyInvisibleSubtitleLayoutFromMpvMetrics-mega-function.md
2026-02-11 09:33:47 -08:00

1.6 KiB

id, title, status, assignee, created_date, labels, milestone, dependencies, references, priority
id title status assignee created_date labels milestone dependencies references priority
TASK-11 Break up the applyInvisibleSubtitleLayoutFromMpvMetrics mega function To Do
2026-02-11 08:21
refactor
renderer
complexity
Codebase Clarity & Composability
src/renderer/renderer.ts
medium

Description

In renderer.ts (around lines 865-1075), applyInvisibleSubtitleLayoutFromMpvMetrics is a 211-line function with up to 5 levels of nesting. It handles OSD scaling calculations, platform-specific font compensation (macOS vs Linux), DPR calculations, ASS alignment tag interpretation (\an tags), baseline compensation, line-height fixes, font property application, and transform origin — all interleaved.

Extract into focused helpers:

  • calculateOsdScale(metrics, renderAreaHeight) — pure scaling math
  • calculateSubtitlePosition(metrics, scale, alignment) — ASS \an tag interpretation + positioning
  • applyPlatformFontCompensation(style, platform) — macOS kerning/size adjustments
  • applySubtitleStyle(element, computedStyle) — DOM style application

This can be done independently of or as part of TASK-6 (renderer split).

Acceptance Criteria

  • #1 No single function exceeds ~50 lines in the positioning logic
  • #2 Helper functions are pure where possible (take inputs, return outputs)
  • #3 Platform-specific branches isolated into dedicated helpers
  • #4 Invisible overlay positioning still works correctly on Linux and macOS