Skip to content

[BUG] renderText doesn't verticalAlign #37

Closed

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).

Activity

  1. added this to the v3 milestone on Oct 14, 2026
  2. self-assigned this
    on Oct 14, 2026
  3. matmen commented on Oct 14, 2026

    @matmen
    Collaborator

    Fixed in 3.0.0. The option names were also mixed up: horizontalAlign now takes left/center/right and verticalAlign takes top/middle/bottom. The old values are still accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions