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

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. :^)
This commit is contained in:
Andreas Kling 2021-05-20 18:40:48 +02:00
parent 068ddf4513
commit 6a012ad79f
24 changed files with 33 additions and 46 deletions

View file

@ -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

View file

@ -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());

View file

@ -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);

View file

@ -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);

View file

@ -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:

View file

@ -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;

View file

@ -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();

View file

@ -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();
}