diff --git a/README.md b/README.md
index 95864be..1767e15 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,7 @@ tablet, browser window, full screen, or no device at all with the text centered)
- **Background scenery**: rings, blurred colors, aurora, grid, color gradient, spotlight or plain, and the background can change during the video with a crossfade
- **Headline effects**: every headline can come in (up, from above, fade, pop, from the left, sharpen) and go out (up, down, fade, blur, shrink, to the right) in its own way, or the same for all texts at once
- **Zooms** onto a point you click, and **taps / clicks** that show where to look
-- **Captions** in four styles (pop, karaoke, block, classic), made from the voice-over, from any audio track with
+- **Captions** in five styles (pop, karaoke, highlighter, block, classic), made from the voice-over, from any audio track with
**speech recognition** (Whisper, on your own computer, every word at its exact moment) or imported from `.srt`/`.vtt`
- **Voice-over** from text (Kokoro / Piper TTS), plus a **music bed** that fades, ducks under the voice and
carves an EQ pocket for it, so speech stays clear while the music stays full
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 78b4e26..3635cfa 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -143,7 +143,7 @@ pause, after a sentence end, or when it gets long). The job returns the blocks;
with `commit`, so undo works.
The style comes from `captionDefaults` < `brand.captions` < `video.captions`. It covers:
-- `style` (`pop`, `karaoke`, `box`, `plain`)
+- `style` (`pop`, `karaoke`, `highlighter`, `box`, `plain`)
- `y` and `size`
- `words` (per group)
- `upper` and `outline`
diff --git a/src/captions.mjs b/src/captions.mjs
index b35f431..c2f3d1b 100644
--- a/src/captions.mjs
+++ b/src/captions.mjs
@@ -6,12 +6,14 @@
export const captionStyles = {
pop: 'Pop',
karaoke: 'Karaoke',
+ highlighter: 'Markeerstift',
box: 'Blok',
plain: 'Klassiek'
};
export const captionStyleHints = {
pop: 'Woorden springen er één voor één in, het gesproken woord licht op.',
karaoke: 'De hele groep staat er, gesproken woorden kleuren mee.',
+ highlighter: 'Een markeerstreep veegt achter elk gesproken woord.',
box: 'Het gesproken woord krijgt een gekleurd blok (TikTok-stijl).',
plain: 'Rustige ondertitel met achtergrond, hele groep in één keer.'
};
diff --git a/src/template.mjs b/src/template.mjs
index 84717d1..12a72d9 100644
--- a/src/template.mjs
+++ b/src/template.mjs
@@ -257,7 +257,7 @@ export function build(v, brand, fmt = '9:16') {
const capMap = FH / H, capSize = F.area ? Math.min(1, capMap * 1.25) : 1;
const capK = Math.max(2, Math.round(cs.size * capSize * 0.055));
const capShadow = cs.outline ? [[1, 0], [-1, 0], [0, 1], [0, -1], [0.7, 0.7], [-0.7, 0.7], [0.7, -0.7], [-0.7, -0.7]].map(([x, y]) => `${Math.round(x * capK)}px ${Math.round(y * capK)}px 0 #000`).join(', ') + `, 0 ${capK}px ${capK * 4}px #000a` : 'none';
- const captions = capGroups.map((g, i) => `
${g.words.map((w, j) => `${esc(w.w)}`).join(' ')}
`).join('\n ');
+ const captions = capGroups.map((g, i) => `${g.words.map((w, j) => `${esc(w.w)}`).join(' ')}
`).join('\n ');
// The device comes in at the start with its layout's entrance. A video that opens with only text has none: the device
// arrives with the transition of the change that brings it in.
const enter = TEXT0 || layouts[L].enter === 'none' ? '' : layouts[L].enter === 'fade'
@@ -465,6 +465,11 @@ export function build(v, brand, fmt = '9:16') {
tl.set(w, { color: CAP.hi }, t); tl.set(w, { color: base }, next);
} else if (CAP.style === 'karaoke') {
tl.set(w, { opacity: 1, color: CAP.hi }, t); tl.set(w, { color: base }, next);
+ } else if (CAP.style === 'highlighter') {
+ const marker = w.querySelector('.cw-marker');
+ tl.fromTo(marker, { scaleX: 0 }, { scaleX: 1, duration: Math.min(0.22, next - t), ease: 'power1.out', immediateRender: false }, t);
+ tl.set(w, { color: CAP.ink }, t); tl.set(w, { color: base }, next);
+ tl.set(marker, { scaleX: 0 }, next);
} else if (CAP.style === 'box') {
tl.set(w, { backgroundColor: CAP.hi, color: CAP.ink, textShadow: 'none', scale: 1.08 }, t);
tl.set(w, { backgroundColor: 'rgba(0,0,0,0)', color: base, textShadow: CAP.shadow, scale: 1 }, next);
@@ -637,6 +642,9 @@ export function build(v, brand, fmt = '9:16') {
.cap { position: absolute; left: 0; right: 0; top: 0; height: 0; display: flex; align-items: center; justify-content: center; opacity: 0; }
.cap-bg { display: block; max-width: 100%; text-align: center; font-size: ${Math.round(cs.size * capSize)}px; font-weight: 820; line-height: 1.14; letter-spacing: -0.02em; color: ${capColor}; text-wrap: balance;${cs.upper ? ' text-transform: uppercase;' : ''} }
.cw { display: inline-block; padding: 0.02em 0.14em; margin: 0 -0.06em; border-radius: 0.2em; text-shadow: ${capShadow}; }
+ .cw-marker { display: none; }
+ .S-highlighter .cw { position: relative; isolation: isolate; }
+ .S-highlighter .cw-marker { display: block; position: absolute; z-index: -1; inset: 0; border-radius: 0.16em; background: ${capHi}; transform: scaleX(0); transform-origin: left center; }
.cw.em { color: ${capHi}; }
.S-pop .cw { opacity: 0; }
.S-karaoke .cw { opacity: 0.45; }
diff --git a/test/template.test.mjs b/test/template.test.mjs
index a4f5d49..1d69fcf 100644
--- a/test/template.test.mjs
+++ b/test/template.test.mjs
@@ -24,6 +24,14 @@ test('build: every layout in every format gives a page of the right size', () =>
}
});
+test('build: highlighter captions sweep behind each timed word and restore the text color', () => {
+ const html = build(video({ captions: { style: 'highlighter' } }), brand, '9:16');
+ assert.match(html, /class="cw-marker"/);
+ assert.match(html, /\.S-highlighter \.cw-marker/);
+ assert.match(html, /scaleX: 1, duration: Math\.min\(0\.22, next - t\)/);
+ assert.match(html, /color: CAP\.ink/);
+});
+
test('stageFit: 9:16 is the stage itself; other formats put the device box inside their area', () => {
for (const L of Object.keys(layouts)) assert.equal(stageFit('9:16', L), null);
for (const [fmt, F] of Object.entries(formats)) {
diff --git a/ui/editor.css b/ui/editor.css
index 008bac3..84433c5 100644
--- a/ui/editor.css
+++ b/ui/editor.css
@@ -311,11 +311,12 @@ body.electron #bar button, body.electron #bar select, body.electron #bar input,
/* captions */
.tl-item.k-sub { background: #1c2a33; color: #bfe6ff; border-color: #2a4150; }
.tl-item.k-sub.off { opacity: .45; border-style: dashed; }
-.layout-grid.cap-styles { grid-template-columns: repeat(4, 1fr); }
+.layout-grid.cap-styles { grid-template-columns: repeat(5, 1fr); }
.cap-demo { display: flex; align-items: baseline; gap: 1px; font-size: 16px; font-weight: 800; font-style: normal; line-height: 1; padding: 2px 4px; border-radius: 5px; }
.cap-demo b, .cap-demo i { font-style: normal; font-weight: 800; padding: 1px 2px; border-radius: 4px; }
.cap-demo.s-pop b { color: var(--accent); transform: scale(1.15); display: inline-block; } .cap-demo.s-pop i { opacity: .25; }
.cap-demo.s-karaoke b { color: var(--accent); } .cap-demo.s-karaoke i { opacity: .45; }
+.cap-demo.s-highlighter b { background: linear-gradient(transparent 45%, var(--accent) 45%); }
.cap-demo.s-box b { background: var(--accent); color: #17244a; }
.cap-demo.s-plain { background: #000a; }
diff --git a/ui/i18n.js b/ui/i18n.js
index a9e1788..75eadbe 100644
--- a/ui/i18n.js
+++ b/ui/i18n.js
@@ -232,9 +232,10 @@ const en = {
'Nog geen ondertitels. Maak ze uit de voice-over, importeer een .srt/.vtt of voeg losse blokken toe met "Ondertitel".': 'No captions yet. Make them from the voice-over, import an .srt/.vtt or add blocks with "Caption".',
'{0} blok(ken) op de Ondertitels-track. Staat ook als .srt naast de render.': '{0} block(s) on the Captions track. Also saved as .srt next to the render.',
'Uit voice-over': 'From voice-over', 'Voeg eerst VO-zinnen toe': 'Add VO lines first', 'Importeer .srt/.vtt': 'Import .srt/.vtt',
- 'Ondertitels tonen': 'Show captions', 'Pop': 'Pop', 'Karaoke': 'Karaoke', 'Blok': 'Block', 'Klassiek': 'Classic',
+ 'Ondertitels tonen': 'Show captions', 'Pop': 'Pop', 'Karaoke': 'Karaoke', 'Markeerstift': 'Highlighter', 'Blok': 'Block', 'Klassiek': 'Classic',
'Woorden springen er één voor één in, het gesproken woord licht op.': 'Words pop in one by one, the spoken word lights up.',
'De hele groep staat er, gesproken woorden kleuren mee.': 'The whole group is shown, spoken words light up as they go.',
+ 'Een markeerstreep veegt achter elk gesproken woord.': 'A highlight sweeps behind each spoken word.',
'Het gesproken woord krijgt een gekleurd blok (TikTok-stijl).': 'The spoken word gets a colored block (TikTok style).',
'Rustige ondertitel met achtergrond, hele groep in één keer.': 'Calm caption with a background, the whole group at once.',
'Grootte (px)': 'Size (px)', 'Woorden per keer': 'Words at a time', 'Hoogte in beeld (Y, px)': 'Height on screen (Y, px)', 'Hoogte in beeld in {0} (Y, px)': 'Height on screen in {0} (Y, px)',