Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: clip typography that cannot fit even at its minimum size (#8984)

[._.]/ Adam Eivy5212d9b9d81b
diff --git a/server/services/musicVideo/composition.js b/server/services/musicVideo/composition.js
index 1f458078c9..8e839ed919 100644
--- a/server/services/musicVideo/composition.js
+++ b/server/services/musicVideo/composition.js
@@ -170,7 +170,7 @@ export function buildTypographyDocument({ cues, style = {}, width, height, durat
html, body { margin: 0; padding: 0; background: transparent; overflow: hidden; }
#safe { position: absolute; }
.cue { position: absolute; left: 0; right: 0; box-sizing: border-box; padding: 0.25em; text-align: center; color: ${color}; font-family: ${fontStack};
- font-weight: 700; line-height: 1.15; overflow-wrap: break-word; visibility: hidden; will-change: transform, opacity;
+ font-weight: 700; line-height: 1.15; overflow-wrap: break-word; overflow: hidden; visibility: hidden; will-change: transform, opacity;
/* The padding keeps this legibility shadow inside the cue box, and so inside the safe area. */
text-shadow: 0 0 0.12em rgba(0,0,0,0.85), 0 0.04em 0.18em rgba(0,0,0,0.7); }
.cue .rest { visibility: hidden; }
@@ -210,13 +210,15 @@ function layout({ width, height }) {
size = Math.max(floor, Math.floor(size * 0.92));
node.el.style.fontSize = size + 'px';
}
- const boxH = Math.min(node.el.scrollHeight, safeH);
// A lower cue that rises in starts below its resting place: rest it high
// enough that its first frame is still inside the safe area.
const reserve = node.cue.template === 'rise' ? Math.ceil(0.04 * height) : 0;
- const top = node.cue.placement === 'upper' ? 0 : node.cue.placement === 'center' ? (safeH - boxH) / 2 : safeH - boxH - reserve;
+ // Text still too tall at the minimum size is clipped to the box (overflow:
+ // hidden), and the box — plus any rise travel — never exceeds the safe area.
+ const boxH = Math.min(node.el.scrollHeight, safeH - reserve);
+ const top = node.cue.placement === 'upper' ? 0 : node.cue.placement === 'center' ? (safeH - reserve - boxH) / 2 : safeH - boxH - reserve;
node.el.style.top = Math.round(top) + 'px';
- node.el.style.maxHeight = safeH + 'px';
+ node.el.style.maxHeight = boxH + 'px';
}
}
function draw(t) {
diff --git a/server/services/musicVideo/compositionRender.test.js b/server/services/musicVideo/compositionRender.test.js
index 933c2eeb1b..ac100c2448 100644
--- a/server/services/musicVideo/compositionRender.test.js
+++ b/server/services/musicVideo/compositionRender.test.js
@@ -125,14 +125,16 @@ describe.skipIf(!chrome || !ffmpeg)('music-video typography overlay with real Ch
expect(await readdir(join(PATHS.data, COMPOSITION_SCRATCH_DIR))).toEqual([]);
}, 60000);
- it.each([['16:9', 480, 270], ['9:16', 270, 480]])('keeps every motion template inside the title-safe area at %s', async (_label, width, height) => {
+ it.each([['16:9', 480, 270], ['9:16', 270, 480], ['a small 16:9 frame', 160, 90]])('keeps every motion template inside the title-safe area at %s', async (_label, width, height) => {
const long = 'A deliberately long lyric line that has to wrap and shrink to stay inside the frame';
const cues = [
{ id: 'hero', text: long, startSec: 0, endSec: 0.75, template: 'pop', placement: 'center', emphasis: 'hero' },
{ id: 'low', text: long, startSec: 1, endSec: 1.75, template: 'rise', placement: 'lower', emphasis: 'subtitle' },
{ id: 'up', text: long, startSec: 2, endSec: 2.75, template: 'typewriter', placement: 'upper', emphasis: 'subtitle' },
+ // Worst case: a maximum-length hero line that cannot fit even at the minimum size.
+ { id: 'max', text: 'W'.repeat(500), startSec: 3, endSec: 3.75, template: 'rise', placement: 'lower', emphasis: 'hero' },
];
- const overlays = await renderTypographyOverlays({ jobId: `safe-${width}`, cues, style: { font: 'serif' }, width, height, fps: 12, durationSec: 3 });
+ const overlays = await renderTypographyOverlays({ jobId: `safe-${width}`, cues, style: { font: 'serif' }, width, height, fps: 12, durationSec: 4 });
let drawn = 0;
for (const overlay of overlays) drawn += assertInsideSafeArea(overlay.path, width, height);
expect(drawn).toBeGreaterThan(1000);