-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
add line height to TextFont
#16614
base: main
Are you sure you want to change the base?
add line height to TextFont
#16614
Conversation
2904af4
to
52c76ff
Compare
crates/bevy_text/src/text.rs
Outdated
/// If not set, the line height will be 1.2 * `font_size`. | ||
pub line_height: Option<f32>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a point to making this optional, it could just be an f32
with a default value of 1.2 instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's measured in pixels, not multiples of the font size (though that might be a better interface). Working with Options
makes it simpler to implement too IMO, but changing it wouldn't be a huge deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see it's not a scalar. I think then it would better if there was a LineHeight
enum maybe with Px
and Scalar
variants or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that! Best of both worlds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case, should it be a field of TextFont
, or its own component? Being a separate component would make it so it's not a breaking change at all, but I'm not sure yet how to do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise it looks good, the UI text debug examples are still working with different line heights, don't see any problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case, should it be a field of
TextFont
, or its own component? Being a separate component would make it so it's not a breaking change at all, but I'm not sure yet how to do that
The current direction atm with Bevy seems to be less granular APIs so a field on TextFont
is preferable probably. A field is more discoverable than a separate component as well.
2344bdb
to
fb378bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Left a couple comments, mostly about the LineHeight
enum, but also about a potential issue with the line height math.
|
||
impl Default for LineHeight { | ||
fn default() -> Self { | ||
LineHeight::Scalar(1.2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it easier to expand the feature set in the future (by propagating inherited line height across a hierarchy etc) without having to do a breaking change, would it make sense to have a separate LineHeight::Auto
variant as the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would that do?
83f0e91
to
bb38174
Compare
@coreh everything check out? |
At a quick glance, LGTM! 👍 |
do the labels need updated? |
You need to fix the no-std build. It can be in final review after 2 community approvals. |
I'm not sure what I need to do to fix the nostd build, the error was in a different crate than my changes |
Weird. FYI @bushrat011899 |
@Cyborus04 just tested your PR locally, it'll pass the |
bb38174
to
c63bfe5
Compare
I had a suspicion that's all I needed to do, I just wasn't at a computer to do so then |
Objective
Solution
line_height
field toTextFont
to feed intocosmic_text
'sMetrics
.Testing
Text2d
.Text
still needs tested, but I imagine it'll work fine.Showcase
Click to view showcase
With font:
With font:
Migration Guide
TextFont
now has aline_height
field. Any instantiation ofTextFont
that doesn't have..default()
will need to add this field.