mirror of
https://github.com/Hommy-master/capcut-mate.git
synced 2026-09-01 15:32:57 +08:00
b7cbc329d3
"draft_url": "https://capcut-mate.jcaigc.cn/openapi/capcut-mate/v1/get_draft?draft_id=20251206191116a4fdff66", "captions": "[{\"start\":0,\"end\":10000000,\"text\":\"你好,剪映\",\"keyword\":\"好\",\"keyword_color\":\"#457616\",\"keyword_font_size\":15}]", "alignment": 1, "alpha": 1.0, "font_size": 6, "scale_x": 1.0, "scale_y": 1.0, "transform_x": 200, "transform_y": 200, "style_text": false, "underline": false, "italic": false, "bold": false } 解决指定font_size不生效的问题。
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
import sys
|
|
import os
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
|
|
from src.pyJianYingDraft.text_segment import TextStyle, TextSegment
|
|
from src.pyJianYingDraft.time_util import Timerange
|
|
|
|
def test_font_size():
|
|
"""测试字体大小设置"""
|
|
|
|
# 创建一个文本样式,指定字体大小为20
|
|
text_style = TextStyle(
|
|
size=20.0,
|
|
color=(1.0, 1.0, 1.0), # 白色
|
|
alpha=1.0,
|
|
align=1, # 居中
|
|
auto_wrapping=True
|
|
)
|
|
|
|
print(f"创建的TextStyle字体大小: {text_style.size}")
|
|
|
|
# 创建一个时间范围
|
|
timerange = Timerange(start=0, duration=5000000) # 5秒
|
|
|
|
# 创建文本片段
|
|
text_segment = TextSegment(
|
|
text="测试字体大小",
|
|
timerange=timerange,
|
|
style=text_style
|
|
)
|
|
|
|
print(f"TextSegment的style.size: {text_segment.style.size}")
|
|
|
|
# 导出材质并检查字体大小
|
|
material_json = text_segment.export_material()
|
|
content = material_json["content"]
|
|
print(f"导出的content: {content}")
|
|
|
|
# 解析content JSON
|
|
import json
|
|
content_data = json.loads(content)
|
|
styles = content_data["styles"]
|
|
base_style = styles[0]
|
|
print(f"基础样式中的字体大小: {base_style['size']}")
|
|
|
|
if __name__ == "__main__":
|
|
test_font_size() |