diff options
author | 2024-07-18 22:39:49 +0200 | |
---|---|---|
committer | 2024-07-18 22:39:49 +0200 | |
commit | 23ad15391c88f562c90f4344d3949f76b6f9caf9 (patch) | |
tree | 883f5752e3cfe516ee22048015e9255b502bb04e /graphics/src/text.rs | |
parent | 616689ca54942a13aac3615e571ae995ad4571b6 (diff) | |
parent | 06acb740fba1889c6a9fb48dfa3ae3aaac1df3ab (diff) | |
download | iced-23ad15391c88f562c90f4344d3949f76b6f9caf9.tar.gz iced-23ad15391c88f562c90f4344d3949f76b6f9caf9.tar.bz2 iced-23ad15391c88f562c90f4344d3949f76b6f9caf9.zip |
Merge pull request #2508 from iced-rs/feature/rich-text
`rich_text` and `markdown` widgets
Diffstat (limited to 'graphics/src/text.rs')
-rw-r--r-- | graphics/src/text.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/graphics/src/text.rs b/graphics/src/text.rs index 30269e69..23ec14d4 100644 --- a/graphics/src/text.rs +++ b/graphics/src/text.rs @@ -232,13 +232,14 @@ impl PartialEq for Raw { /// Measures the dimensions of the given [`cosmic_text::Buffer`]. pub fn measure(buffer: &cosmic_text::Buffer) -> Size { - let (width, total_lines) = buffer - .layout_runs() - .fold((0.0, 0usize), |(width, total_lines), run| { - (run.line_w.max(width), total_lines + 1) - }); + let (width, height) = + buffer + .layout_runs() + .fold((0.0, 0.0), |(width, height), run| { + (run.line_w.max(width), height + run.line_height) + }); - Size::new(width, total_lines as f32 * buffer.metrics().line_height) + Size::new(width, height) } /// Returns the attributes of the given [`Font`]. |