Closed eidloi closed 2 months ago
Is this just a matter of exposing more of the internals?
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: https://github.com/bevyengine/bevy/blob/473577621d2fc640c935340e2334f0ca40587e8e/crates/bevy_text/src/glyph_brush.rs#L101
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.
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.
This was fixed by #10193
Bevy version
0.13
What you did
Debug log any
TextLayoutInfo
to inspect the glyph list.What went wrong
The
TextLayoutInfo
only containsPositionedGlyph
s 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