tnfe / FFCreator

A fast video processing library based on node.js (一个基于node.js的高速视频制作库)
http://tnfe.github.io/FFCreator/
MIT License
2.86k stars 407 forks source link

FFText如何实现一个段落首行缩进两个汉字 #443

Closed Caisen1988 closed 2 weeks ago

Caisen1988 commented 2 months ago

FFText如何实现一个段落首行缩进两个汉字,感谢!

Caisen1988 commented 2 months ago

已经试了下面方法

  1. 前面添加2个空格
  2. '\u2003\u2003\u2003\u2003'
  3. 使用textIndent 都不行

    if (weatherJson.message['天气概述']) {
            // const indentSpace = '\u2003\u2003'; // 使用 2 个 Em 空格作为缩进
            const weatherSummary = weatherJson.message['天气概述'] || '';
            // const indentedText = `${indentSpace}${weatherSummary}`;
            const text = new FFText({
                text: weatherSummary,
                x: 400,
                y: 390,
                color: '#ffffff',
                width: 1090,
                font: fontPath,
            });
    
            text.setStyle({
                fontSize: 50,
                fontStyle: 'normal',
                fontWeight: 'bold',
                fill: '#ffffff',
                stroke: '#b9b7b7',
                strokeThickness: 3,
                dropShadow: true,
                dropShadowColor: '#000000',
                dropShadowBlur: 3,
                dropShadowAngle: Math.PI / 6,
                dropShadowDistance: 1,
                wordWrap: true,
                wordWrapWidth: 1090,
                breakWords: true,
                align: 'left',
                lineHeight: 60,
                leading: 10,
                letterSpacing: 2,
                textIndent: 100,
            });
            text.addEffect('fadeIn', 0.5, 9.2);
            text.addEffect('fadeOut', 0.1, 33);
            scene.addChild(text);
        }
Caisen1988 commented 1 month ago

@drawcall Hi Could you help to take a look, thank you so much.

drawcall commented 1 month ago

Possibly no good solution for now.