diff --git a/tauri-app/src/pages/VideoCreation/SubtitleBurning.tsx b/tauri-app/src/pages/VideoCreation/SubtitleBurning.tsx index 45a63e7..9268b97 100644 --- a/tauri-app/src/pages/VideoCreation/SubtitleBurning.tsx +++ b/tauri-app/src/pages/VideoCreation/SubtitleBurning.tsx @@ -188,47 +188,56 @@ export default function SubtitleBurning() { // 构建 ASS Style 参数 const videoDurationMs = (alignment?.duration || 0) * 1000; - const buildSubtitleStyle = (preset: TitlePreset, scale: number = 1): Partial => ({ - fontSize: Math.round(64 * scale), - primaryColor: htmlColorToAss(preset.primaryColor), - outlineColor: htmlColorToAss(preset.outlineColor), - backColor: htmlColorToAss(preset.backColor), - borderStyle: preset.borderStyle, - outline: Math.round(preset.outline * scale), - shadow: 0, - alignment: 2, - marginV: Math.round(480 * scale), - marginL: Math.round(160 * scale), - marginR: Math.round(160 * scale), - }); + const buildSubtitleStyle = (preset: TitlePreset, scale: number = 1): Partial => { + const is720 = scale <= 0.7; + return { + fontSize: is720 ? 40 : 64, + primaryColor: htmlColorToAss(preset.primaryColor), + outlineColor: htmlColorToAss(preset.outlineColor), + backColor: htmlColorToAss(preset.backColor), + borderStyle: preset.borderStyle, + outline: Math.round(preset.outline * scale), + shadow: 0, + alignment: 2, + marginV: Math.round(480 * scale), + marginL: Math.round(160 * scale), + marginR: Math.round(160 * scale), + }; + }; - const buildMainTitleStyle = (preset: TitlePreset, scale: number = 1): Partial => ({ - fontSize: Math.round(96 * scale), - primaryColor: htmlColorToAss(preset.primaryColor), - outlineColor: htmlColorToAss(preset.outlineColor), - backColor: htmlColorToAss(preset.backColor), - borderStyle: preset.borderStyle, - outline: Math.round(preset.outline * scale), - shadow: 0, - alignment: 8, - marginV: Math.round(320 * scale), - marginL: Math.round(160 * scale), - marginR: Math.round(160 * scale), - }); + const buildMainTitleStyle = (preset: TitlePreset, scale: number = 1): Partial => { + const is720 = scale <= 0.7; + return { + fontSize: is720 ? 64 : 90, + primaryColor: htmlColorToAss(preset.primaryColor), + outlineColor: htmlColorToAss(preset.outlineColor), + backColor: htmlColorToAss(preset.backColor), + borderStyle: preset.borderStyle, + outline: Math.round(preset.outline * scale), + shadow: 0, + alignment: 8, + marginV: Math.round(320 * scale), + marginL: Math.round(160 * scale), + marginR: Math.round(160 * scale), + }; + }; - const buildSubTitleStyle = (preset: TitlePreset, scale: number = 1): Partial => ({ - fontSize: Math.round(80 * scale), - primaryColor: htmlColorToAss(preset.primaryColor), - outlineColor: htmlColorToAss(preset.outlineColor), - backColor: htmlColorToAss(preset.backColor), - borderStyle: preset.borderStyle, - outline: Math.round(preset.outline * scale), - shadow: 0, - alignment: 8, - marginV: Math.round(440 * scale), - marginL: Math.round(160 * scale), - marginR: Math.round(160 * scale), - }); + const buildSubTitleStyle = (preset: TitlePreset, scale: number = 1): Partial => { + const is720 = scale <= 0.7; + return { + fontSize: is720 ? 50 : 72, + primaryColor: htmlColorToAss(preset.primaryColor), + outlineColor: htmlColorToAss(preset.outlineColor), + backColor: htmlColorToAss(preset.backColor), + borderStyle: preset.borderStyle, + outline: Math.round(preset.outline * scale), + shadow: 0, + alignment: 8, + marginV: Math.round(440 * scale), + marginL: Math.round(160 * scale), + marginR: Math.round(160 * scale), + }; + }; // 用 text-shadow 模拟 ASS 外描边(比 WebkitTextStroke 的居中描边更准确) const getOutlineShadow = (color: string, outlineWidth: number): string => { @@ -391,10 +400,12 @@ export default function SubtitleBurning() { if ((mainTitle && mtStyle) || (subTitle && stStyle)) { const { generateTitlePngDataUrl } = await import('../../utils/titlePngGenerator'); + // 标题 PNG 使用独立的字体大小(与 ASS 不同) + const titlePngMainStyle = mtStyle ? { ...mtStyle, fontSize: targetWidth === 720 ? 64 : 104 } : undefined; const pngDataUrl = await generateTitlePngDataUrl( mainTitle || undefined, subTitle || undefined, - mtStyle, + titlePngMainStyle, stStyle, targetWidth, targetHeight,