Skip to content

Support dynamic text rasterization size #24120

@chronicl

Description

@chronicl

What problem does this solve or what need does it fill?

Bevy currently couples text rasterization size directly to font size, which is also used as a logical unit for UI layout. This makes it difficult to render high resolution text (e.g. for zoomable interfaces like node graphs or other editors) without also affecting layout size.

Existing workarounds such as increasing font size and scaling down via UiTransform, or using UiScale are cumbersome, fragile, and can introduce layout inconsistencies. They also lack flexibility, because layout is calculated before UiTransform scale is applied.

What solution would you like?

A solution that allows dynamic control, ideally hierarchical, over text rasterization resolution independently of layout size would be ideal and was implemented in #24061, however this added too much extra complexity for a relatively niche feature.

What alternative(s) have you considered?

An alternative solution, which scales the logical to physical pixel conversion was implemented by @ickshonpe as https://github.com/ickshonpe/bevy_ui_local_scale. This solution is hierarchical and has less downsides than the other current workarounds, however, you still need to inversely scale via UiTransform for the text to be the desired size on screen, making zoom implementations that want to dynamically change the text rasterization size based on zoom level tricky. Dynamically changing text rasterization size based on zoom level is required for text to maintain good legibility at all zoom level. Small rasterization size reads better when zoomed out, while high rasterization size reads better when zoomed in.

Another possible solution is to support vector based text rendering, which is more expensive (and might look a little worse?), but would be perfect for this use case, but would introduce a completely separate text rendering path - high complexity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenA-TextRendering and layout for charactersC-FeatureA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!S-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    Status

    Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions