@softure-ai/marketing-kit 0.38.1 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +11 -6
- package/dist/footage/draft-overlays.d.ts.map +1 -1
- package/dist/footage/draft-overlays.js +72 -28
- package/dist/footage/draft-overlays.js.map +1 -1
- package/dist/footage/overlay-html.d.ts.map +1 -1
- package/dist/footage/overlay-html.js +22 -5
- package/dist/footage/overlay-html.js.map +1 -1
- package/dist/footage/overlay-motion.d.ts +2 -1
- package/dist/footage/overlay-motion.d.ts.map +1 -1
- package/dist/footage/overlay-motion.js +9 -3
- package/dist/footage/overlay-motion.js.map +1 -1
- package/dist/footage/overlays.d.ts +36 -5
- package/dist/footage/overlays.d.ts.map +1 -1
- package/dist/footage/overlays.js +144 -37
- package/dist/footage/overlays.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/footage/draft-overlays.ts +82 -29
- package/src/footage/overlay-html.ts +20 -4
- package/src/footage/overlay-motion.ts +9 -2
- package/src/footage/overlays.ts +175 -41
- package/src/index.ts +2 -0
package/dist/footage/overlays.js
CHANGED
|
@@ -76,6 +76,12 @@ export const LIST_CHIP_COVERED_OPACITY = 0.55;
|
|
|
76
76
|
* shrinking down to it, so the step badges never turn a row that fitted without them into a refusal.
|
|
77
77
|
*/
|
|
78
78
|
export const LIST_CHIP_MIN_FONT_SIZE = 36;
|
|
79
|
+
/**
|
|
80
|
+
* The smallest type a row of chips shrinks to so it can sit on the frame's axis (RV-185 of an adopting app), in px of a
|
|
81
|
+
* 1080 px wide frame: in the centred span only, where a row that fits the whole zone at `LIST_CHIP_MIN_FONT_SIZE` would
|
|
82
|
+
* otherwise stand off the axis.
|
|
83
|
+
*/
|
|
84
|
+
export const LIST_CHIP_CENTRED_MIN_FONT_SIZE = 32;
|
|
79
85
|
/** A place card title's line height, tighter for its big type. */
|
|
80
86
|
export const OVERLAY_TITLE_LINE_HEIGHT = 1.05;
|
|
81
87
|
export const OVERLAY_PADDING_EM = { x: 0.6, y: 0.35 };
|
|
@@ -142,17 +148,22 @@ function findOverlayStart(overlay, words) {
|
|
|
142
148
|
return findWordStart(overlay.at_word, words, "at_word");
|
|
143
149
|
}
|
|
144
150
|
/** The film second a word of the transcript starts at, or why it is not there (`field` names it in the reason). */
|
|
145
|
-
function findWordStart(wanted, words, field) {
|
|
151
|
+
function findWordStart(wanted, words, field, from) {
|
|
146
152
|
const key = normalizeWord(wanted.text);
|
|
147
153
|
const occurrence = wanted.occurrence ?? 1;
|
|
148
154
|
const matches = words.filter((word) => normalizeWord(word.text) === key);
|
|
149
|
-
|
|
155
|
+
// A list's point is said after the list starts (RV-192 of an adopting app): its occurrence counts from there, and only
|
|
156
|
+
// a word the list never reaches falls back to the whole cut's count, as before.
|
|
157
|
+
const after = from === undefined ? [] : matches.filter((word) => word.start >= from - WORD_START_TOLERANCE);
|
|
158
|
+
const word = after[occurrence - 1] ?? matches[occurrence - 1];
|
|
150
159
|
if (word === undefined) {
|
|
151
160
|
const said = matches.length === 0 ? "the film never says it" : `the film says it ${matches.length} time${matches.length === 1 ? "" : "s"}`;
|
|
152
161
|
return { ok: false, error: `${field}: no word "${wanted.text}"${occurrence > 1 ? ` (occurrence ${occurrence})` : ""} in the cut; ${said}` };
|
|
153
162
|
}
|
|
154
163
|
return { ok: true, start: word.start };
|
|
155
164
|
}
|
|
165
|
+
/** How far before a list's start its point's word may begin and still count as said after it: one frame at 30 fps. */
|
|
166
|
+
const WORD_START_TOLERANCE = 0.034;
|
|
156
167
|
const r1 = (value) => Math.round(value * 10) / 10;
|
|
157
168
|
const r3 = (value) => Math.round(value * 1000) / 1000 || 0;
|
|
158
169
|
/** A drawn overlay's padding round its text, in px: `OVERLAY_PADDING_EM` of its font size, scaled by its `padScale`. */
|
|
@@ -260,13 +271,23 @@ function getBoxesUnion(boxes) {
|
|
|
260
271
|
* A list's drawn boxes after each point has come in (RV-144 of an adopting app): `cards[i]` is what shows once points
|
|
261
272
|
* 0 to i are in. A stack's card grows with each point, fitted to the points in so far (one line taller, as wide as the
|
|
262
273
|
* widest), so it never stands sized for the whole list nor empty: its first point comes in with it. Chips add one
|
|
263
|
-
* card at a time,
|
|
264
|
-
*
|
|
274
|
+
* card at a time, and the chips shown so far are always a row of their own on the frame's axis (`chipAxis`, RV-185 of
|
|
275
|
+
* an adopting app), as close to it as the box allows, their sizes and gaps kept; the last step is the full row
|
|
276
|
+
* (`overlay.chips`) exactly. Every entry holds one box per drawn card.
|
|
265
277
|
*/
|
|
266
278
|
export function getListCardsByItem(overlay) {
|
|
267
279
|
if (overlay.chips !== undefined) {
|
|
268
280
|
const chips = overlay.chips;
|
|
269
|
-
|
|
281
|
+
const first = chips[0].left;
|
|
282
|
+
const axis = overlay.chipAxis ?? (first + getChipRight(chips[chips.length - 1])) / 2;
|
|
283
|
+
const { box } = overlay;
|
|
284
|
+
return chips.map((chip, index) => {
|
|
285
|
+
if (index === chips.length - 1)
|
|
286
|
+
return chips;
|
|
287
|
+
const width = getChipRight(chip) - first;
|
|
288
|
+
const left = Math.round(Math.max(box.left, Math.min(box.left + box.width - width, axis - width / 2)));
|
|
289
|
+
return chips.slice(0, index + 1).map((shown) => ({ ...shown, left: shown.left - first + left }));
|
|
290
|
+
});
|
|
270
291
|
}
|
|
271
292
|
const lines = getSideTextLines(overlay);
|
|
272
293
|
const padY = getOverlayPadding(overlay).y;
|
|
@@ -275,6 +296,19 @@ export function getListCardsByItem(overlay) {
|
|
|
275
296
|
return [getSideTextCard(overlay, lines.slice(0, index + 1), height)];
|
|
276
297
|
});
|
|
277
298
|
}
|
|
299
|
+
/** A chip's right edge, in px of the frame. */
|
|
300
|
+
function getChipRight(chip) {
|
|
301
|
+
return chip.left + chip.width;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Which step of `getListCardsByItem` shows from each distinct second a list's points come in at (RV-185 of an adopting
|
|
305
|
+
* app): points on the same second come in together, so the step is the last of them. In time order, the first at the
|
|
306
|
+
* list's start.
|
|
307
|
+
*/
|
|
308
|
+
export function getListStops(overlay) {
|
|
309
|
+
const times = getListItemTimes(overlay);
|
|
310
|
+
return times.flatMap((at, step) => (times[step + 1] === at ? [] : [{ at, step }]));
|
|
311
|
+
}
|
|
278
312
|
/** The film seconds each point of a list comes in at: its own (`itemStarts`), the first with the card; else all with the card. */
|
|
279
313
|
export function getListItemTimes(overlay) {
|
|
280
314
|
return overlay.items.map((_item, index) => (index === 0 ? overlay.start : (overlay.itemStarts?.[index] ?? overlay.start)));
|
|
@@ -374,7 +408,7 @@ export function resolveEdlOverlays(input) {
|
|
|
374
408
|
// Chips always come in one by one, as a countdown of the points (RV-181 of an adopting app); a stack only when asked.
|
|
375
409
|
const isStaggered = overlay.style?.stagger === true || overlay.item_words !== undefined || overlay.item_at !== undefined;
|
|
376
410
|
if (placed.overlay.kind === "list" && (isStaggered || placed.overlay.chips !== undefined)) {
|
|
377
|
-
const said = (overlay.item_words ?? []).map((word, item) => findWordStart(word, input.words, `item_words[${item}]
|
|
411
|
+
const said = (overlay.item_words ?? []).map((word, item) => findWordStart(word, input.words, `item_words[${item}]`, start));
|
|
378
412
|
const missing = said.flatMap((word) => (word.ok ? [] : [word.error]));
|
|
379
413
|
if (missing.length > 0) {
|
|
380
414
|
problems.push(...missing.map((error) => `${at}.${error}`));
|
|
@@ -490,10 +524,12 @@ function getCentredSpan(place, margin) {
|
|
|
490
524
|
* there either in the whole zone, as close to the axis as the zone allows. What fitted before still fits.
|
|
491
525
|
*/
|
|
492
526
|
function measureCentred(input) {
|
|
493
|
-
const wide = input.measure(input.whole);
|
|
494
|
-
if (!wide.ok
|
|
527
|
+
const wide = input.measure(input.whole, false);
|
|
528
|
+
if (!wide.ok && input.isRetriedWhenRefused !== true)
|
|
529
|
+
return wide;
|
|
530
|
+
if (wide.ok && input.getWidth(wide) <= input.centred)
|
|
495
531
|
return wide;
|
|
496
|
-
const narrow = input.measure(input.centred);
|
|
532
|
+
const narrow = input.measure(input.centred, true);
|
|
497
533
|
return narrow.ok ? narrow : wide;
|
|
498
534
|
}
|
|
499
535
|
/** The top of a box `height` tall at a named position of the text region. */
|
|
@@ -729,8 +765,10 @@ function placeSideText(overlay, drawn, place) {
|
|
|
729
765
|
const chips = overlay.kind === "list" ? measureCentred({
|
|
730
766
|
whole: room,
|
|
731
767
|
centred: getCentredSpan(place, margin).width,
|
|
732
|
-
measure: (width) => getListChipLayout({ items: overlay.items ?? [], layout: overlay.style?.list_layout ?? "stack", fontSize, minFontSize: Math.round(LIST_CHIP_MIN_FONT_SIZE * scale), padScale: place.padScale, room: width }),
|
|
768
|
+
measure: (width, isCentred) => getListChipLayout({ items: overlay.items ?? [], layout: overlay.style?.list_layout ?? "stack", fontSize, minFontSize: Math.round((isCentred ? LIST_CHIP_CENTRED_MIN_FONT_SIZE : LIST_CHIP_MIN_FONT_SIZE) * scale), padScale: place.padScale, room: width }),
|
|
733
769
|
getWidth: (result) => result.row?.width ?? 0,
|
|
770
|
+
// A row refused in the whole zone may still fit the centred span a little smaller.
|
|
771
|
+
isRetriedWhenRefused: true,
|
|
734
772
|
}) : null;
|
|
735
773
|
if (chips !== null && !chips.ok)
|
|
736
774
|
return chips;
|
|
@@ -750,7 +788,7 @@ function placeSideText(overlay, drawn, place) {
|
|
|
750
788
|
const centred = { ...box, ...getCentredSpan(place, margin) };
|
|
751
789
|
if (overlay.kind === "list") {
|
|
752
790
|
const isCentred = row === null && overlay.style?.side === undefined;
|
|
753
|
-
const layout = row !== null ? { chips: placeChipRow(row, { ...box, left: getCentredLeft(place, row.width, margin), width: row.width }) } : isCentred ? { isCentred: true } : {};
|
|
791
|
+
const layout = row !== null ? { chips: placeChipRow(row, { ...box, left: getCentredLeft(place, row.width, margin), width: row.width }), chipAxis: place.frame.width / 2 } : isCentred ? { isCentred: true } : {};
|
|
754
792
|
// A row of chips may be drawn smaller than the list's size, to fit one row.
|
|
755
793
|
return { ok: true, overlay: { ...drawn, kind: "list", items: overlay.items ?? [], fontSize: row?.fontSize ?? fontSize, side, box: isCentred ? centred : box, ...layout } };
|
|
756
794
|
}
|
|
@@ -828,15 +866,16 @@ export function getChipTickPoints(badge) {
|
|
|
828
866
|
];
|
|
829
867
|
}
|
|
830
868
|
/**
|
|
831
|
-
* When each chip of a row is covered: the second
|
|
832
|
-
* fainter, its number a tick) and the newest point leads, as a countdown does
|
|
833
|
-
*
|
|
869
|
+
* When each chip of a row is covered: the first second a later point comes in after it, after which the chip steps
|
|
870
|
+
* back (its point fainter, its number a tick) and the newest point leads, as a countdown does. So every point before
|
|
871
|
+
* the one leading is ticked, in order, even when two came in together (RV-192 of an adopting app). Null for the
|
|
872
|
+
* points that lead last, and for one whose next point comes in only after the list has gone.
|
|
834
873
|
*/
|
|
835
874
|
export function getChipCoveredTimes(overlay) {
|
|
836
875
|
const times = getListItemTimes(overlay);
|
|
837
876
|
return times.map((at, index) => {
|
|
838
|
-
const next = times
|
|
839
|
-
return next !== undefined && next
|
|
877
|
+
const next = times.slice(index + 1).find((later) => later > at);
|
|
878
|
+
return next !== undefined && next < overlay.end ? next : null;
|
|
840
879
|
});
|
|
841
880
|
}
|
|
842
881
|
/** The chips of a row in their final places: centred in `box`, left to right in the points' order. */
|
|
@@ -870,9 +909,12 @@ export function wrapOverlayTitle(text, fontSize, width) {
|
|
|
870
909
|
}
|
|
871
910
|
return best;
|
|
872
911
|
}
|
|
873
|
-
/**
|
|
874
|
-
|
|
875
|
-
|
|
912
|
+
/**
|
|
913
|
+
* A title's lines and font size: its own size, else smaller by `OVERLAY_TITLE_SHRINK` until it fits two lines, at most
|
|
914
|
+
* `maxShrinks` times; null when it never does.
|
|
915
|
+
*/
|
|
916
|
+
function fitTitle(text, fontSize, room, maxShrinks = MAX_TITLE_SHRINKS) {
|
|
917
|
+
for (let shrink = 0, size = fontSize; shrink <= maxShrinks; shrink++, size = Math.round(size * OVERLAY_TITLE_SHRINK)) {
|
|
876
918
|
const lines = wrapOverlayTitle(text, size, room);
|
|
877
919
|
if (lines.length <= MAX_OVERLAY_TITLE_LINES && lines.every((line) => estimateTextWidth(line, size) <= room))
|
|
878
920
|
return { lines, fontSize: size };
|
|
@@ -885,10 +927,44 @@ function fitTitle(text, fontSize, room) {
|
|
|
885
927
|
* fitted then is refused now).
|
|
886
928
|
*/
|
|
887
929
|
function getSubtitleSize(input) {
|
|
888
|
-
const
|
|
930
|
+
const smallest = Math.round(MIN_OVERLAY_SUBTITLE_PX * input.scale);
|
|
931
|
+
const wanted = Math.max(smallest, Math.round(input.titleSize * OVERLAY_SUBTITLE_SCALES[input.step]));
|
|
889
932
|
const fitting = Math.floor(input.room / ([...input.subtitle].length * OVERLAY_CHAR_EM));
|
|
890
|
-
|
|
933
|
+
// In the centred span a subtitle may go down to `MIN_OVERLAY_SUBTITLE_PX` too when the `s` step is above it.
|
|
934
|
+
const floor = Math.round(input.titleSize * OVERLAY_SUBTITLE_SCALES.s);
|
|
935
|
+
return Math.min(wanted, Math.max(fitting, input.isCentred === true ? Math.min(floor, smallest) : floor));
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* A place card's subtitle: one line at `getSubtitleSize` when it fits `room` (what fitted before keeps its size), else
|
|
939
|
+
* two balanced lines, each sized as one line would be; null when even two lines are too wide (RV-184 of an adopting
|
|
940
|
+
* app: a card whose subtitle cannot fit the centred span is placed off the frame's axis).
|
|
941
|
+
*/
|
|
942
|
+
function fitPlaceSubtitle(input) {
|
|
943
|
+
const size = getSubtitleSize(input);
|
|
944
|
+
if (estimateTextWidth(input.subtitle, size) <= input.room)
|
|
945
|
+
return { lines: [input.subtitle], size };
|
|
946
|
+
const lines = splitInTwoLines(input.subtitle);
|
|
947
|
+
if (lines === null)
|
|
948
|
+
return null;
|
|
949
|
+
const longest = lines.reduce((widest, line) => ([...line].length > [...widest].length ? line : widest));
|
|
950
|
+
const lineSize = getSubtitleSize({ ...input, subtitle: longest });
|
|
951
|
+
return lines.every((line) => estimateTextWidth(line, lineSize) <= input.room) ? { lines, size: lineSize } : null;
|
|
952
|
+
}
|
|
953
|
+
/** A text's two lines of words as even as they can be (the longer line as short as it can be); null for one word. */
|
|
954
|
+
function splitInTwoLines(text) {
|
|
955
|
+
const words = text.split(/\s+/).filter((part) => part.length > 0);
|
|
956
|
+
if (words.length < 2)
|
|
957
|
+
return null;
|
|
958
|
+
let best = [words[0], words.slice(1).join(" ")];
|
|
959
|
+
for (let split = 2; split < words.length; split++) {
|
|
960
|
+
const pair = [words.slice(0, split).join(" "), words.slice(split).join(" ")];
|
|
961
|
+
if (Math.max(...pair.map((line) => [...line].length)) < Math.max(...best.map((line) => [...line].length)))
|
|
962
|
+
best = pair;
|
|
963
|
+
}
|
|
964
|
+
return best;
|
|
891
965
|
}
|
|
966
|
+
/** A place card's title may shrink this many steps more in the centred span than in the whole zone (0.9² ≈ 0.81). */
|
|
967
|
+
const CENTRED_TITLE_EXTRA_SHRINKS = 2;
|
|
892
968
|
/**
|
|
893
969
|
* The text block of a hook title or a place card without its padding, in px: its widest line (the place label with
|
|
894
970
|
* its pin, the subtitle, each title line) and its height. Its card is this plus the padding, so the draft and the
|
|
@@ -897,11 +973,14 @@ function getSubtitleSize(input) {
|
|
|
897
973
|
export function getTitleContentSize(input) {
|
|
898
974
|
const { kind, lines, fontSize, second, secondSize } = input;
|
|
899
975
|
const isHook = kind === "hook_title";
|
|
900
|
-
const
|
|
976
|
+
const seconds = second === null ? [] : (input.secondLines ?? [second]);
|
|
977
|
+
const secondWidth = Math.max(0, ...seconds.map((line) => estimateTextWidth(line, secondSize) + (isHook ? Math.round(secondSize * 1.1) : 0)));
|
|
901
978
|
const lineHeight = isHook ? OVERLAY_LINE_HEIGHT : OVERLAY_TITLE_LINE_HEIGHT;
|
|
979
|
+
// A wrapped subtitle's further lines each add a card line (`OVERLAY_LINE_HEIGHT`), as the render's `<br>` does.
|
|
980
|
+
const secondHeight = seconds.length === 0 ? 0 : secondSize * 1.3 + fontSize * 0.12 + (seconds.length - 1) * secondSize * OVERLAY_LINE_HEIGHT;
|
|
902
981
|
return {
|
|
903
982
|
width: Math.max(secondWidth, input.pin === true ? getPlaceCardPinSize(fontSize) : 0, ...lines.map((line) => estimateTextWidth(line, fontSize))),
|
|
904
|
-
height: lines.length * fontSize * lineHeight +
|
|
983
|
+
height: lines.length * fontSize * lineHeight + secondHeight + (input.pin === true ? getPlaceCardPinRow(fontSize) : 0),
|
|
905
984
|
};
|
|
906
985
|
}
|
|
907
986
|
/** A place card's pin height (and width), in px: half its title's size. */
|
|
@@ -916,26 +995,38 @@ export function getPlaceCardPinRow(fontSize) {
|
|
|
916
995
|
export function getTitleContentBox(overlay) {
|
|
917
996
|
const second = overlay.kind === "hook_title" ? overlay.place : overlay.subtitle;
|
|
918
997
|
const secondSize = overlay.kind === "hook_title" ? overlay.placeFontSize : overlay.subtitleFontSize;
|
|
919
|
-
const
|
|
998
|
+
const isPlace = overlay.kind === "place_card";
|
|
999
|
+
const size = getTitleContentSize({
|
|
1000
|
+
kind: overlay.kind,
|
|
1001
|
+
lines: overlay.lines,
|
|
1002
|
+
fontSize: overlay.fontSize,
|
|
1003
|
+
second,
|
|
1004
|
+
secondSize,
|
|
1005
|
+
pin: isPlace && overlay.pin !== undefined,
|
|
1006
|
+
...(isPlace && overlay.subtitleLines !== undefined ? { secondLines: overlay.subtitleLines } : {}),
|
|
1007
|
+
});
|
|
920
1008
|
const { box } = overlay;
|
|
921
1009
|
return { left: box.left + (box.width - size.width) / 2, top: box.top + (box.height - size.height) / 2, width: size.width, height: size.height };
|
|
922
1010
|
}
|
|
923
1011
|
/** A hook title's or a place card's lines and second line, aligned as its style says. */
|
|
924
|
-
function measureTitle(overlay, metrics) {
|
|
1012
|
+
function measureTitle(overlay, metrics, isCentred = false) {
|
|
925
1013
|
const { room, label } = metrics;
|
|
926
|
-
const
|
|
1014
|
+
const isHook = overlay.kind === "hook_title";
|
|
1015
|
+
// In the centred span a place card's title may shrink further, so a card that fitted the whole zone stays on the axis.
|
|
1016
|
+
const fitted = fitTitle(overlay.text ?? "", metrics.fontSize, room, MAX_TITLE_SHRINKS + (isCentred && !isHook ? CENTRED_TITLE_EXTRA_SHRINKS : 0));
|
|
927
1017
|
if (fitted === null)
|
|
928
1018
|
return { ok: false, error: `the ${label} takes more than ${MAX_OVERLAY_TITLE_LINES} lines even at a smaller size; shorten it or use a smaller size` };
|
|
929
1019
|
const { lines, fontSize } = fitted;
|
|
930
|
-
const isHook = overlay.kind === "hook_title";
|
|
931
1020
|
const second = (isHook ? overlay.place : overlay.subtitle) ?? null;
|
|
932
|
-
const
|
|
933
|
-
|
|
934
|
-
|
|
1021
|
+
const subtitle = !isHook && second !== null ? fitPlaceSubtitle({ subtitle: second, titleSize: metrics.fontSize, step: overlay.style?.subtitle_size ?? "m", room, scale: metrics.scale, isCentred }) : null;
|
|
1022
|
+
if (!isHook && second !== null && subtitle === null)
|
|
1023
|
+
return tooWide(metrics, "subtitle");
|
|
1024
|
+
const secondSize = subtitle?.size ?? Math.round(metrics.fontSize * OVERLAY_SECONDARY_SCALE[overlay.kind]);
|
|
1025
|
+
const subtitleLines = subtitle !== null && subtitle.lines.length > 1 ? subtitle.lines : undefined;
|
|
935
1026
|
// The hook title's place label carries a pin about one label line wide before it.
|
|
936
|
-
const secondWidth = second === null ? 0 : estimateTextWidth(second, secondSize) +
|
|
1027
|
+
const secondWidth = second === null || !isHook ? 0 : estimateTextWidth(second, secondSize) + Math.round(secondSize * 1.1);
|
|
937
1028
|
if (secondWidth > room)
|
|
938
|
-
return tooWide(metrics,
|
|
1029
|
+
return tooWide(metrics, "place label");
|
|
939
1030
|
// A title's align is center or left (the schema refuses right on it).
|
|
940
1031
|
const align = overlay.style?.align === "left" ? "left" : "center";
|
|
941
1032
|
const pin = !isHook && overlay.style?.pin !== undefined && overlay.style.pin !== "none" ? overlay.style.pin : undefined;
|
|
@@ -943,10 +1034,20 @@ function measureTitle(overlay, metrics) {
|
|
|
943
1034
|
return {
|
|
944
1035
|
ok: true,
|
|
945
1036
|
content: {
|
|
946
|
-
...getTitleContentSize({ kind: overlay.kind, lines, fontSize, second, secondSize, pin: pin !== undefined }),
|
|
1037
|
+
...getTitleContentSize({ kind: overlay.kind, lines, fontSize, second, secondSize, pin: pin !== undefined, ...(subtitleLines === undefined ? {} : { secondLines: subtitleLines }) }),
|
|
947
1038
|
fields: isHook
|
|
948
1039
|
? { kind: "hook_title", lines, place: second, fontSize, placeFontSize: secondSize, align, ...(overlay.style?.backdrop === "highlight" ? { backdrop: "highlight" } : {}) }
|
|
949
|
-
: {
|
|
1040
|
+
: {
|
|
1041
|
+
kind: "place_card",
|
|
1042
|
+
lines,
|
|
1043
|
+
subtitle: second,
|
|
1044
|
+
fontSize,
|
|
1045
|
+
subtitleFontSize: secondSize,
|
|
1046
|
+
align,
|
|
1047
|
+
...(pin === undefined ? {} : { pin }),
|
|
1048
|
+
...(delay === undefined ? {} : { subtitleDelay: delay }),
|
|
1049
|
+
...(subtitleLines === undefined ? {} : { subtitleLines }),
|
|
1050
|
+
},
|
|
950
1051
|
},
|
|
951
1052
|
};
|
|
952
1053
|
}
|
|
@@ -1004,10 +1105,10 @@ function placeCard(overlay, drawn, place) {
|
|
|
1004
1105
|
const outer = frame.width - zone.left - zone.right - 2 * margin;
|
|
1005
1106
|
const fontSize = Math.round(OVERLAY_FONT_SIZES[overlay.kind][overlay.style?.size ?? "m"] * scale);
|
|
1006
1107
|
const pad = getOverlayPadding({ fontSize, padScale: place.padScale });
|
|
1007
|
-
const measure = (room) => {
|
|
1108
|
+
const measure = (room, isCentred = false) => {
|
|
1008
1109
|
const metrics = { fontSize, pad, room: room - 2 * pad.x, label: overlay.kind.replace("_", " "), scale };
|
|
1009
1110
|
return overlay.kind === "hook_title" || overlay.kind === "place_card"
|
|
1010
|
-
? measureTitle({ ...overlay, kind: overlay.kind }, metrics)
|
|
1111
|
+
? measureTitle({ ...overlay, kind: overlay.kind }, metrics, isCentred)
|
|
1011
1112
|
: overlay.kind === "search_bar"
|
|
1012
1113
|
? measureSearchBar(overlay, metrics)
|
|
1013
1114
|
: overlay.kind === "counter"
|
|
@@ -1017,7 +1118,13 @@ function placeCard(overlay, drawn, place) {
|
|
|
1017
1118
|
// A date stamp sits on its side of the whole zone; every other card on the frame's axis.
|
|
1018
1119
|
const measured = overlay.kind === "date_stamp"
|
|
1019
1120
|
? measure(outer)
|
|
1020
|
-
: measureCentred({
|
|
1121
|
+
: measureCentred({
|
|
1122
|
+
whole: outer,
|
|
1123
|
+
centred: getCentredSpan(place, margin).width,
|
|
1124
|
+
measure,
|
|
1125
|
+
getWidth: (result) => Math.ceil(result.content.width + 2 * pad.x),
|
|
1126
|
+
isRetriedWhenRefused: overlay.kind === "place_card",
|
|
1127
|
+
});
|
|
1021
1128
|
if (!measured.ok)
|
|
1022
1129
|
return measured;
|
|
1023
1130
|
const { content } = measured;
|