diff options
author | 2023-12-02 16:10:42 +0100 | |
---|---|---|
committer | 2023-12-02 16:10:42 +0100 | |
commit | 8727b3fc50ec251d9c117c51ca1289be5ba9b117 (patch) | |
tree | 802fef9f0b54b6f9cbbeedff14d7f57169db7d6b /graphics/src/text.rs | |
parent | 7f8b17604a31e00becc43130ec516c1a53552c88 (diff) | |
parent | b526ce4958b28208395276dd4078ffe0d780e1d7 (diff) | |
download | iced-8727b3fc50ec251d9c117c51ca1289be5ba9b117.tar.gz iced-8727b3fc50ec251d9c117c51ca1289be5ba9b117.tar.bz2 iced-8727b3fc50ec251d9c117c51ca1289be5ba9b117.zip |
Merge pull request #2154 from iced-rs/fix/text-clipping
Fix text clipping
Diffstat (limited to 'graphics/src/text.rs')
-rw-r--r-- | graphics/src/text.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/graphics/src/text.rs b/graphics/src/text.rs index 7261900e..fc7694c2 100644 --- a/graphics/src/text.rs +++ b/graphics/src/text.rs @@ -76,7 +76,12 @@ pub fn measure(buffer: &cosmic_text::Buffer) -> Size { (run.line_w.max(width), total_lines + 1) }); - Size::new(width, total_lines as f32 * buffer.metrics().line_height) + let (max_width, max_height) = buffer.size(); + + Size::new( + width.min(max_width), + (total_lines as f32 * buffer.metrics().line_height).min(max_height), + ) } /// Returns the attributes of the given [`Font`]. |