瀏覽代碼

LibGUI: Redraw widgets when default font changes

LuK1337 4 年之前
父節點
當前提交
8992271c5c
共有 2 個文件被更改,包括 8 次插入2 次删除
  1. 7 2
      Userland/Libraries/LibGUI/Widget.cpp
  2. 1 0
      Userland/Libraries/LibGUI/Widget.h

+ 7 - 2
Userland/Libraries/LibGUI/Widget.cpp

@@ -562,6 +562,8 @@ void Widget::theme_change_event(ThemeChangeEvent&)
 
 void Widget::fonts_change_event(FontsChangeEvent&)
 {
+    if (m_default_font)
+        set_font(nullptr);
 }
 
 void Widget::screen_rects_change_event(ScreenRectsChangeEvent&)
@@ -705,10 +707,13 @@ void Widget::set_font(const Gfx::Font* font)
     if (m_font.ptr() == font)
         return;
 
-    if (!font)
+    if (!font) {
         m_font = Gfx::FontDatabase::default_font();
-    else
+        m_default_font = true;
+    } else {
         m_font = *font;
+        m_default_font = false;
+    }
 
     did_change_font();
     update();

+ 1 - 0
Userland/Libraries/LibGUI/Widget.h

@@ -361,6 +361,7 @@ private:
     bool m_updates_enabled { true };
     bool m_accepts_emoji_input { false };
     bool m_shrink_to_fit { false };
+    bool m_default_font { true };
 
     NonnullRefPtr<Gfx::PaletteImpl> m_palette;