Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextLayoutInfo doesn't contain every processed glyph #13063

Open
eidloi opened this issue Apr 22, 2024 · 3 comments
Open

TextLayoutInfo doesn't contain every processed glyph #13063

eidloi opened this issue Apr 22, 2024 · 3 comments
Labels
A-Text Rendering and layout for characters A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior

Comments

@eidloi
Copy link

eidloi commented Apr 22, 2024

Bevy version

0.13

What you did

Debug log any TextLayoutInfo to inspect the glyph list.

What went wrong

The TextLayoutInfo only contains PositionedGlyphs that are from the outlined list.

Additional information

Interacting with text (i.e. placing a caret, selection) is impossible without knowing the positions of individual glyph and their relation to the sections they came from. While the relation part can be worked around, the position and scale of the rendered glyph is necessary. This info is currently opaque and recalculating it is both expensive and needs copy/paste of private bevy code, such as the GlyphPlacementAdjuster

@eidloi eidloi added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 22, 2024
@alice-i-cecile alice-i-cecile added A-Text Rendering and layout for characters A-UI Graphical user interfaces, styles, layouts, and widgets and removed S-Needs-Triage This issue needs to be labelled labels Apr 22, 2024
@alice-i-cecile
Copy link
Member

Is this just a matter of exposing more of the internals?

@eidloi
Copy link
Author

eidloi commented Apr 22, 2024

Is this just a matter of exposing more of the internals?

Not completely, TextLayoutInfo exposes a list of glyph data calculated when the layout changes. This list however is incomplete, as it only has the outlined glyphs added to it. I think the rendering later on takes this list and does some extra in the Text2D systems, so just adding the rest of the glyphs might cause an issue there (or at least a performance cost).

This is the part that selectively fills the list:

if let Some(outlined_glyph) = section_data.1.font.outline_glyph(glyph) {

So there are multiple issues: The TextLayoutInfo exposes some calculated data and makes it seem that it should have all glyphs. This makes it unsafe to rely on, as the intention of these glyphs to be used as part of Text2D is not documented, nor implied. We also have no way to get the complete list so text-related calculations need to be re-done and the calculations rely on private code.

@jordanhalase
Copy link

I'd just like to add that having access to the processed glyphs would be useful to implement the typewriter effect which is used nearly ubiquitously in RPGs or any game with dialogue boxes. Also in this space it could be used to make text glyphs "jiggle" or fly around the screen into place.

Ensuring that they are all present when you expect them makes this process easier, though I would like to do more testing to see if Bevy could make this process easier in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Text Rendering and layout for characters A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

3 participants