Skip to content

Chunkified text doesn't properly work in the TextLayout #5623

@bieleluk

Description

@bieleluk

Incomplete chunks at the end of the line

When using the TextLayout to render the left-aligned chunkified text, the text doesn't break only at the entire chunks, i.e.:

Image

Expected layout

8208  8811  1111
1111  11

Root cause

TextLayout uses Spans to render the individual lines, in particular, the function fit_horizontally. The issue is that the function goes only character-by-character and doesn't look at the following characters to see if they would complete a chunk at the beginning of another line.

Fix

We would have to predict if the entire chunk fits the line in the function Span::fit_horizontally

Center and Right alignment do not work at all with chunkified text

When using the center alignment, the first chunk is rendered in the middle of the line, the second in the middle of the right half line, ..., until the text doesn't fit.

Image

Severity

The TextLayout for the centered chunkified text is needed for the Eckhart's PIN Keyboard screen: Figma. For now, the left alignment is used.

Root cause

The functionTextLayout::layout_text uses Spans to render the individual lines. In the normal text, the Span corresponds to one line, and the alignment works properly. After the end of the span, the span is aligned in the remaining space. In the normal text, the remaining space is the entire line.
But in the case of the chunkified text, one span corresponds to one chunk because the chunk gap has to be rendered. This is also the reason for the strange rendering because:
The remaining space for the first chunk is the entire line, the remaining space for the second chunk is the right half of the line, ...

Fix

The alignment should be done once per line, not after the each Span is processed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as expectedcoreTrezor Core firmware. Runs on Trezor Model T and Safe models.

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions