diff options
author | Andreas Kling <kling@serenityos.org> | 2020-10-25 19:28:06 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-25 21:18:18 +0100 |
commit | 9d347352a1a6c47867bc8340a13d69c8272952d9 (patch) | |
tree | dc1015117b75cf743581217624bae31a2c6bc2bd /Applications/TextEditor | |
parent | 260b52215cbfc3be760e829c75ffe3aec53465bc (diff) | |
download | serenity-9d347352a1a6c47867bc8340a13d69c8272952d9.zip |
LibGfx+LibGUI+Clients: Make fonts findable by their qualified name
The qualified name of a font is "<Family> <Size> <Weight>". You can
get the QN of a Font via the Font::qualified_name() API, and you can
get any system font by QN from the GUI::FontDatabase. :^)
Diffstat (limited to 'Applications/TextEditor')
-rw-r--r-- | Applications/TextEditor/TextEditorWidget.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index f53d4df6cc..dde6f1e275 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -396,12 +396,12 @@ TextEditorWidget::TextEditorWidget() font_actions.set_exclusive(true); auto& font_menu = view_menu.add_submenu("Font"); - GUI::FontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { - auto action = GUI::Action::create_checkable(font_name, [&](auto& action) { - m_editor->set_font(GUI::FontDatabase::the().get_by_name(action.text())); + GUI::FontDatabase::the().for_each_fixed_width_font([&](const Gfx::Font& font) { + auto action = GUI::Action::create_checkable(font.qualified_name(), [&](auto&) { + m_editor->set_font(font); m_editor->update(); }); - if (m_editor->font().name() == font_name) + if (m_editor->font().qualified_name() == font.qualified_name()) action->set_checked(true); font_actions.add_action(*action); font_menu.add_action(*action); |