diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-20 18:40:48 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-20 20:55:29 +0200 |
commit | 6a012ad79f95673a36531c27c81e0efa6c6ec664 (patch) | |
tree | 54777eacd8382e76f87d578e57ac080cb531c0e1 /Userland | |
parent | 068ddf4513281c0aa183552273b3b9a811b78263 (diff) | |
download | serenity-6a012ad79f95673a36531c27c81e0efa6c6ec664.zip |
LibGfx: Remove Gfx::FontDatabase::default_bold_font()
Instead use default_font().bold_variant() in cases where we want a bold
variant of the default font. :^)
Diffstat (limited to 'Userland')
23 files changed, 33 insertions, 41 deletions
diff --git a/Userland/Applications/Calendar/AddEventDialog.cpp b/Userland/Applications/Calendar/AddEventDialog.cpp index 0aa92a8140..9f972ea291 100644 --- a/Userland/Applications/Calendar/AddEventDialog.cpp +++ b/Userland/Applications/Calendar/AddEventDialog.cpp @@ -46,7 +46,7 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window) auto& add_label = top_container.add<GUI::Label>("Add title & date:"); add_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); add_label.set_fixed_height(14); - add_label.set_font(Gfx::FontDatabase::default_bold_font()); + add_label.set_font(Gfx::FontDatabase::default_font().bold_variant()); auto& event_title_textbox = top_container.add<GUI::TextBox>(); event_title_textbox.set_fixed_height(20); diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp index bc57d5b4b6..bf0dab3738 100644 --- a/Userland/Applications/HexEditor/HexEditor.cpp +++ b/Userland/Applications/HexEditor/HexEditor.cpp @@ -497,7 +497,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) painter.draw_text( side_offset_rect, line, - is_current_line ? Gfx::FontDatabase::default_bold_font() : font(), + is_current_line ? font().bold_variant() : font(), Gfx::TextAlignment::TopLeft, is_current_line ? palette().ruler_active_text() : palette().ruler_inactive_text()); } diff --git a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp index 70266c8925..8b66213a7c 100644 --- a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp +++ b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp @@ -42,7 +42,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph) container.set_layout<GUI::HorizontalBoxLayout>(); container.set_fixed_size(275, 12); auto& description_label = container.add<GUI::Label>(description); - description_label.set_font(Gfx::FontDatabase::default_bold_font()); + description_label.set_font(Gfx::FontDatabase::default_font().bold_variant()); description_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); auto& label = container.add<GUI::Label>(); label.set_text_alignment(Gfx::TextAlignment::CenterRight); diff --git a/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp b/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp index 9b17340f65..2ff01db2ba 100644 --- a/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp +++ b/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp @@ -45,7 +45,7 @@ public: if (role == GUI::ModelRole::Font) { if (index.column() == 0) { - return Gfx::FontDatabase::default_bold_font(); + return Gfx::FontDatabase::default_font().bold_variant(); } } diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index 4220c0aa8e..58bfa8fd21 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -456,7 +456,7 @@ NonnullRefPtr<GUI::Window> build_process_window(pid_t pid) } auto& process_name_label = hero_container.add<GUI::Label>(); - process_name_label.set_font(Gfx::FontDatabase::default_bold_font()); + process_name_label.set_font(Gfx::FontDatabase::default_font().bold_variant()); process_name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); process_name_label.set_text(String::formatted("{} (PID {})", process_index.sibling_at_column(ProcessModel::Column::Name).data().to_string(), diff --git a/Userland/Demos/LibGfxDemo/main.cpp b/Userland/Demos/LibGfxDemo/main.cpp index 30dcefcb59..a0421adece 100644 --- a/Userland/Demos/LibGfxDemo/main.cpp +++ b/Userland/Demos/LibGfxDemo/main.cpp @@ -147,7 +147,7 @@ void Canvas::draw() painter.draw_rect({ 520, 410, 240, 80 }, Color::DarkGray); painter.draw_text({ 520, 415, 240, 20 }, "Normal text", Gfx::FontDatabase::default_font(), Gfx::TextAlignment::CenterLeft, Color::Red); - painter.draw_text({ 520, 430, 240, 20 }, "Bold text", Gfx::FontDatabase::default_bold_font(), Gfx::TextAlignment::CenterLeft, Color::Green); + painter.draw_text({ 520, 430, 240, 20 }, "Bold text", Gfx::FontDatabase::default_font().bold_variant(), Gfx::TextAlignment::CenterLeft, Color::Green); painter.draw_text({ 520, 450, 240, 20 }, "Normal text (fixed width)", Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Blue); painter.draw_text({ 520, 465, 240, 20 }, "Bold text (fixed width)", Gfx::FontDatabase::default_bold_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Yellow); diff --git a/Userland/DevTools/HackStudio/EditorWrapper.cpp b/Userland/DevTools/HackStudio/EditorWrapper.cpp index 128eff2ca1..26ff288ec8 100644 --- a/Userland/DevTools/HackStudio/EditorWrapper.cpp +++ b/Userland/DevTools/HackStudio/EditorWrapper.cpp @@ -66,7 +66,8 @@ EditorWrapper::~EditorWrapper() void EditorWrapper::set_editor_has_focus(Badge<Editor>, bool focus) { - m_filename_label->set_font(focus ? Gfx::FontDatabase::default_bold_font() : Gfx::FontDatabase::default_font()); + auto& font = Gfx::FontDatabase::default_font(); + m_filename_label->set_font(focus ? font.bold_variant() : font); } LanguageClient& EditorWrapper::language_client() { return m_editor->language_client(); } diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 92921bb6be..db1e05fb56 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -41,6 +41,8 @@ void ChessWidget::paint_event(GUI::PaintEvent& event) Chess::Board& active_board = (m_playback ? board_playback() : board()); + auto& coordinate_font = Gfx::FontDatabase::default_font().bold_variant(); + Chess::Square::for_each([&](Chess::Square sq) { Gfx::IntRect tile_rect; if (side() == Chess::Color::White) { @@ -62,10 +64,10 @@ void ChessWidget::paint_event(GUI::PaintEvent& event) auto shrunken_rect = tile_rect; shrunken_rect.shrink(4, 4); if (sq.rank == coord_rank_file) - painter.draw_text(shrunken_rect, coord.substring_view(0, 1), Gfx::FontDatabase::default_bold_font(), Gfx::TextAlignment::BottomRight, text_color); + painter.draw_text(shrunken_rect, coord.substring_view(0, 1), coordinate_font, Gfx::TextAlignment::BottomRight, text_color); if (sq.file == coord_rank_file) - painter.draw_text(shrunken_rect, coord.substring_view(1, 1), Gfx::FontDatabase::default_bold_font(), Gfx::TextAlignment::TopLeft, text_color); + painter.draw_text(shrunken_rect, coord.substring_view(1, 1), coordinate_font, Gfx::TextAlignment::TopLeft, text_color); } for (auto& m : m_board_markings) { diff --git a/Userland/Games/Solitaire/Card.cpp b/Userland/Games/Solitaire/Card.cpp index 20e79c128e..122abd6c14 100644 --- a/Userland/Games/Solitaire/Card.cpp +++ b/Userland/Games/Solitaire/Card.cpp @@ -88,7 +88,7 @@ Card::Card(Type type, uint8_t value) } Gfx::Painter painter(m_front); - auto& font = Gfx::FontDatabase::default_bold_font(); + auto& font = Gfx::FontDatabase::default_font().bold_variant(); auto label = labels[value]; m_front->fill(Color::White); diff --git a/Userland/Libraries/LibGUI/AboutDialog.cpp b/Userland/Libraries/LibGUI/AboutDialog.cpp index fcac58c045..f0118e667d 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.cpp +++ b/Userland/Libraries/LibGUI/AboutDialog.cpp @@ -63,7 +63,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window label.set_text_alignment(Gfx::TextAlignment::CenterLeft); label.set_fixed_height(14); if (bold) - label.set_font(Gfx::FontDatabase::default_bold_font()); + label.set_font(Gfx::FontDatabase::default_font().bold_variant()); }; make_label(m_name, true); // If we are displaying a dialog for an application, insert 'SerenityOS' below the application name diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp index 7b7aa662c4..107eaccbe5 100644 --- a/Userland/Libraries/LibGUI/Button.cpp +++ b/Userland/Libraries/LibGUI/Button.cpp @@ -75,7 +75,7 @@ void Button::paint_event(PaintEvent& event) painter.blit_disabled(icon_location, *m_icon, m_icon->rect(), palette()); } } - auto& font = is_checked() ? Gfx::FontDatabase::default_bold_font() : this->font(); + auto& font = is_checked() ? this->font().bold_variant() : this->font(); if (m_icon && !text().is_empty()) { content_rect.translate_by(m_icon->width() + icon_spacing(), 0); content_rect.set_width(content_rect.width() - m_icon->width() - icon_spacing()); diff --git a/Userland/Libraries/LibGUI/HeaderView.cpp b/Userland/Libraries/LibGUI/HeaderView.cpp index cb9fe2d202..db0f704bee 100644 --- a/Userland/Libraries/LibGUI/HeaderView.cpp +++ b/Userland/Libraries/LibGUI/HeaderView.cpp @@ -23,7 +23,7 @@ HeaderView::HeaderView(AbstractTableView& table_view, Gfx::Orientation orientati : m_table_view(table_view) , m_orientation(orientation) { - set_font(Gfx::FontDatabase::default_bold_font()); + set_font(Gfx::FontDatabase::default_font().bold_variant()); if (m_orientation == Gfx::Orientation::Horizontal) { set_fixed_height(16); diff --git a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp index 7ea3be7c70..5ab950bf83 100644 --- a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp +++ b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp @@ -28,12 +28,12 @@ WizardPage::WizardPage(const String& title_text, const String& subtitle_text) header_widget.set_layout<VerticalBoxLayout>(); header_widget.layout()->set_margins({ 30, 15, 30, 0 }); m_title_label = header_widget.add<Label>(title_text); - m_title_label->set_font(Gfx::FontDatabase::the().default_bold_font()); - m_title_label->set_fixed_height(Gfx::FontDatabase::the().default_bold_font().glyph_height() + 2); + m_title_label->set_font(Gfx::FontDatabase::default_font().bold_variant()); + m_title_label->set_fixed_height(m_title_label->font().glyph_height() + 2); m_title_label->set_text_alignment(Gfx::TextAlignment::TopLeft); m_subtitle_label = header_widget.add<Label>(subtitle_text); m_subtitle_label->set_text_alignment(Gfx::TextAlignment::TopLeft); - m_title_label->set_fixed_height(Gfx::FontDatabase::the().default_font().glyph_height()); + m_subtitle_label->set_fixed_height(m_subtitle_label->font().glyph_height()); header_widget.layout()->add_spacer(); auto& separator = add<SeparatorWidget>(Gfx::Orientation::Horizontal); diff --git a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp index e8aa426847..185013767d 100644 --- a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp +++ b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp @@ -58,13 +58,13 @@ void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window frame_rect.set_location({ 0, 0 }); Gfx::StylePainter::paint_window_frame(painter, frame_rect, palette); - auto& title_font = FontDatabase::default_bold_font(); + auto& title_font = FontDatabase::default_font().bold_variant(); auto titlebar_rect = this->titlebar_rect(WindowType::Normal, window_rect, palette); auto titlebar_icon_rect = this->titlebar_icon_rect(WindowType::Normal, window_rect, palette); auto titlebar_inner_rect = titlebar_text_rect(WindowType::Normal, window_rect, palette); auto titlebar_title_rect = titlebar_inner_rect; - titlebar_title_rect.set_width(FontDatabase::default_bold_font().width(window_title)); + titlebar_title_rect.set_width(title_font.width(window_title)); auto [title_color, border_color, border_color2, stripes_color, shadow_color] = compute_frame_colors(window_state, palette); @@ -100,12 +100,12 @@ void ClassicWindowTheme::paint_tool_window_frame(Painter& painter, WindowState w frame_rect.set_location({ 0, 0 }); Gfx::StylePainter::paint_window_frame(painter, frame_rect, palette); - auto& title_font = FontDatabase::default_bold_font(); + auto& title_font = FontDatabase::default_font().bold_variant(); auto titlebar_rect = this->titlebar_rect(WindowType::ToolWindow, window_rect, palette); auto titlebar_inner_rect = titlebar_text_rect(WindowType::ToolWindow, window_rect, palette); auto titlebar_title_rect = titlebar_inner_rect; - titlebar_title_rect.set_width(FontDatabase::default_bold_font().width(title_text)); + titlebar_title_rect.set_width(title_font.width(title_text)); auto [title_color, border_color, border_color2, stripes_color, shadow_color] = compute_frame_colors(window_state, palette); @@ -134,7 +134,7 @@ IntRect ClassicWindowTheme::menubar_rect(WindowType window_type, const IntRect& IntRect ClassicWindowTheme::titlebar_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const { - auto& title_font = FontDatabase::default_bold_font(); + auto& title_font = FontDatabase::default_font().bold_variant(); auto window_titlebar_height = titlebar_height(window_type, palette); // FIXME: The top of the titlebar doesn't get redrawn properly if this padding is different int total_vertical_padding = title_font.glyph_height() - 1; @@ -235,7 +235,7 @@ Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, const int ClassicWindowTheme::titlebar_height(WindowType window_type, const Palette& palette) const { - auto& title_font = FontDatabase::default_bold_font(); + auto& title_font = FontDatabase::default_font().bold_variant(); switch (window_type) { case WindowType::Normal: case WindowType::Notification: diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp index 44b934d109..b71bc61c01 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/FontDatabase.cpp @@ -54,16 +54,6 @@ Font& FontDatabase::default_bold_fixed_width_font() return *font; } -Font& FontDatabase::default_bold_font() -{ - static Font* font; - if (!font) { - font = FontDatabase::the().get_by_name("Katica 10 700"); - VERIFY(font); - } - return *font; -} - struct FontDatabase::Private { HashMap<String, RefPtr<Gfx::Font>> full_name_to_font_map; Vector<RefPtr<Typeface>> typefaces; diff --git a/Userland/Libraries/LibGfx/FontDatabase.h b/Userland/Libraries/LibGfx/FontDatabase.h index 30e239784f..64b029dd90 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.h +++ b/Userland/Libraries/LibGfx/FontDatabase.h @@ -35,7 +35,6 @@ public: static FontDatabase& the(); static Font& default_font(); - static Font& default_bold_font(); static Font& default_fixed_width_font(); static Font& default_bold_fixed_width_font(); diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 01bf6b4d68..5fa06a9b31 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -200,7 +200,7 @@ RefPtr<Gfx::Font> StyleProperties::font_fallback(bool monospace, bool bold) cons return Gfx::FontDatabase::default_fixed_width_font(); if (bold) - return Gfx::FontDatabase::default_bold_font(); + return Gfx::FontDatabase::default_font().bold_variant(); return Gfx::FontDatabase::default_font(); } diff --git a/Userland/Services/NotificationServer/NotificationWindow.cpp b/Userland/Services/NotificationServer/NotificationWindow.cpp index de8f989f0b..b05b25398b 100644 --- a/Userland/Services/NotificationServer/NotificationWindow.cpp +++ b/Userland/Services/NotificationServer/NotificationWindow.cpp @@ -82,7 +82,7 @@ NotificationWindow::NotificationWindow(i32 client_id, const String& text, const left_container.set_layout<GUI::VerticalBoxLayout>(); m_title_label = &left_container.add<GUI::Label>(title); - m_title_label->set_font(Gfx::FontDatabase::default_bold_font()); + m_title_label->set_font(Gfx::FontDatabase::default_font().bold_variant()); m_title_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); m_text_label = &left_container.add<GUI::Label>(text); m_text_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); diff --git a/Userland/Services/Taskbar/ShutdownDialog.cpp b/Userland/Services/Taskbar/ShutdownDialog.cpp index 70fe10e798..8bc39e1c50 100644 --- a/Userland/Services/Taskbar/ShutdownDialog.cpp +++ b/Userland/Services/Taskbar/ShutdownDialog.cpp @@ -72,7 +72,7 @@ ShutdownDialog::ShutdownDialog() auto& label = right_container.add<GUI::Label>("What would you like to do?"); label.set_text_alignment(Gfx::TextAlignment::CenterLeft); label.set_fixed_height(22); - label.set_font(Gfx::FontDatabase::default_bold_font()); + label.set_font(Gfx::FontDatabase::default_font().bold_variant()); for (size_t i = 0; i < options.size(); i++) { auto action = options[i]; diff --git a/Userland/Services/Taskbar/TaskbarButton.cpp b/Userland/Services/Taskbar/TaskbarButton.cpp index 62ca821008..e0a3087283 100644 --- a/Userland/Services/Taskbar/TaskbarButton.cpp +++ b/Userland/Services/Taskbar/TaskbarButton.cpp @@ -89,7 +89,7 @@ void TaskbarButton::paint_event(GUI::PaintEvent& event) { VERIFY(icon()); auto& icon = *this->icon(); - auto& font = is_checked() ? Gfx::FontDatabase::default_bold_font() : this->font(); + auto& font = is_checked() ? this->font().bold_variant() : this->font(); auto& window = WindowList::the().ensure_window(m_identifier); GUI::Painter painter(*this); diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index fdcdf48c4e..c700cbf756 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -65,7 +65,7 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu) main_widget.layout()->set_margins({ 3, 3, 3, 1 }); m_start_button = GUI::Button::construct("Serenity"); - m_start_button->set_font(Gfx::FontDatabase::default_bold_font()); + m_start_button->set_font(Gfx::FontDatabase::default_font().bold_variant()); m_start_button->set_icon_spacing(0); m_start_button->set_fixed_size(80, 21); auto app_icon = GUI::Icon::default_icon("ladyball"); diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp index d903db27eb..3d1562b332 100644 --- a/Userland/Services/WindowServer/Menu.cpp +++ b/Userland/Services/WindowServer/Menu.cpp @@ -94,7 +94,7 @@ int Menu::content_width() const for (auto& item : m_items) { if (item.type() != MenuItem::Text) continue; - auto& use_font = item.is_default() ? Gfx::FontDatabase::default_bold_font() : font(); + auto& use_font = item.is_default() ? font().bold_variant() : font(); int text_width = use_font.width(Gfx::parse_ampersand_string(item.text())); if (!item.shortcut_text().is_empty()) { int shortcut_width = use_font.width(item.shortcut_text()); @@ -245,7 +245,7 @@ void Menu::draw() } auto& previous_font = painter.font(); if (item.is_default()) - painter.set_font(Gfx::FontDatabase::default_bold_font()); + painter.set_font(previous_font.bold_variant()); painter.draw_ui_text(text_rect, item.text(), painter.font(), Gfx::TextAlignment::CenterLeft, text_color); if (!item.shortcut_text().is_empty()) { painter.draw_text(item.rect().translated(-right_padding(), 0), item.shortcut_text(), Gfx::TextAlignment::CenterRight, text_color); diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index b6aac44d4f..6ccdae3799 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -99,7 +99,7 @@ const Gfx::Font& WindowManager::font() const const Gfx::Font& WindowManager::window_title_font() const { - return Gfx::FontDatabase::default_bold_font(); + return Gfx::FontDatabase::default_font().bold_variant(); } bool WindowManager::set_resolution(int width, int height, int scale) |