pixijs / ui

Commonly used UI components for PixiJS

Home Page:https://pixijs.io/ui/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Input() text is squished

reececomo opened this issue · comments

Current Behavior

Text is squished into a fixed width area:

Screenshot 2024-01-29 at 10 06 32 pm Screenshot 2024-01-29 at 10 06 40 pm Screenshot 2024-01-29 at 10 06 49 pm

Weirdly, placeholder text is unaffected (although it is awfully off-centre for 'center' aligned text):

Screenshot 2024-01-29 at 10 11 56 pm

The amount of squash/stretching appears to be linked to the size of the value field.

Screenshot 2024-01-29 at 10 52 53 pm

Screenshot 2024-01-29 at 10 51 39 pm Screenshot 2024-01-29 at 10 51 42 pm

And finally when no value is provided (same behaviour, width seems to be ~half the width of a single character):

Screenshot 2024-01-29 at 10 53 48 pm

Expected Behavior

Text should appear normally, and not stretched out.

Context

This is the entire code (honestly):

    this.$_nameField = new Input({
      placeholder: 'Enter text',
      bg,
      align: 'center',
      maxLength: 120,
      textStyle: {
        fontFamily: ['Arial', 'sans-serif'],
        fontWeight: 'bold',
        whiteSpace: 'normal',
      },
      value: 'example',
      padding: 8,
    });
    this.$_nameField.zIndex = 1_000;
    this.$rootView.addChild(this.$_nameField);

Is anyone seeing something similar?

entire* code probably should include the bg Graphics object too:

    const borderColor = 0xcccccc;
    const backgroundColor = 0xeeeeee;
    const border = 3;
    const radius = 5;
    const width = 200;
    const height = 50;
    const bg = new Graphics()
      .beginFill(borderColor)
      .drawRoundedRect(0, 0, width, height, radius + border)
      .beginFill(backgroundColor)
      .drawRoundedRect(border, border, width - (border * 2), height - (border * 2), radius);

Hi, @reececomo

Unfortunately I was not able to reproduce this issue. I have also checked all the usages of the pixi Text instance used here, and there are no places in code where size or scale is changing. You can check it here:

ui/src/Input.ts

Line 164 in e77935a

this.inputField = new Text('', textStyle);

this.inputField is only used to get it's size and never set.

So in order to try to help I need either codepen example that reproduces this issue, or link to a repo (maybe if it is opensource)

Yeah all good, I figure we (or a plugin) must be doing something somewhere that's causing this.

Thanks for looking, will close this ticket.