Skip to content

add_text_style ​

POST /add_text_style

接口说明 ​

根据关键词和普通文字生成分段富文本样式,接口本身不修改草稿。把返回的 text_styles 原样传给 add_text,即可实现关键词高亮、字号和颜色差异。

根据关键词生成富文本样式。这个接口不改草稿,只返回可直接传给 add_text 的 text_styles 数组。

请求参数 ​

参数类型必填默认值说明
textstring是—完整文本
keywordstring是—关键词,多个关键词用 `
font_sizenumber否12普通文字大小
keyword_colorstring否#ff7100关键词颜色
keyword_font_sizenumber否15关键词大小
normal_colorstring否#FFFFFF普通文字颜色

请求示例 ​

bash
curl -X POST https://your-domain.example/api/add_text_style \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $VECTCUT_API_KEY" \
  -d '{
    "text": "今天分享三个剪辑技巧",
    "keyword": "剪辑|技巧",
    "font_size": 12,
    "keyword_color": "#ff7100",
    "keyword_font_size": 15
  }'

返回示例 ​

json
{
  "success": true,
  "output": {
    "text": "今天分享三个剪辑技巧",
    "styles": [
      {
        "start": 0,
        "end": 6,
        "style": {
          "size": 12,
          "color": "#FFFFFF",
          "bold": false
        }
      },
      {
        "start": 6,
        "end": 8,
        "style": {
          "size": 15,
          "color": "#ff7100",
          "bold": true
        }
      }
    ],
    "text_styles": [
      {
        "start": 0,
        "end": 6,
        "style": {
          "size": 12,
          "bold": false,
          "italic": false,
          "underline": false,
          "color": "#FFFFFF",
          "alpha": 1.0,
          "align": 1,
          "vertical": false,
          "letter_spacing": 0,
          "line_spacing": 0
        },
        "border": {
          "width": 0
        }
      },
      {
        "start": 6,
        "end": 8,
        "style": {
          "size": 15,
          "bold": true,
          "italic": false,
          "underline": false,
          "color": "#ff7100",
          "alpha": 1.0,
          "align": 1,
          "vertical": false,
          "letter_spacing": 0,
          "line_spacing": 0
        },
        "border": {
          "width": 0
        }
      }
    ]
  },
  "error": ""
}

styles 和 text_styles 是同一份数据的两个兼容字段;把 text_styles 原样传给 add_text 即可。

个人自建服务