mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:32:46 +00:00 
			
		
		
		
	LibGFX: Move default_xxx_font() methods from Font to FontDatabase
When we have an abstract font class it makes no sense to keep these methods in the Font class.
This commit is contained in:
		
							parent
							
								
									1a072a61fb
								
							
						
					
					
						commit
						b4d1390714
					
				
					 48 changed files with 152 additions and 115 deletions
				
			
		|  | @ -30,6 +30,7 @@ | ||||||
| #include <LibGUI/Button.h> | #include <LibGUI/Button.h> | ||||||
| #include <LibGUI/JSSyntaxHighlighter.h> | #include <LibGUI/JSSyntaxHighlighter.h> | ||||||
| #include <LibGUI/TextBox.h> | #include <LibGUI/TextBox.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibJS/Interpreter.h> | #include <LibJS/Interpreter.h> | ||||||
| #include <LibJS/MarkupGenerator.h> | #include <LibJS/MarkupGenerator.h> | ||||||
| #include <LibJS/Parser.h> | #include <LibJS/Parser.h> | ||||||
|  | @ -67,7 +68,7 @@ ConsoleWidget::ConsoleWidget() | ||||||
|     m_input = bottom_container.add<GUI::TextBox>(); |     m_input = bottom_container.add<GUI::TextBox>(); | ||||||
|     m_input->set_syntax_highlighter(make<GUI::JSSyntaxHighlighter>()); |     m_input->set_syntax_highlighter(make<GUI::JSSyntaxHighlighter>()); | ||||||
|     // FIXME: Syntax Highlighting breaks the cursor's position on non fixed-width fonts.
 |     // FIXME: Syntax Highlighting breaks the cursor's position on non fixed-width fonts.
 | ||||||
|     m_input->set_font(Gfx::Font::default_fixed_width_font()); |     m_input->set_font(Gfx::FontDatabase::default_fixed_width_font()); | ||||||
|     m_input->set_history_enabled(true); |     m_input->set_history_enabled(true); | ||||||
| 
 | 
 | ||||||
|     m_input->on_return_pressed = [this] { |     m_input->on_return_pressed = [this] { | ||||||
|  |  | ||||||
|  | @ -30,6 +30,7 @@ | ||||||
| #include <LibGUI/Label.h> | #include <LibGUI/Label.h> | ||||||
| #include <LibGUI/TextBox.h> | #include <LibGUI/TextBox.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
| CalculatorWidget::CalculatorWidget() | CalculatorWidget::CalculatorWidget() | ||||||
|  | @ -39,7 +40,7 @@ CalculatorWidget::CalculatorWidget() | ||||||
|     m_entry = add<GUI::TextBox>(); |     m_entry = add<GUI::TextBox>(); | ||||||
|     m_entry->set_relative_rect(5, 5, 244, 26); |     m_entry->set_relative_rect(5, 5, 244, 26); | ||||||
|     m_entry->set_text_alignment(Gfx::TextAlignment::CenterRight); |     m_entry->set_text_alignment(Gfx::TextAlignment::CenterRight); | ||||||
|     m_entry->set_font(Gfx::Font::default_fixed_width_font()); |     m_entry->set_font(Gfx::FontDatabase::default_fixed_width_font()); | ||||||
| 
 | 
 | ||||||
|     m_label = add<GUI::Label>(); |     m_label = add<GUI::Label>(); | ||||||
|     m_label->set_relative_rect(12, 42, 27, 27); |     m_label->set_relative_rect(12, 42, 27, 27); | ||||||
|  |  | ||||||
|  | @ -38,6 +38,7 @@ | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Color.h> | #include <LibGfx/Color.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| 
 | 
 | ||||||
| static const char* short_month_names[] = { | static const char* short_month_names[] = { | ||||||
|     "Jan", "Feb", "Mar", "Apr", "May", "Jun", |     "Jan", "Feb", "Mar", "Apr", "May", "Jun", | ||||||
|  | @ -65,7 +66,7 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window) | ||||||
|     auto& add_label = top_container.add<GUI::Label>("Add title & date:"); |     auto& add_label = top_container.add<GUI::Label>("Add title & date:"); | ||||||
|     add_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     add_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     add_label.set_fixed_height(14); |     add_label.set_fixed_height(14); | ||||||
|     add_label.set_font(Gfx::Font::default_bold_font()); |     add_label.set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
| 
 | 
 | ||||||
|     auto& event_title_textbox = top_container.add<GUI::TextBox>(); |     auto& event_title_textbox = top_container.add<GUI::TextBox>(); | ||||||
|     event_title_textbox.set_fixed_height(20); |     event_title_textbox.set_fixed_height(20); | ||||||
|  |  | ||||||
|  | @ -40,6 +40,7 @@ | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/Color.h> | #include <LibGfx/Color.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
| int main(int argc, char** argv) | int main(int argc, char** argv) | ||||||
|  | @ -136,7 +137,7 @@ int main(int argc, char** argv) | ||||||
|     selected_calendar_button = toolbar.add<GUI::Button>(calendar_widget.selected_calendar_text()); |     selected_calendar_button = toolbar.add<GUI::Button>(calendar_widget.selected_calendar_text()); | ||||||
|     selected_calendar_button->set_fixed_width(70); |     selected_calendar_button->set_fixed_width(70); | ||||||
|     selected_calendar_button->set_button_style(Gfx::ButtonStyle::CoolBar); |     selected_calendar_button->set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|     selected_calendar_button->set_font(Gfx::Font::default_bold_fixed_width_font()); |     selected_calendar_button->set_font(Gfx::FontDatabase::default_bold_fixed_width_font()); | ||||||
|     selected_calendar_button->on_click = [&](auto) { |     selected_calendar_button->on_click = [&](auto) { | ||||||
|         calendar_widget.toggle_mode(); |         calendar_widget.toggle_mode(); | ||||||
|         selected_calendar_button->set_text(calendar_widget.selected_calendar_text()); |         selected_calendar_button->set_text(calendar_widget.selected_calendar_text()); | ||||||
|  |  | ||||||
|  | @ -37,6 +37,7 @@ | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Point.h> | #include <LibGfx/Point.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
|  | @ -62,7 +63,7 @@ int main(int argc, char** argv) | ||||||
|     RefPtr<Gfx::Font> edited_font; |     RefPtr<Gfx::Font> edited_font; | ||||||
|     if (path == nullptr) { |     if (path == nullptr) { | ||||||
|         path = "/tmp/saved.font"; |         path = "/tmp/saved.font"; | ||||||
|         edited_font = Gfx::Font::default_font().clone(); |         edited_font = Gfx::FontDatabase::default_font().clone(); | ||||||
|     } else { |     } else { | ||||||
|         edited_font = Gfx::Font::load_from_file(path)->clone(); |         edited_font = Gfx::Font::load_from_file(path)->clone(); | ||||||
|         if (!edited_font) { |         if (!edited_font) { | ||||||
|  |  | ||||||
|  | @ -33,6 +33,7 @@ | ||||||
| #include <LibGUI/ScrollBar.h> | #include <LibGUI/ScrollBar.h> | ||||||
| #include <LibGUI/TextEditor.h> | #include <LibGUI/TextEditor.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
|  | @ -43,7 +44,7 @@ HexEditor::HexEditor() | ||||||
| { | { | ||||||
|     set_focus_policy(GUI::FocusPolicy::StrongFocus); |     set_focus_policy(GUI::FocusPolicy::StrongFocus); | ||||||
|     set_scrollbars_enabled(true); |     set_scrollbars_enabled(true); | ||||||
|     set_font(Gfx::Font::default_fixed_width_font()); |     set_font(Gfx::FontDatabase::default_fixed_width_font()); | ||||||
|     set_background_role(ColorRole::Base); |     set_background_role(ColorRole::Base); | ||||||
|     set_foreground_role(ColorRole::BaseText); |     set_foreground_role(ColorRole::BaseText); | ||||||
|     vertical_scrollbar().set_step(line_height()); |     vertical_scrollbar().set_step(line_height()); | ||||||
|  | @ -520,7 +521,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) | ||||||
|         painter.draw_text( |         painter.draw_text( | ||||||
|             side_offset_rect, |             side_offset_rect, | ||||||
|             line, |             line, | ||||||
|             is_current_line ? Gfx::Font::default_bold_font() : font(), |             is_current_line ? Gfx::FontDatabase::default_bold_font() : font(), | ||||||
|             Gfx::TextAlignment::TopLeft, |             Gfx::TextAlignment::TopLeft, | ||||||
|             is_current_line ? palette().ruler_active_text() : palette().ruler_inactive_text()); |             is_current_line ? palette().ruler_active_text() : palette().ruler_inactive_text()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -30,6 +30,7 @@ | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGUI/ScrollBar.h> | #include <LibGUI/ScrollBar.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <math.h> | #include <math.h> | ||||||
| 
 | 
 | ||||||
| constexpr int note_height = 20; | constexpr int note_height = 20; | ||||||
|  | @ -142,7 +143,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event) | ||||||
|         const char* note_name = note_names[note % notes_per_octave]; |         const char* note_name = note_names[note % notes_per_octave]; | ||||||
| 
 | 
 | ||||||
|         painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft); |         painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft); | ||||||
|         note_name_rect.move_by(Gfx::Font::default_font().width(note_name) + 2, 0); |         note_name_rect.move_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0); | ||||||
|         if (note % notes_per_octave == 0) |         if (note % notes_per_octave == 0) | ||||||
|             painter.draw_text(note_name_rect, String::formatted("{}", note / notes_per_octave + 1), Gfx::TextAlignment::CenterLeft); |             painter.draw_text(note_name_rect, String::formatted("{}", note / notes_per_octave + 1), Gfx::TextAlignment::CenterLeft); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -43,6 +43,7 @@ | ||||||
| #include <LibGUI/TabWidget.h> | #include <LibGUI/TabWidget.h> | ||||||
| #include <LibGUI/TextEditor.h> | #include <LibGUI/TextEditor.h> | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| 
 | 
 | ||||||
| REGISTER_WIDGET(Spreadsheet, ConditionsView); | REGISTER_WIDGET(Spreadsheet, ConditionsView); | ||||||
| 
 | 
 | ||||||
|  | @ -437,7 +438,7 @@ ConditionView::ConditionView(ConditionalFormat& fmt) | ||||||
| 
 | 
 | ||||||
|     formula_editor.set_syntax_highlighter(make<GUI::JSSyntaxHighlighter>()); |     formula_editor.set_syntax_highlighter(make<GUI::JSSyntaxHighlighter>()); | ||||||
|     formula_editor.set_should_hide_unnecessary_scrollbars(true); |     formula_editor.set_should_hide_unnecessary_scrollbars(true); | ||||||
|     formula_editor.set_font(&Gfx::Font::default_fixed_width_font()); |     formula_editor.set_font(&Gfx::FontDatabase::default_fixed_width_font()); | ||||||
|     formula_editor.on_change = [&] { |     formula_editor.on_change = [&] { | ||||||
|         m_format.condition = formula_editor.text(); |         m_format.condition = formula_editor.text(); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -38,6 +38,7 @@ | ||||||
| #include <LibGUI/Splitter.h> | #include <LibGUI/Splitter.h> | ||||||
| #include <LibGUI/TabWidget.h> | #include <LibGUI/TabWidget.h> | ||||||
| #include <LibGUI/TextEditor.h> | #include <LibGUI/TextEditor.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
| namespace Spreadsheet { | namespace Spreadsheet { | ||||||
|  | @ -65,7 +66,7 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& cell_value_editor = top_bar.add<GUI::TextEditor>(GUI::TextEditor::Type::SingleLine); |     auto& cell_value_editor = top_bar.add<GUI::TextEditor>(GUI::TextEditor::Type::SingleLine); | ||||||
|     cell_value_editor.set_font(Gfx::Font::default_fixed_width_font()); |     cell_value_editor.set_font(Gfx::FontDatabase::default_fixed_width_font()); | ||||||
|     cell_value_editor.set_scrollbars_enabled(false); |     cell_value_editor.set_scrollbars_enabled(false); | ||||||
| 
 | 
 | ||||||
|     cell_value_editor.set_syntax_highlighter(make<CellSyntaxHighlighter>()); |     cell_value_editor.set_syntax_highlighter(make<CellSyntaxHighlighter>()); | ||||||
|  |  | ||||||
|  | @ -33,6 +33,7 @@ | ||||||
| #include <LibGUI/Label.h> | #include <LibGUI/Label.h> | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|  | @ -61,7 +62,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph) | ||||||
|         container.set_layout<GUI::HorizontalBoxLayout>(); |         container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|         container.set_fixed_size(275, 12); |         container.set_fixed_size(275, 12); | ||||||
|         auto& description_label = container.add<GUI::Label>(description); |         auto& description_label = container.add<GUI::Label>(description); | ||||||
|         description_label.set_font(Gfx::Font::default_bold_font()); |         description_label.set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
|         description_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         description_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         auto& label = container.add<GUI::Label>(); |         auto& label = container.add<GUI::Label>(); | ||||||
|         label.set_text_alignment(Gfx::TextAlignment::CenterRight); |         label.set_text_alignment(Gfx::TextAlignment::CenterRight); | ||||||
|  |  | ||||||
|  | @ -43,6 +43,7 @@ | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| 
 | 
 | ||||||
|  | @ -195,14 +196,14 @@ int main(int argc, char** argv) | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         auto& content_title = title_box.add<GUI::Label>(); |         auto& content_title = title_box.add<GUI::Label>(); | ||||||
|         content_title.set_font(Gfx::Font::default_bold_font()); |         content_title.set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
|         content_title.set_text(page.title); |         content_title.set_text(page.title); | ||||||
|         content_title.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         content_title.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         content_title.set_fixed_height(10); |         content_title.set_fixed_height(10); | ||||||
| 
 | 
 | ||||||
|         for (auto& paragraph : page.content) { |         for (auto& paragraph : page.content) { | ||||||
|             auto& content_text = content.add<TextWidget>(); |             auto& content_text = content.add<TextWidget>(); | ||||||
|             content_text.set_font(Gfx::Font::default_font()); |             content_text.set_font(Gfx::FontDatabase::default_font()); | ||||||
|             content_text.set_text(paragraph); |             content_text.set_text(paragraph); | ||||||
|             content_text.set_text_alignment(Gfx::TextAlignment::TopLeft); |             content_text.set_text_alignment(Gfx::TextAlignment::TopLeft); | ||||||
|             content_text.set_line_height(12); |             content_text.set_line_height(12); | ||||||
|  | @ -210,7 +211,7 @@ int main(int argc, char** argv) | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         auto& menu_option = menu.add<UnuncheckableButton>(); |         auto& menu_option = menu.add<UnuncheckableButton>(); | ||||||
|         menu_option.set_font(Gfx::Font::default_font()); |         menu_option.set_font(Gfx::FontDatabase::default_font()); | ||||||
|         menu_option.set_text(page.menu_name); |         menu_option.set_text(page.menu_name); | ||||||
|         menu_option.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         menu_option.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         menu_option.set_fixed_height(20); |         menu_option.set_fixed_height(20); | ||||||
|  |  | ||||||
|  | @ -31,6 +31,7 @@ | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Painter.h> | #include <LibGfx/Painter.h> | ||||||
| #include <LibGfx/Path.h> | #include <LibGfx/Path.h> | ||||||
| 
 | 
 | ||||||
|  | @ -161,10 +162,10 @@ void Canvas::draw() | ||||||
|     painter.draw_text({ 520, 360, 240, 30 }, "Emojis! 🙂😂🐞🦄", Gfx::TextAlignment::Center, Color::White); |     painter.draw_text({ 520, 360, 240, 30 }, "Emojis! 🙂😂🐞🦄", Gfx::TextAlignment::Center, Color::White); | ||||||
| 
 | 
 | ||||||
|     painter.draw_rect({ 520, 410, 240, 80 }, Color::DarkGray); |     painter.draw_rect({ 520, 410, 240, 80 }, Color::DarkGray); | ||||||
|     painter.draw_text({ 520, 415, 240, 20 }, "Normal text", Gfx::Font::default_font(), Gfx::TextAlignment::CenterLeft, Color::Red); |     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::Font::default_bold_font(), Gfx::TextAlignment::CenterLeft, Color::Green); |     painter.draw_text({ 520, 430, 240, 20 }, "Bold text", Gfx::FontDatabase::default_bold_font(), Gfx::TextAlignment::CenterLeft, Color::Green); | ||||||
|     painter.draw_text({ 520, 450, 240, 20 }, "Normal text (fixed width)", Gfx::Font::default_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Blue); |     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::Font::default_bold_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Yellow); |     painter.draw_text({ 520, 465, 240, 20 }, "Bold text (fixed width)", Gfx::FontDatabase::default_bold_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Yellow); | ||||||
| 
 | 
 | ||||||
|     auto font = Gfx::Font::load_from_file("/res/fonts/PebbletonBold14.font"); |     auto font = Gfx::Font::load_from_file("/res/fonts/PebbletonBold14.font"); | ||||||
|     painter.draw_rect({ 520, 510, 240, 30 }, Color::DarkGray); |     painter.draw_rect({ 520, 510, 240, 30 }, Color::DarkGray); | ||||||
|  |  | ||||||
|  | @ -55,6 +55,7 @@ | ||||||
| #include <LibGUI/Variant.h> | #include <LibGUI/Variant.h> | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
| class ListViewModel final : public GUI::Model { | class ListViewModel final : public GUI::Model { | ||||||
|  | @ -442,7 +443,7 @@ int main(int argc, char** argv) | ||||||
|     input_group_box.layout()->add_spacer(); |     input_group_box.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& input_label = input_group_box.add<GUI::Label>("Valued user input goes here."); |     auto& input_label = input_group_box.add<GUI::Label>("Valued user input goes here."); | ||||||
|     input_label.set_font(Gfx::Font::default_bold_font()); |     input_label.set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
| 
 | 
 | ||||||
|     input_group_box.layout()->add_spacer(); |     input_group_box.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -32,6 +32,7 @@ | ||||||
| #include <LibGUI/InputBox.h> | #include <LibGUI/InputBox.h> | ||||||
| #include <LibGUI/Label.h> | #include <LibGUI/Label.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| 
 | 
 | ||||||
| namespace HackStudio { | namespace HackStudio { | ||||||
| 
 | 
 | ||||||
|  | @ -77,7 +78,7 @@ EditorWrapper::~EditorWrapper() | ||||||
| 
 | 
 | ||||||
| void EditorWrapper::set_editor_has_focus(Badge<Editor>, bool focus) | void EditorWrapper::set_editor_has_focus(Badge<Editor>, bool focus) | ||||||
| { | { | ||||||
|     m_filename_label->set_font(focus ? Gfx::Font::default_bold_font() : Gfx::Font::default_font()); |     m_filename_label->set_font(focus ? Gfx::FontDatabase::default_bold_font() : Gfx::FontDatabase::default_font()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,6 +32,7 @@ | ||||||
| #include <LibGUI/Button.h> | #include <LibGUI/Button.h> | ||||||
| #include <LibGUI/TableView.h> | #include <LibGUI/TableView.h> | ||||||
| #include <LibGUI/TextBox.h> | #include <LibGUI/TextBox.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| 
 | 
 | ||||||
| namespace HackStudio { | namespace HackStudio { | ||||||
| 
 | 
 | ||||||
|  | @ -78,7 +79,7 @@ public: | ||||||
|             return Gfx::TextAlignment::CenterLeft; |             return Gfx::TextAlignment::CenterLeft; | ||||||
|         if (role == GUI::ModelRole::Font) { |         if (role == GUI::ModelRole::Font) { | ||||||
|             if (index.column() == Column::MatchedText) |             if (index.column() == Column::MatchedText) | ||||||
|                 return Gfx::Font::default_fixed_width_font(); |                 return Gfx::FontDatabase::default_fixed_width_font(); | ||||||
|             return {}; |             return {}; | ||||||
|         } |         } | ||||||
|         if (role == GUI::ModelRole::Display) { |         if (role == GUI::ModelRole::Display) { | ||||||
|  |  | ||||||
|  | @ -31,6 +31,7 @@ | ||||||
| #include <LibGUI/ScrollBar.h> | #include <LibGUI/ScrollBar.h> | ||||||
| #include <LibGfx/Color.h> | #include <LibGfx/Color.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
| // #define DEBUG_DIFF
 | // #define DEBUG_DIFF
 | ||||||
|  | @ -180,7 +181,7 @@ DiffViewer::DiffViewer(const String& original, const String& diff) | ||||||
| 
 | 
 | ||||||
| void DiffViewer::setup_properties() | void DiffViewer::setup_properties() | ||||||
| { | { | ||||||
|     set_font(Gfx::Font::default_fixed_width_font()); |     set_font(Gfx::FontDatabase::default_fixed_width_font()); | ||||||
|     set_background_role(ColorRole::Base); |     set_background_role(ColorRole::Base); | ||||||
|     set_foreground_role(ColorRole::BaseText); |     set_foreground_role(ColorRole::BaseText); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -75,6 +75,7 @@ | ||||||
| #include <LibGUI/TreeView.h> | #include <LibGUI/TreeView.h> | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibThread/Lock.h> | #include <LibThread/Lock.h> | ||||||
| #include <LibThread/Thread.h> | #include <LibThread/Thread.h> | ||||||
| #include <LibVT/TerminalWidget.h> | #include <LibVT/TerminalWidget.h> | ||||||
|  | @ -718,7 +719,7 @@ void HackStudioWidget::create_form_editor(GUI::Widget& parent) | ||||||
|         auto& label = wrapper.add<GUI::Label>(text); |         auto& label = wrapper.add<GUI::Label>(text); | ||||||
|         label.set_fill_with_background_color(true); |         label.set_fill_with_background_color(true); | ||||||
|         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         label.set_font(Gfx::Font::default_bold_font()); |         label.set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
|         label.set_fixed_height(16); |         label.set_fixed_height(16); | ||||||
|         wrapper.add_child(pane_widget); |         wrapper.add_child(pane_widget); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -32,6 +32,7 @@ | ||||||
| #include <LibGUI/MessageBox.h> | #include <LibGUI/MessageBox.h> | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Path.h> | #include <LibGfx/Path.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| 
 | 
 | ||||||
|  | @ -83,10 +84,10 @@ void ChessWidget::paint_event(GUI::PaintEvent& event) | ||||||
|             auto shrunken_rect = tile_rect; |             auto shrunken_rect = tile_rect; | ||||||
|             shrunken_rect.shrink(4, 4); |             shrunken_rect.shrink(4, 4); | ||||||
|             if (sq.rank == coord_rank_file) |             if (sq.rank == coord_rank_file) | ||||||
|                 painter.draw_text(shrunken_rect, coord.substring_view(0, 1), Gfx::Font::default_bold_font(), Gfx::TextAlignment::BottomRight, text_color); |                 painter.draw_text(shrunken_rect, coord.substring_view(0, 1), Gfx::FontDatabase::default_bold_font(), Gfx::TextAlignment::BottomRight, text_color); | ||||||
| 
 | 
 | ||||||
|             if (sq.file == coord_rank_file) |             if (sq.file == coord_rank_file) | ||||||
|                 painter.draw_text(shrunken_rect, coord.substring_view(1, 1), Gfx::Font::default_bold_font(), Gfx::TextAlignment::TopLeft, text_color); |                 painter.draw_text(shrunken_rect, coord.substring_view(1, 1), Gfx::FontDatabase::default_bold_font(), Gfx::TextAlignment::TopLeft, text_color); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         for (auto& m : m_board_markings) { |         for (auto& m : m_board_markings) { | ||||||
|  |  | ||||||
|  | @ -29,12 +29,13 @@ | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| 
 | 
 | ||||||
| SnakeGame::SnakeGame() | SnakeGame::SnakeGame() | ||||||
| { | { | ||||||
|     set_font(Gfx::Font::default_bold_fixed_width_font()); |     set_font(Gfx::FontDatabase::default_bold_fixed_width_font()); | ||||||
|     m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/paprika.png")); |     m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/paprika.png")); | ||||||
|     m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/eggplant.png")); |     m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/eggplant.png")); | ||||||
|     m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/cauliflower.png")); |     m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/cauliflower.png")); | ||||||
|  |  | ||||||
|  | @ -27,6 +27,7 @@ | ||||||
| #include "Card.h" | #include "Card.h" | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| 
 | 
 | ||||||
| static const NonnullRefPtr<Gfx::CharacterBitmap> s_diamond = Gfx::CharacterBitmap::create_from_ascii( | static const NonnullRefPtr<Gfx::CharacterBitmap> s_diamond = Gfx::CharacterBitmap::create_from_ascii( | ||||||
|     "    #    " |     "    #    " | ||||||
|  | @ -105,7 +106,7 @@ Card::Card(Type type, uint8_t value) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Gfx::Painter painter(m_front); |     Gfx::Painter painter(m_front); | ||||||
|     auto& font = Gfx::Font::default_bold_font(); |     auto& font = Gfx::FontDatabase::default_bold_font(); | ||||||
|     static const String labels[] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" }; |     static const String labels[] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" }; | ||||||
| 
 | 
 | ||||||
|     auto label = labels[value]; |     auto label = labels[value]; | ||||||
|  |  | ||||||
|  | @ -33,6 +33,7 @@ | ||||||
| #include <LibGUI/Label.h> | #include <LibGUI/Label.h> | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| 
 | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
|  | @ -82,7 +83,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window | ||||||
|         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         label.set_fixed_height(14); |         label.set_fixed_height(14); | ||||||
|         if (bold) |         if (bold) | ||||||
|             label.set_font(Gfx::Font::default_bold_font()); |             label.set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
|     }; |     }; | ||||||
|     make_label(m_name, true); |     make_label(m_name, true); | ||||||
|     // If we are displaying a dialog for an application, insert 'SerenityOS' below the application name
 |     // If we are displaying a dialog for an application, insert 'SerenityOS' below the application name
 | ||||||
|  |  | ||||||
|  | @ -30,6 +30,7 @@ | ||||||
| #include <LibGUI/Button.h> | #include <LibGUI/Button.h> | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | @ -89,7 +90,7 @@ void Button::paint_event(PaintEvent& event) | ||||||
|             painter.blit_disabled(icon_location, *m_icon, m_icon->rect(), palette()); |             painter.blit_disabled(icon_location, *m_icon, m_icon->rect(), palette()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     auto& font = is_checked() ? Gfx::Font::default_bold_font() : this->font(); |     auto& font = is_checked() ? Gfx::FontDatabase::default_bold_font() : this->font(); | ||||||
|     if (m_icon && !text().is_empty()) { |     if (m_icon && !text().is_empty()) { | ||||||
|         content_rect.move_by(m_icon->width() + 4, 0); |         content_rect.move_by(m_icon->width() + 4, 0); | ||||||
|         content_rect.set_width(content_rect.width() - m_icon->width() - 4); |         content_rect.set_width(content_rect.width() - m_icon->width() - 4); | ||||||
|  |  | ||||||
|  | @ -32,6 +32,7 @@ | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
|  | @ -72,7 +73,7 @@ Calendar::Calendar(Core::DateTime date_time) | ||||||
|     m_day_name_container->set_background_role(Gfx::ColorRole::HoverHighlight); |     m_day_name_container->set_background_role(Gfx::ColorRole::HoverHighlight); | ||||||
|     for (auto& day : m_day_names) { |     for (auto& day : m_day_names) { | ||||||
|         day = m_day_name_container->add<GUI::Label>(); |         day = m_day_name_container->add<GUI::Label>(); | ||||||
|         day->set_font(Gfx::Font::default_bold_font()); |         day->set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     m_calendar_tile_container = add<GUI::Widget>(); |     m_calendar_tile_container = add<GUI::Widget>(); | ||||||
|  | @ -357,13 +358,13 @@ void Calendar::CalendarTile::paint_event(GUI::PaintEvent& event) | ||||||
|         } else if (is_selected()) { |         } else if (is_selected()) { | ||||||
|             painter.draw_rect(frame_inner_rect(), palette().base_text()); |             painter.draw_rect(frame_inner_rect(), palette().base_text()); | ||||||
|         } |         } | ||||||
|         painter.draw_text(day_rect, display_date, Gfx::Font::default_bold_font(), Gfx::TextAlignment::Center, palette().base_text()); |         painter.draw_text(day_rect, display_date, Gfx::FontDatabase::default_bold_font(), Gfx::TextAlignment::Center, palette().base_text()); | ||||||
|     } else if (is_outside_selection()) { |     } else if (is_outside_selection()) { | ||||||
|         painter.draw_text(day_rect, display_date, Gfx::Font::default_font(), Gfx::TextAlignment::Center, Color::LightGray); |         painter.draw_text(day_rect, display_date, Gfx::FontDatabase::default_font(), Gfx::TextAlignment::Center, Color::LightGray); | ||||||
|     } else { |     } else { | ||||||
|         if (!has_grid() && is_selected()) |         if (!has_grid() && is_selected()) | ||||||
|             painter.draw_rect(frame_inner_rect(), palette().base_text()); |             painter.draw_rect(frame_inner_rect(), palette().base_text()); | ||||||
|         painter.draw_text(day_rect, display_date, Gfx::Font::default_font(), Gfx::TextAlignment::Center, palette().base_text()); |         painter.draw_text(day_rect, display_date, Gfx::FontDatabase::default_font(), Gfx::TextAlignment::Center, palette().base_text()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -40,6 +40,7 @@ | ||||||
| #include <LibGUI/SortingProxyModel.h> | #include <LibGUI/SortingProxyModel.h> | ||||||
| #include <LibGUI/TextBox.h> | #include <LibGUI/TextBox.h> | ||||||
| #include <LibGUI/ToolBar.h> | #include <LibGUI/ToolBar.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
|  | @ -253,7 +254,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const | ||||||
|         m_preview_image->set_fixed_size(160, 160); |         m_preview_image->set_fixed_size(160, 160); | ||||||
| 
 | 
 | ||||||
|         m_preview_name_label = m_preview_container->add<Label>(); |         m_preview_name_label = m_preview_container->add<Label>(); | ||||||
|         m_preview_name_label->set_font(Gfx::Font::default_bold_font()); |         m_preview_name_label->set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
|         m_preview_name_label->set_fixed_height(m_preview_name_label->font().glyph_height()); |         m_preview_name_label->set_fixed_height(m_preview_name_label->font().glyph_height()); | ||||||
| 
 | 
 | ||||||
|         m_preview_geometry_label = m_preview_container->add<Label>(); |         m_preview_geometry_label = m_preview_container->add<Label>(); | ||||||
|  |  | ||||||
|  | @ -31,6 +31,7 @@ | ||||||
| #include <LibGUI/Model.h> | #include <LibGUI/Model.h> | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | @ -42,7 +43,7 @@ HeaderView::HeaderView(AbstractTableView& table_view, Gfx::Orientation orientati | ||||||
|     : m_table_view(table_view) |     : m_table_view(table_view) | ||||||
|     , m_orientation(orientation) |     , m_orientation(orientation) | ||||||
| { | { | ||||||
|     set_font(Gfx::Font::default_bold_font()); |     set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
| 
 | 
 | ||||||
|     if (m_orientation == Gfx::Orientation::Horizontal) { |     if (m_orientation == Gfx::Orientation::Horizontal) { | ||||||
|         set_fixed_height(16); |         set_fixed_height(16); | ||||||
|  |  | ||||||
|  | @ -72,7 +72,7 @@ TextEditor::TextEditor(Type type) | ||||||
|         set_visualize_trailing_whitespace(false); |         set_visualize_trailing_whitespace(false); | ||||||
|     set_scrollbars_enabled(is_multi_line()); |     set_scrollbars_enabled(is_multi_line()); | ||||||
|     if (is_multi_line()) |     if (is_multi_line()) | ||||||
|         set_font(Gfx::Font::default_fixed_width_font()); |         set_font(Gfx::FontDatabase::default_fixed_width_font()); | ||||||
|     vertical_scrollbar().set_step(line_height()); |     vertical_scrollbar().set_step(line_height()); | ||||||
|     m_cursor = { 0, 0 }; |     m_cursor = { 0, 0 }; | ||||||
|     m_automatic_selection_scroll_timer = add<Core::Timer>(100, [this] { |     m_automatic_selection_scroll_timer = add<Core::Timer>(100, [this] { | ||||||
|  |  | ||||||
|  | @ -61,6 +61,7 @@ | ||||||
| #include <LibGUI/WindowServerConnection.h> | #include <LibGUI/WindowServerConnection.h> | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| 
 | 
 | ||||||
|  | @ -127,7 +128,7 @@ Widget::Widget() | ||||||
|     : Core::Object(nullptr, true) |     : Core::Object(nullptr, true) | ||||||
|     , m_background_role(Gfx::ColorRole::Window) |     , m_background_role(Gfx::ColorRole::Window) | ||||||
|     , m_foreground_role(Gfx::ColorRole::WindowText) |     , m_foreground_role(Gfx::ColorRole::WindowText) | ||||||
|     , m_font(Gfx::Font::default_font()) |     , m_font(Gfx::FontDatabase::default_font()) | ||||||
|     , m_palette(Application::the()->palette().impl()) |     , m_palette(Application::the()->palette().impl()) | ||||||
| { | { | ||||||
|     REGISTER_RECT_PROPERTY("relative_rect", relative_rect, set_relative_rect); |     REGISTER_RECT_PROPERTY("relative_rect", relative_rect, set_relative_rect); | ||||||
|  | @ -645,7 +646,7 @@ void Widget::set_font(const Gfx::Font* font) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|     if (!font) |     if (!font) | ||||||
|         m_font = Gfx::Font::default_font(); |         m_font = Gfx::FontDatabase::default_font(); | ||||||
|     else |     else | ||||||
|         m_font = *font; |         m_font = *font; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -27,6 +27,7 @@ | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/ClassicWindowTheme.h> | #include <LibGfx/ClassicWindowTheme.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Painter.h> | #include <LibGfx/Painter.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
|  | @ -73,13 +74,13 @@ void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window | ||||||
|     frame_rect.set_location({ 0, 0 }); |     frame_rect.set_location({ 0, 0 }); | ||||||
|     Gfx::StylePainter::paint_window_frame(painter, frame_rect, palette); |     Gfx::StylePainter::paint_window_frame(painter, frame_rect, palette); | ||||||
| 
 | 
 | ||||||
|     auto& title_font = Font::default_bold_font(); |     auto& title_font = FontDatabase::default_bold_font(); | ||||||
| 
 | 
 | ||||||
|     auto titlebar_rect = title_bar_rect(WindowType::Normal, window_rect, palette); |     auto titlebar_rect = title_bar_rect(WindowType::Normal, window_rect, palette); | ||||||
|     auto titlebar_icon_rect = title_bar_icon_rect(WindowType::Normal, window_rect, palette); |     auto titlebar_icon_rect = title_bar_icon_rect(WindowType::Normal, window_rect, palette); | ||||||
|     auto titlebar_inner_rect = title_bar_text_rect(WindowType::Normal, window_rect, palette); |     auto titlebar_inner_rect = title_bar_text_rect(WindowType::Normal, window_rect, palette); | ||||||
|     auto titlebar_title_rect = titlebar_inner_rect; |     auto titlebar_title_rect = titlebar_inner_rect; | ||||||
|     titlebar_title_rect.set_width(Font::default_bold_font().width(title_text)); |     titlebar_title_rect.set_width(FontDatabase::default_bold_font().width(title_text)); | ||||||
| 
 | 
 | ||||||
|     auto [title_color, border_color, border_color2, stripes_color, shadow_color] = compute_frame_colors(window_state, palette); |     auto [title_color, border_color, border_color2, stripes_color, shadow_color] = compute_frame_colors(window_state, palette); | ||||||
| 
 | 
 | ||||||
|  | @ -109,7 +110,7 @@ void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window | ||||||
| 
 | 
 | ||||||
| IntRect ClassicWindowTheme::title_bar_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const | IntRect ClassicWindowTheme::title_bar_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const | ||||||
| { | { | ||||||
|     auto& title_font = Font::default_bold_font(); |     auto& title_font = FontDatabase::default_bold_font(); | ||||||
|     auto window_titlebar_height = title_bar_height(palette); |     auto window_titlebar_height = title_bar_height(palette); | ||||||
|     // FIXME: The top of the titlebar doesn't get redrawn properly if this padding is different
 |     // 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; |     int total_vertical_padding = title_font.glyph_height() - 1; | ||||||
|  | @ -207,7 +208,7 @@ Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, const | ||||||
| 
 | 
 | ||||||
| int ClassicWindowTheme::title_bar_height(const Palette& palette) const | int ClassicWindowTheme::title_bar_height(const Palette& palette) const | ||||||
| { | { | ||||||
|     auto& title_font = Font::default_bold_font(); |     auto& title_font = FontDatabase::default_bold_font(); | ||||||
|     return max(palette.window_title_height(), title_font.glyph_height() + 8); |     return max(palette.window_title_height(), title_font.glyph_height() + 8); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -60,46 +60,6 @@ struct [[gnu::packed]] FontFileHeader | ||||||
|     char family[32]; |     char family[32]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Font& Font::default_font() |  | ||||||
| { |  | ||||||
|     static Font* font; |  | ||||||
|     if (!font) { |  | ||||||
|         font = FontDatabase::the().get_by_name("Katica 10 400"); |  | ||||||
|         ASSERT(font); |  | ||||||
|     } |  | ||||||
|     return *font; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Font& Font::default_fixed_width_font() |  | ||||||
| { |  | ||||||
|     static Font* font; |  | ||||||
|     if (!font) { |  | ||||||
|         font = FontDatabase::the().get_by_name("Csilla 10 400"); |  | ||||||
|         ASSERT(font); |  | ||||||
|     } |  | ||||||
|     return *font; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Font& Font::default_bold_fixed_width_font() |  | ||||||
| { |  | ||||||
|     static Font* font; |  | ||||||
|     if (!font) { |  | ||||||
|         font = FontDatabase::the().get_by_name("Csilla 10 700"); |  | ||||||
|         ASSERT(font); |  | ||||||
|     } |  | ||||||
|     return *font; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Font& Font::default_bold_font() |  | ||||||
| { |  | ||||||
|     static Font* font; |  | ||||||
|     if (!font) { |  | ||||||
|         font = FontDatabase::the().get_by_name("Katica 10 700"); |  | ||||||
|         ASSERT(font); |  | ||||||
|     } |  | ||||||
|     return *font; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| NonnullRefPtr<Font> Font::clone() const | NonnullRefPtr<Font> Font::clone() const | ||||||
| { | { | ||||||
|     size_t bytes_per_glyph = sizeof(u32) * glyph_height(); |     size_t bytes_per_glyph = sizeof(u32) * glyph_height(); | ||||||
|  |  | ||||||
|  | @ -75,12 +75,6 @@ private: | ||||||
| 
 | 
 | ||||||
| class Font : public RefCounted<Font> { | class Font : public RefCounted<Font> { | ||||||
| public: | public: | ||||||
|     static Font& default_font(); |  | ||||||
|     static Font& default_bold_font(); |  | ||||||
| 
 |  | ||||||
|     static Font& default_fixed_width_font(); |  | ||||||
|     static Font& default_bold_fixed_width_font(); |  | ||||||
| 
 |  | ||||||
|     NonnullRefPtr<Font> clone() const; |     NonnullRefPtr<Font> clone() const; | ||||||
|     static NonnullRefPtr<Font> create(u8 glyph_height, u8 glyph_width, bool fixed, FontTypes type); |     static NonnullRefPtr<Font> create(u8 glyph_height, u8 glyph_width, bool fixed, FontTypes type); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -44,6 +44,46 @@ FontDatabase& FontDatabase::the() | ||||||
|     return *s_the; |     return *s_the; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | Font& FontDatabase::default_font() | ||||||
|  | { | ||||||
|  |     static Font* font; | ||||||
|  |     if (!font) { | ||||||
|  |         font = FontDatabase::the().get_by_name("Katica 10 400"); | ||||||
|  |         ASSERT(font); | ||||||
|  |     } | ||||||
|  |     return *font; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Font& FontDatabase::default_fixed_width_font() | ||||||
|  | { | ||||||
|  |     static Font* font; | ||||||
|  |     if (!font) { | ||||||
|  |         font = FontDatabase::the().get_by_name("Csilla 10 400"); | ||||||
|  |         ASSERT(font); | ||||||
|  |     } | ||||||
|  |     return *font; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Font& FontDatabase::default_bold_fixed_width_font() | ||||||
|  | { | ||||||
|  |     static Font* font; | ||||||
|  |     if (!font) { | ||||||
|  |         font = FontDatabase::the().get_by_name("Csilla 10 700"); | ||||||
|  |         ASSERT(font); | ||||||
|  |     } | ||||||
|  |     return *font; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Font& FontDatabase::default_bold_font() | ||||||
|  | { | ||||||
|  |     static Font* font; | ||||||
|  |     if (!font) { | ||||||
|  |         font = FontDatabase::the().get_by_name("Katica 10 700"); | ||||||
|  |         ASSERT(font); | ||||||
|  |     } | ||||||
|  |     return *font; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| struct FontDatabase::Private { | struct FontDatabase::Private { | ||||||
|     HashMap<String, RefPtr<Gfx::Font>> full_name_to_font_map; |     HashMap<String, RefPtr<Gfx::Font>> full_name_to_font_map; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -37,6 +37,12 @@ class FontDatabase { | ||||||
| public: | public: | ||||||
|     static FontDatabase& the(); |     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(); | ||||||
|  | 
 | ||||||
|     RefPtr<Gfx::Font> get(const String& family, unsigned size, unsigned weight); |     RefPtr<Gfx::Font> get(const String& family, unsigned size, unsigned weight); | ||||||
|     RefPtr<Gfx::Font> get_by_name(const StringView&); |     RefPtr<Gfx::Font> get_by_name(const StringView&); | ||||||
|     void for_each_font(Function<void(const Gfx::Font&)>); |     void for_each_font(Function<void(const Gfx::Font&)>); | ||||||
|  |  | ||||||
|  | @ -28,6 +28,7 @@ | ||||||
| #include "Bitmap.h" | #include "Bitmap.h" | ||||||
| #include "Emoji.h" | #include "Emoji.h" | ||||||
| #include "Font.h" | #include "Font.h" | ||||||
|  | #include "FontDatabase.h" | ||||||
| #include "Gamma.h" | #include "Gamma.h" | ||||||
| #include <AK/Assertions.h> | #include <AK/Assertions.h> | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | @ -72,7 +73,7 @@ Painter::Painter(Gfx::Bitmap& bitmap) | ||||||
| { | { | ||||||
|     ASSERT(bitmap.format() == Gfx::BitmapFormat::RGB32 || bitmap.format() == Gfx::BitmapFormat::RGBA32); |     ASSERT(bitmap.format() == Gfx::BitmapFormat::RGB32 || bitmap.format() == Gfx::BitmapFormat::RGBA32); | ||||||
|     m_state_stack.append(State()); |     m_state_stack.append(State()); | ||||||
|     state().font = &Font::default_font(); |     state().font = &FontDatabase::default_font(); | ||||||
|     state().clip_rect = { { 0, 0 }, bitmap.size() }; |     state().clip_rect = { { 0, 0 }, bitmap.size() }; | ||||||
|     m_clip_origin = state().clip_rect; |     m_clip_origin = state().clip_rect; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -133,7 +133,7 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<Co | ||||||
| 
 | 
 | ||||||
|     auto font_entry = m_config->read_entry("Text", "Font", "default"); |     auto font_entry = m_config->read_entry("Text", "Font", "default"); | ||||||
|     if (font_entry == "default") |     if (font_entry == "default") | ||||||
|         set_font(Gfx::Font::default_fixed_width_font()); |         set_font(Gfx::FontDatabase::default_fixed_width_font()); | ||||||
|     else |     else | ||||||
|         set_font(Gfx::FontDatabase::the().get_by_name(font_entry)); |         set_font(Gfx::FontDatabase::the().get_by_name(font_entry)); | ||||||
| 
 | 
 | ||||||
|  | @ -1022,7 +1022,7 @@ void TerminalWidget::did_change_font() | ||||||
|     m_line_height = font().glyph_height() + m_line_spacing; |     m_line_height = font().glyph_height() + m_line_spacing; | ||||||
| 
 | 
 | ||||||
|     // TODO: try to find a bold version of the new font (e.g. CsillaThin7x10 -> CsillaBold7x10)
 |     // TODO: try to find a bold version of the new font (e.g. CsillaThin7x10 -> CsillaBold7x10)
 | ||||||
|     const Gfx::Font& bold_font = Gfx::Font::default_bold_fixed_width_font(); |     const Gfx::Font& bold_font = Gfx::FontDatabase::default_bold_fixed_width_font(); | ||||||
| 
 | 
 | ||||||
|     if (bold_font.glyph_height() == font().glyph_height() && bold_font.glyph_width(' ') == font().glyph_width(' ')) |     if (bold_font.glyph_height() == font().glyph_height() && bold_font.glyph_width(' ') == font().glyph_width(' ')) | ||||||
|         m_bold_font = &bold_font; |         m_bold_font = &bold_font; | ||||||
|  |  | ||||||
|  | @ -202,7 +202,7 @@ void StyleProperties::load_font() const | ||||||
| 
 | 
 | ||||||
|     if (!found_font) { |     if (!found_font) { | ||||||
|         dbgln("Font not found: '{}' {} {}", family, size, weight); |         dbgln("Font not found: '{}' {} {}", family, size, weight); | ||||||
|         found_font = Gfx::Font::default_font(); |         found_font = Gfx::FontDatabase::default_font(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     m_font = found_font; |     m_font = found_font; | ||||||
|  |  | ||||||
|  | @ -26,6 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/Button.h> | #include <LibGUI/Button.h> | ||||||
| #include <LibGUI/TextBox.h> | #include <LibGUI/TextBox.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibWeb/DOM/Document.h> | #include <LibWeb/DOM/Document.h> | ||||||
| #include <LibWeb/DOM/Event.h> | #include <LibWeb/DOM/Event.h> | ||||||
| #include <LibWeb/HTML/EventNames.h> | #include <LibWeb/HTML/EventNames.h> | ||||||
|  | @ -86,12 +87,12 @@ RefPtr<Layout::Node> HTMLInputElement::create_layout_node(const CSS::StyleProper | ||||||
|         auto& widget = downcast<Layout::WidgetBox>(layout_node())->widget(); |         auto& widget = downcast<Layout::WidgetBox>(layout_node())->widget(); | ||||||
|         const_cast<HTMLInputElement*>(this)->set_attribute(HTML::AttributeNames::value, static_cast<const GUI::TextBox&>(widget).text()); |         const_cast<HTMLInputElement*>(this)->set_attribute(HTML::AttributeNames::value, static_cast<const GUI::TextBox&>(widget).text()); | ||||||
|     }; |     }; | ||||||
|     int text_width = Gfx::Font::default_font().width(value()); |     int text_width = Gfx::FontDatabase::default_font().width(value()); | ||||||
|     auto size_value = attribute(HTML::AttributeNames::size); |     auto size_value = attribute(HTML::AttributeNames::size); | ||||||
|     if (!size_value.is_null()) { |     if (!size_value.is_null()) { | ||||||
|         auto size = size_value.to_uint(); |         auto size = size_value.to_uint(); | ||||||
|         if (size.has_value()) |         if (size.has_value()) | ||||||
|             text_width = Gfx::Font::default_font().glyph_width('x') * size.value(); |             text_width = Gfx::FontDatabase::default_font().glyph_width('x') * size.value(); | ||||||
|     } |     } | ||||||
|     text_box.set_relative_rect(0, 0, text_width + 20, 20); |     text_box.set_relative_rect(0, 0, text_width + 20, 20); | ||||||
|     return adopt(*new Layout::WidgetBox(document(), *this, text_box)); |     return adopt(*new Layout::WidgetBox(document(), *this, text_box)); | ||||||
|  |  | ||||||
|  | @ -26,6 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/ImageDecoder.h> | #include <LibGfx/ImageDecoder.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| #include <LibWeb/Layout/ImageBox.h> | #include <LibWeb/Layout/ImageBox.h> | ||||||
|  | @ -79,7 +80,7 @@ void ImageBox::prepare_for_replaced_layout() | ||||||
| 
 | 
 | ||||||
|     if (renders_as_alt_text()) { |     if (renders_as_alt_text()) { | ||||||
|         auto& image_element = downcast<HTML::HTMLImageElement>(dom_node()); |         auto& image_element = downcast<HTML::HTMLImageElement>(dom_node()); | ||||||
|         auto& font = Gfx::Font::default_font(); |         auto& font = Gfx::FontDatabase::default_font(); | ||||||
|         auto alt = image_element.alt(); |         auto alt = image_element.alt(); | ||||||
|         if (alt.is_empty()) |         if (alt.is_empty()) | ||||||
|             alt = image_element.src(); |             alt = image_element.src(); | ||||||
|  | @ -107,7 +108,7 @@ void ImageBox::paint(PaintContext& context, PaintPhase phase) | ||||||
|     if (phase == PaintPhase::Foreground) { |     if (phase == PaintPhase::Foreground) { | ||||||
|         if (renders_as_alt_text()) { |         if (renders_as_alt_text()) { | ||||||
|             auto& image_element = downcast<HTML::HTMLImageElement>(dom_node()); |             auto& image_element = downcast<HTML::HTMLImageElement>(dom_node()); | ||||||
|             context.painter().set_font(Gfx::Font::default_font()); |             context.painter().set_font(Gfx::FontDatabase::default_font()); | ||||||
|             Gfx::StylePainter::paint_frame(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2); |             Gfx::StylePainter::paint_frame(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2); | ||||||
|             auto alt = image_element.alt(); |             auto alt = image_element.alt(); | ||||||
|             if (alt.is_empty()) |             if (alt.is_empty()) | ||||||
|  |  | ||||||
|  | @ -35,6 +35,7 @@ | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
| class AudioWidget final : public GUI::Widget { | class AudioWidget final : public GUI::Widget { | ||||||
|  | @ -161,7 +162,7 @@ private: | ||||||
| 
 | 
 | ||||||
|         if (m_show_percent) { |         if (m_show_percent) { | ||||||
|             auto volume_text = m_audio_muted ? "mute" : String::format("%d%%", m_audio_volume); |             auto volume_text = m_audio_muted ? "mute" : String::format("%d%%", m_audio_volume); | ||||||
|             painter.draw_text({ 16, 3, 24, 16 }, volume_text, Gfx::Font::default_fixed_width_font(), Gfx::TextAlignment::TopLeft, palette().window_text()); |             painter.draw_text({ 16, 3, 24, 16 }, volume_text, Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::TopLeft, palette().window_text()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -36,6 +36,7 @@ | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <serenity.h> | #include <serenity.h> | ||||||
| #include <spawn.h> | #include <spawn.h> | ||||||
|  | @ -47,7 +48,7 @@ class ClockWidget final : public GUI::Widget { | ||||||
| public: | public: | ||||||
|     ClockWidget() |     ClockWidget() | ||||||
|     { |     { | ||||||
|         m_time_width = Gfx::Font::default_bold_font().width("2222-22-22 22:22:22"); |         m_time_width = Gfx::FontDatabase::default_bold_font().width("2222-22-22 22:22:22"); | ||||||
| 
 | 
 | ||||||
|         m_timer = add<Core::Timer>(1000, [this] { |         m_timer = add<Core::Timer>(1000, [this] { | ||||||
|             static time_t last_update_time; |             static time_t last_update_time; | ||||||
|  | @ -217,7 +218,7 @@ private: | ||||||
|         auto time_text = Core::DateTime::now().to_string(); |         auto time_text = Core::DateTime::now().to_string(); | ||||||
|         GUI::Painter painter(*this); |         GUI::Painter painter(*this); | ||||||
|         painter.fill_rect(event.rect(), palette().window()); |         painter.fill_rect(event.rect(), palette().window()); | ||||||
|         painter.draw_text(event.rect(), time_text, Gfx::Font::default_font(), Gfx::TextAlignment::Center, palette().window_text()); |         painter.draw_text(event.rect(), time_text, Gfx::FontDatabase::default_font(), Gfx::TextAlignment::Center, palette().window_text()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     virtual void mousedown_event(GUI::MouseEvent& event) override |     virtual void mousedown_event(GUI::MouseEvent& event) override | ||||||
|  |  | ||||||
|  | @ -29,6 +29,7 @@ | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
|  | @ -38,7 +39,7 @@ public: | ||||||
|     UserNameWidget() |     UserNameWidget() | ||||||
|     { |     { | ||||||
|         m_username = getlogin(); |         m_username = getlogin(); | ||||||
|         m_username_width = Gfx::Font::default_bold_font().width(m_username); |         m_username_width = Gfx::FontDatabase::default_bold_font().width(m_username); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     virtual ~UserNameWidget() override { } |     virtual ~UserNameWidget() override { } | ||||||
|  | @ -55,7 +56,7 @@ private: | ||||||
|     { |     { | ||||||
|         GUI::Painter painter(*this); |         GUI::Painter painter(*this); | ||||||
|         painter.fill_rect(event.rect(), palette().window()); |         painter.fill_rect(event.rect(), palette().window()); | ||||||
|         painter.draw_text(event.rect(), m_username, Gfx::Font::default_bold_font(), Gfx::TextAlignment::Center, palette().window_text()); |         painter.draw_text(event.rect(), m_username, Gfx::FontDatabase::default_bold_font(), Gfx::TextAlignment::Center, palette().window_text()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     String m_username; |     String m_username; | ||||||
|  |  | ||||||
|  | @ -34,6 +34,7 @@ | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/ShareableBitmap.h> | #include <LibGfx/ShareableBitmap.h> | ||||||
| 
 | 
 | ||||||
| namespace NotificationServer { | namespace NotificationServer { | ||||||
|  | @ -99,7 +100,7 @@ NotificationWindow::NotificationWindow(const String& text, const String& title, | ||||||
|     left_container.set_layout<GUI::VerticalBoxLayout>(); |     left_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& title_label = left_container.add<GUI::Label>(title); |     auto& title_label = left_container.add<GUI::Label>(title); | ||||||
|     title_label.set_font(Gfx::Font::default_bold_font()); |     title_label.set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
|     title_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     title_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     auto& text_label = left_container.add<GUI::Label>(text); |     auto& text_label = left_container.add<GUI::Label>(text); | ||||||
|     text_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     text_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|  |  | ||||||
|  | @ -33,6 +33,7 @@ | ||||||
| #include <LibGUI/RadioButton.h> | #include <LibGUI/RadioButton.h> | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| 
 | 
 | ||||||
| struct Option { | struct Option { | ||||||
|     String title; |     String title; | ||||||
|  | @ -76,7 +77,7 @@ ShutdownDialog::ShutdownDialog() | ||||||
|     auto& header = main.add<GUI::Label>(); |     auto& header = main.add<GUI::Label>(); | ||||||
|     header.set_text("What would you like to do?"); |     header.set_text("What would you like to do?"); | ||||||
|     header.set_fixed_height(16); |     header.set_fixed_height(16); | ||||||
|     header.set_font(Gfx::Font::default_bold_font()); |     header.set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
| 
 | 
 | ||||||
|     for (size_t i = 0; i < options.size(); i++) { |     for (size_t i = 0; i < options.size(); i++) { | ||||||
|         auto action = options[i]; |         auto action = options[i]; | ||||||
|  |  | ||||||
|  | @ -30,6 +30,7 @@ | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGUI/WindowServerConnection.h> | #include <LibGUI/WindowServerConnection.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | @ -106,7 +107,7 @@ void TaskbarButton::paint_event(GUI::PaintEvent& event) | ||||||
| { | { | ||||||
|     ASSERT(icon()); |     ASSERT(icon()); | ||||||
|     auto& icon = *this->icon(); |     auto& icon = *this->icon(); | ||||||
|     auto& font = is_checked() ? Gfx::Font::default_bold_font() : this->font(); |     auto& font = is_checked() ? Gfx::FontDatabase::default_bold_font() : this->font(); | ||||||
|     auto& window = WindowList::the().ensure_window(m_identifier); |     auto& window = WindowList::the().ensure_window(m_identifier); | ||||||
| 
 | 
 | ||||||
|     GUI::Painter painter(*this); |     GUI::Painter painter(*this); | ||||||
|  |  | ||||||
|  | @ -67,7 +67,7 @@ const Gfx::Font& Menu::title_font() const | ||||||
| 
 | 
 | ||||||
| const Gfx::Font& Menu::font() const | const Gfx::Font& Menu::font() const | ||||||
| { | { | ||||||
|     return Gfx::Font::default_font(); |     return Gfx::FontDatabase::default_font(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static const char* s_checked_bitmap_data = { | static const char* s_checked_bitmap_data = { | ||||||
|  | @ -109,7 +109,7 @@ int Menu::content_width() const | ||||||
|     for (auto& item : m_items) { |     for (auto& item : m_items) { | ||||||
|         if (item.type() != MenuItem::Text) |         if (item.type() != MenuItem::Text) | ||||||
|             continue; |             continue; | ||||||
|         auto& use_font = item.is_default() ? Gfx::Font::default_bold_font() : font(); |         auto& use_font = item.is_default() ? Gfx::FontDatabase::default_bold_font() : font(); | ||||||
|         int text_width = use_font.width(item.text()); |         int text_width = use_font.width(item.text()); | ||||||
|         if (!item.shortcut_text().is_empty()) { |         if (!item.shortcut_text().is_empty()) { | ||||||
|             int shortcut_width = use_font.width(item.shortcut_text()); |             int shortcut_width = use_font.width(item.shortcut_text()); | ||||||
|  | @ -261,7 +261,7 @@ void Menu::draw() | ||||||
|             } |             } | ||||||
|             auto& previous_font = painter.font(); |             auto& previous_font = painter.font(); | ||||||
|             if (item.is_default()) |             if (item.is_default()) | ||||||
|                 painter.set_font(Gfx::Font::default_bold_font()); |                 painter.set_font(Gfx::FontDatabase::default_bold_font()); | ||||||
|             painter.draw_text(text_rect, item.text(), Gfx::TextAlignment::CenterLeft, text_color); |             painter.draw_text(text_rect, item.text(), Gfx::TextAlignment::CenterLeft, text_color); | ||||||
|             if (!item.shortcut_text().is_empty()) { |             if (!item.shortcut_text().is_empty()) { | ||||||
|                 painter.draw_text(item.rect().translated(-right_padding(), 0), item.shortcut_text(), Gfx::TextAlignment::CenterRight, text_color); |                 painter.draw_text(item.rect().translated(-right_padding(), 0), item.shortcut_text(), Gfx::TextAlignment::CenterRight, text_color); | ||||||
|  |  | ||||||
|  | @ -31,6 +31,7 @@ | ||||||
| #include <AK/WeakPtr.h> | #include <AK/WeakPtr.h> | ||||||
| #include <LibCore/Object.h> | #include <LibCore/Object.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Forward.h> | #include <LibGfx/Forward.h> | ||||||
| #include <LibGfx/Rect.h> | #include <LibGfx/Rect.h> | ||||||
| #include <WindowServer/Cursor.h> | #include <WindowServer/Cursor.h> | ||||||
|  | @ -135,7 +136,7 @@ public: | ||||||
| private: | private: | ||||||
|     virtual void event(Core::Event&) override; |     virtual void event(Core::Event&) override; | ||||||
| 
 | 
 | ||||||
|     RefPtr<Gfx::Font> m_title_font { &Gfx::Font::default_font() }; |     RefPtr<Gfx::Font> m_title_font { &Gfx::FontDatabase::default_font() }; | ||||||
| 
 | 
 | ||||||
|     void handle_mouse_move_event(const MouseEvent&); |     void handle_mouse_move_event(const MouseEvent&); | ||||||
|     int visible_item_count() const; |     int visible_item_count() const; | ||||||
|  |  | ||||||
|  | @ -47,7 +47,7 @@ void MenuBar::add_menu(Menu& menu) | ||||||
| 
 | 
 | ||||||
|     // NOTE: We assume that the first menu is the App menu, which has a bold font.
 |     // NOTE: We assume that the first menu is the App menu, which has a bold font.
 | ||||||
|     if (m_menus.is_empty()) |     if (m_menus.is_empty()) | ||||||
|         menu.set_title_font(Gfx::Font::default_bold_font()); |         menu.set_title_font(Gfx::FontDatabase::default_bold_font()); | ||||||
| 
 | 
 | ||||||
|     m_menus.append(&menu); |     m_menus.append(&menu); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -121,12 +121,12 @@ void WindowManager::reload_config(bool set_screen) | ||||||
| 
 | 
 | ||||||
| const Gfx::Font& WindowManager::font() const | const Gfx::Font& WindowManager::font() const | ||||||
| { | { | ||||||
|     return Gfx::Font::default_font(); |     return Gfx::FontDatabase::default_font(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const Gfx::Font& WindowManager::window_title_font() const | const Gfx::Font& WindowManager::window_title_font() const | ||||||
| { | { | ||||||
|     return Gfx::Font::default_bold_font(); |     return Gfx::FontDatabase::default_bold_font(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool WindowManager::set_resolution(int width, int height) | bool WindowManager::set_resolution(int width, int height) | ||||||
|  |  | ||||||
|  | @ -50,22 +50,22 @@ static void test_fontdatabase_for_each_font() | ||||||
| 
 | 
 | ||||||
| static void test_default_font() | static void test_default_font() | ||||||
| { | { | ||||||
|     assert(!Gfx::Font::default_font().name().is_null()); |     assert(!Gfx::FontDatabase::default_font().name().is_null()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void test_default_fixed_width_font() | static void test_default_fixed_width_font() | ||||||
| { | { | ||||||
|     assert(!Gfx::Font::default_font().name().is_null()); |     assert(!Gfx::FontDatabase::default_font().name().is_null()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void test_default_bold_fixed_width_font() | static void test_default_bold_fixed_width_font() | ||||||
| { | { | ||||||
|     assert(!Gfx::Font::default_font().name().is_null()); |     assert(!Gfx::FontDatabase::default_font().name().is_null()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void test_default_bold_font() | static void test_default_bold_font() | ||||||
| { | { | ||||||
|     assert(!Gfx::Font::default_font().name().is_null()); |     assert(!Gfx::FontDatabase::default_font().name().is_null()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void test_clone() | static void test_clone() | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Stephan Unverwerth
						Stephan Unverwerth