Skip to content

[BUG] renderText doesn't verticalAlign #37

@Dad-Ju

Description

@Dad-Ju

Describe the bug
When i want to write a bigger text with a maxWidth in place it does wrap the text but doesn't apply the Alignment

To Reproduce

const fs = require("fs")
const { Image, TextLayout } = require("imagescript")

const maxSize = 600

// add font as needed!

const text = "Thats way to big to fit on one line, please Center it :)"
const font = fs.readFileSync('your font :)')

const genFile = async () => {
    const white = Image.rgbToColor(255,255,255)

    const params = new TextLayout({
        maxWidth: maxSize,
        wrapStyle: 'word',
        verticalAlign: 'center',
        horizontalAlign: 'top'
    })

    const txt = await Image.renderText(font, 50, text, white, params)

    const encoded = await image.encode(1, {creationTime: 0, software: ''});

    fs.writeFileSync('./test-is.png', encoded)
}

genFile()

Expected behavior
Align the Text at the center when set in verticalAlign Options and the text got Wrapped.

Screenshots
image
image

Platform:

  • OS: Windows
  • Environment: NodeJS
  • Version: "imagescript": "^1.3.0", "node": "v20.5.1"

Additional context
It doesn't matter if the text gets composite onto another image (as expected).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions