Incorrect alignment for first line of wrapped text in Txt-component

Author: PetLidCreated Apr 1, 2025Updated Aug 30, 2025
Labelsb-bug

Describe the bug When a Txt component contains text that overflows the view width and wrapping is on, the first line of the text is aligned to the right. This seems to only happen when the fontSize is also set explicitly.

It seems to also occur with wrapping disabled when placing a newline in the text.

To Reproduce Steps to reproduce the behavior or a code snippet containing the scene that causes the problem:

typescript
export default makeScene2D(function* (view) {
  const code = createRef<Code>();

  view.add(
      <Txt text={"A very long text that overflows the screen width and then some more.  Help me with my alignment."} textWrap={true} fontSize={30}/>,
  );
});

Expected behavior The first line of text should be left-aligned.

Package versions:

  • core: 3.17.2
  • two: 3.17.2
  • ui: 3.17.2
  • vitePlugin: 3.17.2

Additional context Example Image

Source: motion-canvas/motion-canvas