Spaces:
Running
Running
Commit ·
d913a07
1
Parent(s): f8a99c0
Text working
Browse files
utils/bubble/ass-utils.js
CHANGED
|
@@ -71,28 +71,17 @@ export async function createAssSubtitle(text, opts = {}) {
|
|
| 71 |
const back = assColorFromHex(boxColor);
|
| 72 |
const bold = ('' + fontWeight).indexOf('7') === 0 || (String(fontWeight) === '700' || String(fontWeight).toLowerCase().includes('bold')) ? '1' : '0';
|
| 73 |
const fontSz = Math.round(fontSize);
|
| 74 |
-
const header = `[Script Info]\nScriptType: v4.00+\nPlayResX: ${vw}\nPlayResY: ${vh}\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n`;
|
| 75 |
|
| 76 |
-
//
|
| 77 |
-
const
|
| 78 |
-
|
| 79 |
-
: `Style: ${styleName},${fontName},${fontSz},${primary},&H00FFFFFF,&H00000000,&H00000000,${bold},0,0,0,100,100,0,0,1,1,0,2,10,10,10,1\n\n`;
|
| 80 |
|
| 81 |
-
const eventsHeader = `[Events]\nFormat: Layer, Start, End, Style,
|
| 82 |
const start = secToAssTime(from);
|
| 83 |
const end = secToAssTime(to);
|
| 84 |
-
const dialog = `Dialogue: 0,${start},${end},${styleName},
|
| 85 |
-
|
| 86 |
-
content = `[Script Info]
|
| 87 |
-
Title: Song Lyrics
|
| 88 |
-
|
| 89 |
-
[V4+ Styles]
|
| 90 |
-
Format: Name, Fontname, Fontsize, PrimaryColour, BackColour, BorderStyle, Outline, Shadow
|
| 91 |
-
Style: Default,Arial,20,&H00FFFFFF,&H80000000,3,0,0
|
| 92 |
-
|
| 93 |
-
[Events]
|
| 94 |
-
Format: Layer, Start, End, Style, Text
|
| 95 |
-
Dialogue: 0,0:00:12.50,0:00:15.80,Default,When the night has come`
|
| 96 |
fs.writeFileSync(assPath, content, 'utf8');
|
| 97 |
const meta = { path: assPath };
|
| 98 |
return meta;
|
|
|
|
| 71 |
const back = assColorFromHex(boxColor);
|
| 72 |
const bold = ('' + fontWeight).indexOf('7') === 0 || (String(fontWeight) === '700' || String(fontWeight).toLowerCase().includes('bold')) ? '1' : '0';
|
| 73 |
const fontSz = Math.round(fontSize);
|
| 74 |
+
const header = `[Script Info]\nTitle: Bubble\nScriptType: v4.00+\nPlayResX: ${vw}\nPlayResY: ${vh}\nScaledBorderAndShadow: yes\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n`;
|
| 75 |
|
| 76 |
+
// Match public/test.ass: use BorderStyle=3 and reasonable Outline value so BackColour is drawn reliably
|
| 77 |
+
const outlineVal = 6;
|
| 78 |
+
const styleLine = `Style: ${styleName},${fontName},${fontSz},${primary},&H00FFFFFF,${back || '&H00000000'},&H00000000,${bold},0,0,0,100,100,0,0,3,${outlineVal},0,2,10,10,10,1\n\n`;
|
|
|
|
| 79 |
|
| 80 |
+
const eventsHeader = `[Events]\nFormat: Layer, Start, End, Style, Text\n`;
|
| 81 |
const start = secToAssTime(from);
|
| 82 |
const end = secToAssTime(to);
|
| 83 |
+
const dialog = `Dialogue: 0,${start},${end},${styleName},{\\pos(${Math.round(x)},${Math.round(y)})}${safeText}\n`;
|
| 84 |
+
const content = header + styleLine + eventsHeader + dialog;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
fs.writeFileSync(assPath, content, 'utf8');
|
| 86 |
const meta = { path: assPath };
|
| 87 |
return meta;
|
utils/bubble/bubble-templates.js
CHANGED
|
@@ -3,7 +3,7 @@ export const BaseBubbleTemplates = {
|
|
| 3 |
// Simple text box: black text on white rounded box at top-center
|
| 4 |
'simple-top-center': {
|
| 5 |
// top-level bubble background controls whether a box is rendered
|
| 6 |
-
backgroundColor: '
|
| 7 |
borderRadius: 20,
|
| 8 |
audioEffectFile: 'woosh',
|
| 9 |
bubbleText: {
|
|
|
|
| 3 |
// Simple text box: black text on white rounded box at top-center
|
| 4 |
'simple-top-center': {
|
| 5 |
// top-level bubble background controls whether a box is rendered
|
| 6 |
+
backgroundColor: '#FFFFFF44',
|
| 7 |
borderRadius: 20,
|
| 8 |
audioEffectFile: 'woosh',
|
| 9 |
bubbleText: {
|