Clamp text::measure to Buffer::size
This commit is contained in:
parent
7f8b17604a
commit
99899d49cc
1 changed files with 6 additions and 1 deletions
|
|
@ -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`].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue