Skip to content

Text width miscalculated when setting autoSize on centered or right-aligned text field #10660

@n0samu

Description

@n0samu

Describe the bug

Consider the following sample: NanacaScoreField.zip. This is a simpler demonstration of #1440.

Here is the AS code:

score_txt.autoSize = "right";
score_txt.text = "999.99";

In Ruffle, it looks like this:
image

Notice that the score text is cut off.

Expected behavior

Here is how it appears in Flash:
image

Affected platform

Desktop app

Operating system

Windows 10

Browser

No response

Additional information

The score_txt field is set to right alignment in the Flash editor. The problem persists if the field is set to center alignment, and disappears if the field is set to left alignment. The problem disappears if the AS code that sets autoSize is removed, but persists if autoSize is set to "left", "right", or "center".

I tried adding the following line after

// The edit text's bounds needs to have the padding baked in.

println!("bounds: {:?}\nintrinsic bounds: {:?}", edit_text.bounds, intrinsic_bounds);

According to my understanding of the concept of "intrinsic bounds", they should always start at (0, 0). I noticed that the intrinsic bounds have a nonzero offset_x when there is a problem, whereas offset_x is 0 when Ruffle is working correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtextIssues relating to text rendering/input

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions