解决字体样式不生效的问题。

This commit is contained in:
Hommy
2025-12-04 23:24:57 +08:00
parent 5ebef34b49
commit da4baaeafa
3 changed files with 26 additions and 5 deletions
+4 -1
View File
@@ -192,7 +192,10 @@ def add_captions(acr: AddCaptionsRequest) -> AddCaptionsResponse:
scale_y=acr.scale_y,
transform_x=acr.transform_x,
transform_y=acr.transform_y,
style_text=acr.style_text
style_text=acr.style_text,
underline=acr.underline,
italic=acr.italic,
bold=acr.bold
)
return AddCaptionsResponse(
+3
View File
@@ -19,6 +19,9 @@ class AddCaptionsRequest(BaseModel):
transform_x: float = Field(default=0.0, description="水平位移")
transform_y: float = Field(default=0.0, description="垂直位移")
style_text: bool = Field(default=False, description="是否使用样式文本")
underline: bool = Field(default=False, description="文字下划线开关")
italic: bool = Field(default=False, description="文本斜体开关")
bold: bool = Field(default=False, description="文本加粗开关")
class CaptionItem(BaseModel):
+19 -4
View File
@@ -23,7 +23,10 @@ def add_captions(
scale_y: float = 1.0,
transform_x: float = 0.0,
transform_y: float = 0.0,
style_text: bool = False
style_text: bool = False,
underline: bool = False,
italic: bool = False,
bold: bool = False
) -> Tuple[str, str, List[str], List[str], List[dict]]:
"""
批量添加字幕到剪映草稿的业务逻辑
@@ -61,6 +64,9 @@ def add_captions(
transform_x: 水平位移,默认0.0
transform_y: 垂直位移,默认0.0
style_text: 是否使用样式文本,默认False
underline: 文字下划线开关,默认False
italic: 文本斜体开关,默认False
bold: 文本加粗开关,默认False
Returns:
draft_url: 草稿URL
@@ -119,7 +125,10 @@ def add_captions(
scale_y=scale_y,
transform_x=transform_x,
transform_y=transform_y,
style_text=style_text
style_text=style_text,
underline=underline,
italic=italic,
bold=bold
)
segment_ids.append(segment_id)
text_ids.append(text_id)
@@ -162,7 +171,10 @@ def add_caption_to_draft(
scale_y: float = 1.0,
transform_x: float = 0.0,
transform_y: float = 0.0,
style_text: bool = False
style_text: bool = False,
underline: bool = False,
italic: bool = False,
bold: bool = False
) -> Tuple[str, str, dict]:
"""
向剪映草稿中添加单个字幕
@@ -216,7 +228,10 @@ def add_caption_to_draft(
align=align_value,
letter_spacing=int(letter_spacing) if letter_spacing is not None else 0,
line_spacing=int(line_spacing) if line_spacing is not None else 0,
auto_wrapping=True # 字幕默认开启自动换行
auto_wrapping=True, # 字幕默认开启自动换行
underline=underline,
italic=italic,
bold=bold
)
# 4. 创建图像调节设置