1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:47:44 +00:00

LibGUI: Use the correct font when relayouting Breadcrumbbar

When the system is broadcasting a "system font changed" notification,
the Breadcrumbbar will be notified before its button children. This
means that we have to use the Breadcrumbbar's font() for calculations
inside Breadcrumbbar as the buttons themselves still have the old font
at this point.
This commit is contained in:
Andreas Kling 2023-02-02 14:29:34 +01:00
parent 63ac6ced31
commit 5577d5f789

View file

@ -175,7 +175,9 @@ void Breadcrumbbar::relayout()
for (auto& segment : m_segments) {
VERIFY(segment.button);
auto& button = *segment.button;
auto button_text_width = button.font().width(segment.text);
// NOTE: We use our own font instead of the button's font here in case we're being notified about
// a system font change, and the button hasn't been notified yet.
auto button_text_width = font().width(segment.text);
auto icon_width = button.icon() ? button.icon()->width() : 0;
auto icon_padding = button.icon() ? 4 : 0;