修改dockerfile加字体

This commit is contained in:
lmk
2026-06-23 12:49:34 +08:00
parent e708075512
commit 71b7daddd8
2 changed files with 5 additions and 2 deletions
+2 -1
View File
@@ -49,7 +49,8 @@ RUN npm install -g hyperframes --registry=https://registry.npmmirror.com/ --igno
# HyperFrames 渲染需要 Chromium/Chrome
# 安装 Chromium(提供系统级共享库依赖)和中文字体
RUN apk add --no-cache chromium font-noto-cjk
RUN apk add --no-cache chromium font-noto-cjk fontconfig \
&& fc-cache -f
# 下载 HyperFrames 需要的 headless-shell 浏览器
RUN npx hyperframes browser ensure
+3 -1
View File
@@ -260,6 +260,7 @@ func (s *captionService) runHyperFramesRender(ctx context.Context, projectDir, o
cmd.Dir = projectDir
cmd.Env = append(os.Environ(),
"HYPERFRAMES_HEADLESS=true",
"HYPERFRAMES_BROWSER_PATH=/usr/bin/chromium",
)
output, err := cmd.CombinedOutput()
@@ -308,7 +309,7 @@ func (s *captionService) buildHTML(taskID, videoPath, audioPath string, elements
sb.WriteString("* { margin: 0; padding: 0; box-sizing: border-box; }\n")
sb.WriteString(fmt.Sprintf("body { width: %dpx; height: %dpx; overflow: hidden; background: #000; }\n", width, height))
sb.WriteString(".clip { position: absolute; }\n")
sb.WriteString(".text-element { font-family: \"Noto Sans CJK SC\", \"PingFang SC\", \"Microsoft YaHei\", Arial, sans-serif; text-align: center; display: flex; align-items: center; justify-content: center; white-space: pre-wrap; word-break: break-word; }\n")
sb.WriteString(".text-element { font-family: \"Noto Sans SC\", \"Noto Sans CJK SC\", \"PingFang SC\", \"Microsoft YaHei\", Arial, sans-serif; text-align: center; display: flex; align-items: center; justify-content: center; white-space: pre-wrap; word-break: break-word; }\n")
sb.WriteString("@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }\n")
sb.WriteString("@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }\n")
sb.WriteString("@keyframes slideLeft { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }\n")
@@ -320,6 +321,7 @@ func (s *captionService) buildHTML(taskID, videoPath, audioPath string, elements
sb.WriteString(".anim-scaleIn { animation: scaleIn 0.5s ease-out; }\n")
sb.WriteString(".anim-pulse { animation: pulse 1.5s ease-in-out infinite; }\n")
sb.WriteString("</style>\n")
sb.WriteString("<link href=\"https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;700&display=swap\" rel=\"stylesheet\">\n")
sb.WriteString("<script src=\"https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js\"></script>\n")
sb.WriteString("</head>\n<body>\n")