From d2fbc15f5dcab0348216b4d0eef8d52ba9367119 Mon Sep 17 00:00:00 2001 From: Shane Murphy Date: Wed, 18 Oct 2023 22:08:22 -0700 Subject: [PATCH] Terminal: Fix zoom when font size is missing If Terminal was configured with a typeface that does not have a font for any given size, the zoom in and out button in the menu bar would not work because font lookup was exact. Use Font::AllowInexactMatch::Larger when zooming in and Font::AllowInexactMatch::Smaller when zooming out to allow finding the closest font size in the requested direction. --- Userland/Applications/Terminal/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index ba32c06f68d..e3431431623 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -400,10 +400,10 @@ ErrorOr serenity_main(Main::Arguments arguments) })); view_menu->add_action(terminal->clear_including_history_action()); - auto adjust_font_size = [&](float adjustment) { + auto adjust_font_size = [&](float adjustment, Gfx::Font::AllowInexactSizeMatch preference) { auto& font = terminal->font(); auto new_size = max(5, font.presentation_size() + adjustment); - if (auto new_font = Gfx::FontDatabase::the().get(font.family(), new_size, font.weight(), font.width(), font.slope())) { + if (auto new_font = Gfx::FontDatabase::the().get(font.family(), new_size, font.weight(), font.width(), font.slope(), preference)) { terminal->set_font_and_resize_to_fit(*new_font); terminal->apply_size_increments_to_window(*window); window->resize(terminal->size()); @@ -412,10 +412,10 @@ ErrorOr serenity_main(Main::Arguments arguments) view_menu->add_separator(); view_menu->add_action(GUI::CommonActions::make_zoom_in_action([&](auto&) { - adjust_font_size(1); + adjust_font_size(1, Gfx::Font::AllowInexactSizeMatch::Larger); })); view_menu->add_action(GUI::CommonActions::make_zoom_out_action([&](auto&) { - adjust_font_size(-1); + adjust_font_size(-1, Gfx::Font::AllowInexactSizeMatch::Smaller); })); auto help_menu = window->add_menu("&Help"_string);