Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/7316-lucastext-layout-quirk |
|
|
||
| for placed_row in &mut rows { | ||
| let mut max_row_height = first_row_min_height.max(placed_row.rect().height()); | ||
| let mut max_row_height = first_row_min_height.at_least(placed_row.height()); |
There was a problem hiding this comment.
This really got me, changing the position here to NaN:
egui/crates/epaint/src/text/text_layout.rs
Line 250 in 4e50c17
Would cause the max_row_height here to change to 0. Took me a bit to see that this was due to getting the height from the rect instead of looking at the size directly.
| ); | ||
| assert_eq!( | ||
| galley.intrinsic_size, | ||
| Vec2::new(0.0, 16.0), |
There was a problem hiding this comment.
Where does 16.0 come from? FontId::default() is 14.0
There was a problem hiding this comment.
This also surprised me, font.row_height() returns 16.0. Seems like this comes from the font_scaling:
egui/crates/epaint/src/text/fonts.rs
Lines 1040 to 1048 in 022d342
For the default font, this seems to be 1.121, so the font gets scaled to 15.694.
Then here we get to ~16.125:
egui/crates/epaint/src/text/font.rs
Line 133 in 7ac137b
There was a problem hiding this comment.
makes sense - let's be explicit in the tests though by replacing the hard-coded 16.0
let row_height = fonts.row_height(font_id):
This makes it less brittle if we change the default FontId. Also, self-documenting.
| merged_galley.mesh_bounds = merged_galley | ||
| .mesh_bounds | ||
| .union(placed_row.visuals.mesh_bounds.translate(new_pos.to_vec2())); |
There was a problem hiding this comment.
What do you think about adding a BirOr override to Rect? We already have it for Response
| merged_galley.mesh_bounds = merged_galley | |
| .mesh_bounds | |
| .union(placed_row.visuals.mesh_bounds.translate(new_pos.to_vec2())); | |
| merged_galley.mesh_bounds |= | |
| placed_row.visuals.mesh_bounds.translate(new_pos.to_vec2()); |
There was a problem hiding this comment.
That'd be neat!
| ); | ||
| assert_eq!( | ||
| galley.intrinsic_size, | ||
| Vec2::new(0.0, 16.0), |
There was a problem hiding this comment.
makes sense - let's be explicit in the tests though by replacing the hard-coded 16.0
let row_height = fonts.row_height(font_id):
This makes it less brittle if we change the default FontId. Also, self-documenting.
…getter to avoid accumulating rounding errors. Also improve tests
* Fixes a bug introduced by #7316 The last `\n` was ignored for texts ending with `\n` in the galley split logic.
Galley::intrinsic_sizeand use it inAtomLayout#7146Previously when galleys were splitted, each exept the last had an extra empty row that had to be removed when they were concated. This changes it to remove the
\nfrom the layout jobs when splitting.