FFCreatorLite icon indicating copy to clipboard operation
FFCreatorLite copied to clipboard

How to center text?

Open nilaybrahmbhatt opened this issue 2 years ago • 4 comments

How can i center text or paragraph in width?

nilaybrahmbhatt avatar Feb 13 '23 16:02 nilaybrahmbhatt

Bump

vzeazy avatar Apr 24 '23 04:04 vzeazy

const text1 = new FFText({
 text: videoTitle,
font: fontPath,
        // x: (width - textBoxWidth) / 2,
        x: `(w-text_w)/2`, // center text 居中显示
        y: config.titleY,
        fontSize: config.titleFontSize
 });

hurely avatar Apr 25 '23 01:04 hurely

@hurely Thanks, will give this a go. Didn't see the textBoxWidth anywhere in the repo. You know if textBoxHeight would also be applicable for the Y co-ordinate?

vzeazy avatar Apr 25 '23 10:04 vzeazy

@hurely Thanks, will give this a go. Didn't see the textBoxWidth anywhere in the repo. You know if textBoxHeight would also be applicable for the Y co-ordinate?

textBoxWidth is not useful,you can just use x:' (w-text_w)/2'

hurely avatar Apr 25 '23 12:04 hurely