mirror of
https://github.com/sun-guannan/CapCutAPI.git
synced 2025-11-25 03:15:00 +08:00
default font is system
This commit is contained in:
@@ -14,7 +14,7 @@ def add_text_impl(
|
|||||||
draft_id: str | None = None, # Python 3.10+ 新语法
|
draft_id: str | None = None, # Python 3.10+ 新语法
|
||||||
transform_y: float = -0.8,
|
transform_y: float = -0.8,
|
||||||
transform_x: float = 0,
|
transform_x: float = 0,
|
||||||
font: str = "文轩体",
|
font: Optional[str] = None,
|
||||||
font_color: str = "#ffffff",
|
font_color: str = "#ffffff",
|
||||||
font_size: float = 8.0,
|
font_size: float = 8.0,
|
||||||
track_name: str = "text_main",
|
track_name: str = "text_main",
|
||||||
@@ -102,11 +102,14 @@ def add_text_impl(
|
|||||||
:return: Updated draft information
|
:return: Updated draft information
|
||||||
"""
|
"""
|
||||||
# Validate if font is in Font_type
|
# Validate if font is in Font_type
|
||||||
try:
|
if font is None:
|
||||||
font_type = getattr(Font_type, font)
|
font_type = None
|
||||||
except:
|
else:
|
||||||
available_fonts = [attr for attr in dir(Font_type) if not attr.startswith('_')]
|
try:
|
||||||
raise ValueError(f"Unsupported font: {font}, please use one of the fonts in Font_type: {available_fonts}")
|
font_type = getattr(Font_type, font)
|
||||||
|
except:
|
||||||
|
available_fonts = [attr for attr in dir(Font_type) if not attr.startswith('_')]
|
||||||
|
raise ValueError(f"Unsupported font: {font}, please use one of the fonts in Font_type: {available_fonts}")
|
||||||
|
|
||||||
# Validate alpha value range
|
# Validate alpha value range
|
||||||
if not 0.0 <= font_alpha <= 1.0:
|
if not 0.0 <= font_alpha <= 1.0:
|
||||||
|
|||||||
Reference in New Issue
Block a user