diff --git a/Ladybird/FontPlugin.cpp b/Ladybird/FontPlugin.cpp index 5ebb1c20a7..3fd560b15f 100644 --- a/Ladybird/FontPlugin.cpp +++ b/Ladybird/FontPlugin.cpp @@ -34,11 +34,11 @@ FontPlugin::FontPlugin(bool is_layout_test_mode) update_generic_fonts(); auto default_font_name = generic_font_name(Web::Platform::GenericFont::UiSansSerif); - m_default_font = Gfx::FontDatabase::the().get(default_font_name, 12.0, 400, Gfx::FontWidth::Normal, 0); + m_default_font = Gfx::FontDatabase::the().get(MUST(String::from_deprecated_string(default_font_name)), 12.0, 400, Gfx::FontWidth::Normal, 0); VERIFY(m_default_font); auto default_fixed_width_font_name = generic_font_name(Web::Platform::GenericFont::UiMonospace); - m_default_fixed_width_font = Gfx::FontDatabase::the().get(default_fixed_width_font_name, 12.0, 400, Gfx::FontWidth::Normal, 0); + m_default_fixed_width_font = Gfx::FontDatabase::the().get(MUST(String::from_deprecated_string(default_fixed_width_font_name)), 12.0, 400, Gfx::FontWidth::Normal, 0); VERIFY(m_default_fixed_width_font); } @@ -75,7 +75,7 @@ void FontPlugin::update_generic_fonts() RefPtr gfx_font; for (auto& fallback : fallbacks) { - gfx_font = Gfx::FontDatabase::the().get(fallback, 16, 400, Gfx::FontWidth::Normal, 0, Gfx::Font::AllowInexactSizeMatch::Yes); + gfx_font = Gfx::FontDatabase::the().get(MUST(String::from_deprecated_string(fallback)), 16, 400, Gfx::FontWidth::Normal, 0, Gfx::Font::AllowInexactSizeMatch::Yes); if (gfx_font) break; } diff --git a/Tests/LibGfx/TestFontHandling.cpp b/Tests/LibGfx/TestFontHandling.cpp index 4731d315b9..e4199c0d9d 100644 --- a/Tests/LibGfx/TestFontHandling.cpp +++ b/Tests/LibGfx/TestFontHandling.cpp @@ -32,7 +32,7 @@ TEST_CASE(test_fontdatabase_get) { Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT("")); auto& font_database = Gfx::FontDatabase::the(); - EXPECT(!font_database.get("Family", 12, 400, Gfx::FontWidth::Normal, 0)->name().is_empty()); + EXPECT(!font_database.get("Family"_fly_string, 12, 400, Gfx::FontWidth::Normal, 0)->name().is_empty()); } TEST_CASE(test_fontdatabase_for_each_font) diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index 12d989a202..fa99ab1e82 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -321,14 +321,14 @@ static ErrorOr load_font(StringView path, StringView mime_type, Nonnul { if (path.ends_with(".font"sv)) { auto font = TRY(Gfx::BitmapFont::try_load_from_mapped_file(mapped_file)); - auto typeface = TRY(try_make_ref_counted(font->family().to_deprecated_string(), font->variant().to_deprecated_string())); + auto typeface = TRY(try_make_ref_counted(font->family(), font->variant())); typeface->add_bitmap_font(move(font)); return FontInfo { FontInfo::Format::BitmapFont, move(typeface) }; } if (mime_type == "font/otf" || mime_type == "font/ttf") { auto font = TRY(OpenType::Font::try_load_from_externally_owned_memory(mapped_file->bytes())); - auto typeface = TRY(try_make_ref_counted(font->family().to_deprecated_string(), font->variant().to_deprecated_string())); + auto typeface = TRY(try_make_ref_counted(font->family(), font->variant())); typeface->set_vector_font(move(font)); return FontInfo { mime_type == "font/otf" ? FontInfo::Format::OpenType : FontInfo::Format::TrueType, @@ -338,7 +338,7 @@ static ErrorOr load_font(StringView path, StringView mime_type, Nonnul if (mime_type == "font/woff" || mime_type == "font/woff2") { auto font = TRY(WOFF::Font::try_load_from_externally_owned_memory(mapped_file->bytes())); - auto typeface = TRY(try_make_ref_counted(font->family().to_deprecated_string(), font->variant().to_deprecated_string())); + auto typeface = TRY(try_make_ref_counted(font->family(), font->variant())); typeface->set_vector_font(move(font)); return FontInfo { mime_type == "font/woff" ? FontInfo::Format::WOFF : FontInfo::Format::WOFF2, @@ -381,7 +381,7 @@ ErrorOr PropertiesWindow::create_font_tab(GUI::TabWidget& tab_widget, Nonn break; } tab->find_descendant_of_type_named("font_format")->set_text(format_name); - tab->find_descendant_of_type_named("font_family")->set_text(TRY(String::from_deprecated_string(typeface->family()))); + tab->find_descendant_of_type_named("font_family")->set_text(typeface->family().to_string()); tab->find_descendant_of_type_named("font_fixed_width")->set_text(typeface->is_fixed_width() ? "Yes"_string : "No"_string); tab->find_descendant_of_type_named("font_width")->set_text(TRY(String::from_utf8(Gfx::width_to_name(static_cast(typeface->width()))))); diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index a5272d2724..8655a615a0 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -403,7 +403,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto adjust_font_size = [&](float adjustment) { auto& font = terminal->font(); auto new_size = max(5, font.presentation_size() + adjustment); - if (auto new_font = Gfx::FontDatabase::the().get(font.family().to_deprecated_string(), 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())) { terminal->set_font_and_resize_to_fit(*new_font); terminal->apply_size_increments_to_window(*window); window->resize(terminal->size()); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 51b448b96f..34a0b869d8 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -1856,7 +1856,7 @@ RefPtr HackStudioWidget::read_editor_font_from_config() auto font_variant = Config::read_string("HackStudio"sv, "EditorFont"sv, "Variant"sv); auto font_size = Config::read_i32("HackStudio"sv, "EditorFont"sv, "Size"sv); - auto font = Gfx::FontDatabase::the().get(font_family, font_variant, font_size); + auto font = Gfx::FontDatabase::the().get(MUST(FlyString::from_deprecated_fly_string(font_family)), FlyString::from_deprecated_fly_string(font_variant).release_value_but_fixme_should_propagate_errors(), font_size); if (font.is_null()) return Gfx::FontDatabase::the().default_fixed_width_font(); diff --git a/Userland/Libraries/LibGUI/FontPicker.cpp b/Userland/Libraries/LibGUI/FontPicker.cpp index 8e553edb8a..8a5f05f204 100644 --- a/Userland/Libraries/LibGUI/FontPicker.cpp +++ b/Userland/Libraries/LibGUI/FontPicker.cpp @@ -30,11 +30,11 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo widget->load_from_gml(font_picker_dialog_gml).release_value_but_fixme_should_propagate_errors(); m_family_list_view = *widget->find_descendant_of_type_named("family_list_view"); - m_family_list_view->set_model(ItemListModel::create(m_families)); + m_family_list_view->set_model(ItemListModel::create(m_families)); m_family_list_view->horizontal_scrollbar().set_visible(false); m_variant_list_view = *widget->find_descendant_of_type_named("variant_list_view"); - m_variant_list_view->set_model(ItemListModel::create(m_variants)); + m_variant_list_view->set_model(ItemListModel::create(m_variants)); m_variant_list_view->horizontal_scrollbar().set_visible(false); m_size_spin_box = *widget->find_descendant_of_type_named("size_spin_box"); @@ -57,7 +57,7 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo m_family_list_view->on_selection_change = [this] { const auto& index = m_family_list_view->selection().first(); - m_family = index.data().to_deprecated_string(); + m_family = MUST(String::from_deprecated_string(index.data().to_deprecated_string())); m_variants.clear(); Gfx::FontDatabase::the().for_each_typeface([&](auto& typeface) { if (m_fixed_width_only && !typeface.is_fixed_width()) @@ -78,7 +78,7 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo m_variant_list_view->on_selection_change = [this] { const auto& index = m_variant_list_view->selection().first(); bool font_is_fixed_size = false; - m_variant = index.data().to_deprecated_string(); + m_variant = MUST(String::from_deprecated_string(index.data().to_deprecated_string())); m_sizes.clear(); Gfx::FontDatabase::the().for_each_typeface([&](auto& typeface) { if (m_fixed_width_only && !typeface.is_fixed_width()) @@ -190,15 +190,15 @@ void FontPicker::set_font(Gfx::Font const* font) return; } - m_family = font->family().to_deprecated_string(); - m_variant = font->variant().to_deprecated_string(); + m_family = font->family(); + m_variant = font->variant(); m_size = font->presentation_size(); - auto family_index = m_families.find_first_index(m_font->family().to_deprecated_string()); + auto family_index = m_families.find_first_index(m_font->family()); if (family_index.has_value()) m_family_list_view->set_cursor(m_family_list_view->model()->index(family_index.value()), GUI::AbstractView::SelectionUpdate::Set); - auto variant_index = m_variants.find_first_index(m_font->variant().to_deprecated_string()); + auto variant_index = m_variants.find_first_index(m_font->variant()); if (variant_index.has_value()) m_variant_list_view->set_cursor(m_variant_list_view->model()->index(variant_index.value()), GUI::AbstractView::SelectionUpdate::Set); diff --git a/Userland/Libraries/LibGUI/FontPicker.h b/Userland/Libraries/LibGUI/FontPicker.h index 96d500839f..1f4d38a1d0 100644 --- a/Userland/Libraries/LibGUI/FontPicker.h +++ b/Userland/Libraries/LibGUI/FontPicker.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -37,12 +38,12 @@ private: RefPtr m_size_spin_box; RefPtr