mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
LibGUI: Consider carriage returns when counting lines in a label
We create labels in the Browser from text on web documents, which may use carriage returns. LibGfx will split lines on CR already, but LibGUI would not consider CRs when computing the height of the containing widget. The result was text that would not fit in the label's box.
This commit is contained in:
parent
82ea53cf10
commit
2a021a35fc
2 changed files with 3 additions and 3 deletions
|
@ -96,7 +96,7 @@ int Label::text_calculated_preferred_width() const
|
|||
|
||||
int Label::text_calculated_preferred_height() const
|
||||
{
|
||||
return static_cast<int>(ceilf(font().preferred_line_height()) * (m_text.count("\n"sv) + 1));
|
||||
return static_cast<int>(ceilf(font().preferred_line_height()) * m_text.bytes_as_string_view().count_lines());
|
||||
}
|
||||
|
||||
Optional<UISize> Label::calculated_preferred_size() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue