You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ickshonpe opened this issue
Jun 29, 2023
· 3 comments
· May be fixed by #9341
Labels
A-TextRendering and layout for charactersA-UIGraphical user interfaces, styles, layouts, and widgetsC-FeatureA new feature, making something new possible
What problem does this solve or what need does it fill?
Bevy UI can only draw text horizontally except if you apply rotation to the TextBundle entities transform which breaks the layout.
What solution would you like?
Maybe add a TextWritingMode enum (The relevant property in CSS is called writing-mode) with Horizontal and Vertical variants initially. This isn't a feature that would make sense for Text2dBundle, so it shouldn't be a field that is added to the Text struct (unless we split up Text into Text and Text2d types, which might make sense as their behaviour is very different now).
The Horizontal variant would be what we have now, and the Vertical variant would match the behaviour of writing-mode: vertical-rl in CSS (example: https://www.w3docs.com/tools/editor/9992).
The implementation shouldn't be too tricky. It might be a little challenging if you aren't familiar with the bevy ui internals but still doable.
For rendering, in extract_text_uinodes if TextWritingMode::Vertical is set the transform needs to be rotated by Quat::from_rotation_z(std::f32::consts::FRAC_PI_2). The translation might need adjustment too.
measure_text_system and text_system would also need changes and you'd need a new measure func. It should be enough I think to just wrap the existing TextMeasure in a new Measure type and swap the width and height:
Related taffy issue, to adapt the layout to the writing direction of the text: DioxusLabs/taffy#213
Selene-Amanita
added
A-UI
Graphical user interfaces, styles, layouts, and widgets
S-Blocked
This cannot move forward until something else changes
and removed
S-Needs-Triage
This issue needs to be labelled
S-Blocked
This cannot move forward until something else changes
labels
Jul 3, 2023
#9341 resolves this but the API is a bit mathy and might be quite counterintuitive for some users. It's also completely different to the CSS interface.
A-TextRendering and layout for charactersA-UIGraphical user interfaces, styles, layouts, and widgetsC-FeatureA new feature, making something new possible
What problem does this solve or what need does it fill?
Bevy UI can only draw text horizontally except if you apply rotation to the
TextBundle
entities transform which breaks the layout.What solution would you like?
Maybe add a
TextWritingMode
enum (The relevant property in CSS is called writing-mode) withHorizontal
andVertical
variants initially. This isn't a feature that would make sense forText2dBundle
, so it shouldn't be a field that is added to theText
struct (unless we split upText
intoText
andText2d
types, which might make sense as their behaviour is very different now).The
Horizontal
variant would be what we have now, and theVertical
variant would match the behaviour ofwriting-mode: vertical-rl
in CSS (example: https://www.w3docs.com/tools/editor/9992).The implementation shouldn't be too tricky. It might be a little challenging if you aren't familiar with the bevy ui internals but still doable.
For rendering, in
extract_text_uinodes
ifTextWritingMode::Vertical
is set the transform needs to be rotated byQuat::from_rotation_z(std::f32::consts::FRAC_PI_2)
. The translation might need adjustment too.measure_text_system
andtext_system
would also need changes and you'd need a new measure func. It should be enough I think to just wrap the existingTextMeasure
in a newMeasure
type and swap the width and height:Additional context
https://developer.mozilla.org/en-US/docs/Web/CSS/text-orientation
https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode
https://www.w3docs.com/learn-css/writing-mode.html
The text was updated successfully, but these errors were encountered: