Просмотр исходного кода

LibGfx: Convert FontDatabase APIs to use FlyString

Andreas Kling 1 год назад
Родитель
Сommit
13db3c5ce0

+ 3 - 3
Ladybird/FontPlugin.cpp

@@ -34,11 +34,11 @@ FontPlugin::FontPlugin(bool is_layout_test_mode)
     update_generic_fonts();
     update_generic_fonts();
 
 
     auto default_font_name = generic_font_name(Web::Platform::GenericFont::UiSansSerif);
     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);
     VERIFY(m_default_font);
 
 
     auto default_fixed_width_font_name = generic_font_name(Web::Platform::GenericFont::UiMonospace);
     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);
     VERIFY(m_default_fixed_width_font);
 }
 }
 
 
@@ -75,7 +75,7 @@ void FontPlugin::update_generic_fonts()
         RefPtr<Gfx::Font const> gfx_font;
         RefPtr<Gfx::Font const> gfx_font;
 
 
         for (auto& fallback : fallbacks) {
         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)
             if (gfx_font)
                 break;
                 break;
         }
         }

+ 1 - 1
Tests/LibGfx/TestFontHandling.cpp

@@ -32,7 +32,7 @@ TEST_CASE(test_fontdatabase_get)
 {
 {
     Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT(""));
     Gfx::FontDatabase::set_default_fonts_lookup_path(TEST_INPUT(""));
     auto& font_database = Gfx::FontDatabase::the();
     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)
 TEST_CASE(test_fontdatabase_for_each_font)

+ 4 - 4
Userland/Applications/FileManager/PropertiesWindow.cpp

@@ -321,14 +321,14 @@ static ErrorOr<FontInfo> load_font(StringView path, StringView mime_type, Nonnul
 {
 {
     if (path.ends_with(".font"sv)) {
     if (path.ends_with(".font"sv)) {
         auto font = TRY(Gfx::BitmapFont::try_load_from_mapped_file(mapped_file));
         auto font = TRY(Gfx::BitmapFont::try_load_from_mapped_file(mapped_file));
-        auto typeface = TRY(try_make_ref_counted<Gfx::Typeface>(font->family().to_deprecated_string(), font->variant().to_deprecated_string()));
+        auto typeface = TRY(try_make_ref_counted<Gfx::Typeface>(font->family(), font->variant()));
         typeface->add_bitmap_font(move(font));
         typeface->add_bitmap_font(move(font));
         return FontInfo { FontInfo::Format::BitmapFont, move(typeface) };
         return FontInfo { FontInfo::Format::BitmapFont, move(typeface) };
     }
     }
 
 
     if (mime_type == "font/otf" || mime_type == "font/ttf") {
     if (mime_type == "font/otf" || mime_type == "font/ttf") {
         auto font = TRY(OpenType::Font::try_load_from_externally_owned_memory(mapped_file->bytes()));
         auto font = TRY(OpenType::Font::try_load_from_externally_owned_memory(mapped_file->bytes()));
-        auto typeface = TRY(try_make_ref_counted<Gfx::Typeface>(font->family().to_deprecated_string(), font->variant().to_deprecated_string()));
+        auto typeface = TRY(try_make_ref_counted<Gfx::Typeface>(font->family(), font->variant()));
         typeface->set_vector_font(move(font));
         typeface->set_vector_font(move(font));
         return FontInfo {
         return FontInfo {
             mime_type == "font/otf" ? FontInfo::Format::OpenType : FontInfo::Format::TrueType,
             mime_type == "font/otf" ? FontInfo::Format::OpenType : FontInfo::Format::TrueType,
@@ -338,7 +338,7 @@ static ErrorOr<FontInfo> load_font(StringView path, StringView mime_type, Nonnul
 
 
     if (mime_type == "font/woff" || mime_type == "font/woff2") {
     if (mime_type == "font/woff" || mime_type == "font/woff2") {
         auto font = TRY(WOFF::Font::try_load_from_externally_owned_memory(mapped_file->bytes()));
         auto font = TRY(WOFF::Font::try_load_from_externally_owned_memory(mapped_file->bytes()));
-        auto typeface = TRY(try_make_ref_counted<Gfx::Typeface>(font->family().to_deprecated_string(), font->variant().to_deprecated_string()));
+        auto typeface = TRY(try_make_ref_counted<Gfx::Typeface>(font->family(), font->variant()));
         typeface->set_vector_font(move(font));
         typeface->set_vector_font(move(font));
         return FontInfo {
         return FontInfo {
             mime_type == "font/woff" ? FontInfo::Format::WOFF : FontInfo::Format::WOFF2,
             mime_type == "font/woff" ? FontInfo::Format::WOFF : FontInfo::Format::WOFF2,
@@ -381,7 +381,7 @@ ErrorOr<void> PropertiesWindow::create_font_tab(GUI::TabWidget& tab_widget, Nonn
         break;
         break;
     }
     }
     tab->find_descendant_of_type_named<GUI::Label>("font_format")->set_text(format_name);
     tab->find_descendant_of_type_named<GUI::Label>("font_format")->set_text(format_name);
-    tab->find_descendant_of_type_named<GUI::Label>("font_family")->set_text(TRY(String::from_deprecated_string(typeface->family())));
+    tab->find_descendant_of_type_named<GUI::Label>("font_family")->set_text(typeface->family().to_string());
     tab->find_descendant_of_type_named<GUI::Label>("font_fixed_width")->set_text(typeface->is_fixed_width() ? "Yes"_string : "No"_string);
     tab->find_descendant_of_type_named<GUI::Label>("font_fixed_width")->set_text(typeface->is_fixed_width() ? "Yes"_string : "No"_string);
     tab->find_descendant_of_type_named<GUI::Label>("font_width")->set_text(TRY(String::from_utf8(Gfx::width_to_name(static_cast<Gfx::FontWidth>(typeface->width())))));
     tab->find_descendant_of_type_named<GUI::Label>("font_width")->set_text(TRY(String::from_utf8(Gfx::width_to_name(static_cast<Gfx::FontWidth>(typeface->width())))));
 
 

+ 1 - 1
Userland/Applications/Terminal/main.cpp

@@ -403,7 +403,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     auto adjust_font_size = [&](float adjustment) {
     auto adjust_font_size = [&](float adjustment) {
         auto& font = terminal->font();
         auto& font = terminal->font();
         auto new_size = max(5, font.presentation_size() + adjustment);
         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->set_font_and_resize_to_fit(*new_font);
             terminal->apply_size_increments_to_window(*window);
             terminal->apply_size_increments_to_window(*window);
             window->resize(terminal->size());
             window->resize(terminal->size());

+ 1 - 1
Userland/DevTools/HackStudio/HackStudioWidget.cpp

@@ -1856,7 +1856,7 @@ RefPtr<Gfx::Font const> HackStudioWidget::read_editor_font_from_config()
     auto font_variant = Config::read_string("HackStudio"sv, "EditorFont"sv, "Variant"sv);
     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_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())
     if (font.is_null())
         return Gfx::FontDatabase::the().default_fixed_width_font();
         return Gfx::FontDatabase::the().default_fixed_width_font();
 
 

+ 8 - 8
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();
     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<ListView>("family_list_view");
     m_family_list_view = *widget->find_descendant_of_type_named<ListView>("family_list_view");
-    m_family_list_view->set_model(ItemListModel<DeprecatedString>::create(m_families));
+    m_family_list_view->set_model(ItemListModel<FlyString>::create(m_families));
     m_family_list_view->horizontal_scrollbar().set_visible(false);
     m_family_list_view->horizontal_scrollbar().set_visible(false);
 
 
     m_variant_list_view = *widget->find_descendant_of_type_named<ListView>("variant_list_view");
     m_variant_list_view = *widget->find_descendant_of_type_named<ListView>("variant_list_view");
-    m_variant_list_view->set_model(ItemListModel<DeprecatedString>::create(m_variants));
+    m_variant_list_view->set_model(ItemListModel<FlyString>::create(m_variants));
     m_variant_list_view->horizontal_scrollbar().set_visible(false);
     m_variant_list_view->horizontal_scrollbar().set_visible(false);
 
 
     m_size_spin_box = *widget->find_descendant_of_type_named<SpinBox>("size_spin_box");
     m_size_spin_box = *widget->find_descendant_of_type_named<SpinBox>("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] {
     m_family_list_view->on_selection_change = [this] {
         const auto& index = m_family_list_view->selection().first();
         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();
         m_variants.clear();
         Gfx::FontDatabase::the().for_each_typeface([&](auto& typeface) {
         Gfx::FontDatabase::the().for_each_typeface([&](auto& typeface) {
             if (m_fixed_width_only && !typeface.is_fixed_width())
             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] {
     m_variant_list_view->on_selection_change = [this] {
         const auto& index = m_variant_list_view->selection().first();
         const auto& index = m_variant_list_view->selection().first();
         bool font_is_fixed_size = false;
         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();
         m_sizes.clear();
         Gfx::FontDatabase::the().for_each_typeface([&](auto& typeface) {
         Gfx::FontDatabase::the().for_each_typeface([&](auto& typeface) {
             if (m_fixed_width_only && !typeface.is_fixed_width())
             if (m_fixed_width_only && !typeface.is_fixed_width())
@@ -190,15 +190,15 @@ void FontPicker::set_font(Gfx::Font const* font)
         return;
         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();
     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())
     if (family_index.has_value())
         m_family_list_view->set_cursor(m_family_list_view->model()->index(family_index.value()), GUI::AbstractView::SelectionUpdate::Set);
         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())
     if (variant_index.has_value())
         m_variant_list_view->set_cursor(m_variant_list_view->model()->index(variant_index.value()), GUI::AbstractView::SelectionUpdate::Set);
         m_variant_list_view->set_cursor(m_variant_list_view->model()->index(variant_index.value()), GUI::AbstractView::SelectionUpdate::Set);
 
 

+ 5 - 4
Userland/Libraries/LibGUI/FontPicker.h

@@ -7,6 +7,7 @@
 
 
 #pragma once
 #pragma once
 
 
+#include <AK/FlyString.h>
 #include <LibGUI/Dialog.h>
 #include <LibGUI/Dialog.h>
 #include <LibGfx/Font/Font.h>
 #include <LibGfx/Font/Font.h>
 #include <LibGfx/Forward.h>
 #include <LibGfx/Forward.h>
@@ -37,12 +38,12 @@ private:
     RefPtr<SpinBox> m_size_spin_box;
     RefPtr<SpinBox> m_size_spin_box;
     RefPtr<Label> m_sample_text_label;
     RefPtr<Label> m_sample_text_label;
 
 
-    Vector<DeprecatedString> m_families;
-    Vector<DeprecatedString> m_variants;
+    Vector<FlyString> m_families;
+    Vector<FlyString> m_variants;
     Vector<int> m_sizes;
     Vector<int> m_sizes;
 
 
-    Optional<DeprecatedString> m_family;
-    Optional<DeprecatedString> m_variant;
+    Optional<FlyString> m_family;
+    Optional<FlyString> m_variant;
     Optional<int> m_size;
     Optional<int> m_size;
 };
 };
 
 

+ 5 - 5
Userland/Libraries/LibGUI/Widget.cpp

@@ -821,25 +821,25 @@ void Widget::set_font(Gfx::Font const* font)
 
 
 void Widget::set_font_family(String const& family)
 void Widget::set_font_family(String const& family)
 {
 {
-    set_font(Gfx::FontDatabase::the().get(family.to_deprecated_string(), m_font->presentation_size(), m_font->weight(), m_font->width(), m_font->slope()));
+    set_font(Gfx::FontDatabase::the().get(family, m_font->presentation_size(), m_font->weight(), m_font->width(), m_font->slope()));
 }
 }
 
 
 void Widget::set_font_size(unsigned size)
 void Widget::set_font_size(unsigned size)
 {
 {
-    set_font(Gfx::FontDatabase::the().get(m_font->family().to_deprecated_string(), size, m_font->weight(), m_font->width(), m_font->slope()));
+    set_font(Gfx::FontDatabase::the().get(m_font->family(), size, m_font->weight(), m_font->width(), m_font->slope()));
 }
 }
 
 
 void Widget::set_font_weight(unsigned weight)
 void Widget::set_font_weight(unsigned weight)
 {
 {
-    set_font(Gfx::FontDatabase::the().get(m_font->family().to_deprecated_string(), m_font->presentation_size(), weight, m_font->width(), m_font->slope()));
+    set_font(Gfx::FontDatabase::the().get(m_font->family(), m_font->presentation_size(), weight, m_font->width(), m_font->slope()));
 }
 }
 
 
 void Widget::set_font_fixed_width(bool fixed_width)
 void Widget::set_font_fixed_width(bool fixed_width)
 {
 {
     if (fixed_width)
     if (fixed_width)
-        set_font(Gfx::FontDatabase::the().get(Gfx::FontDatabase::the().default_fixed_width_font().family().to_deprecated_string(), m_font->presentation_size(), m_font->weight(), m_font->width(), m_font->slope()));
+        set_font(Gfx::FontDatabase::the().get(Gfx::FontDatabase::the().default_fixed_width_font().family(), m_font->presentation_size(), m_font->weight(), m_font->width(), m_font->slope()));
     else
     else
-        set_font(Gfx::FontDatabase::the().get(Gfx::FontDatabase::the().default_font().family().to_deprecated_string(), m_font->presentation_size(), m_font->weight(), m_font->width(), m_font->slope()));
+        set_font(Gfx::FontDatabase::the().get(Gfx::FontDatabase::the().default_font().family(), m_font->presentation_size(), m_font->weight(), m_font->width(), m_font->slope()));
 }
 }
 
 
 bool Widget::is_font_fixed_width()
 bool Widget::is_font_fixed_width()

+ 1 - 1
Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp

@@ -33,7 +33,7 @@ ErrorOr<void> CoverWizardPage::build(String title, String subtitle)
     m_content_widget->set_layout<VerticalBoxLayout>(20);
     m_content_widget->set_layout<VerticalBoxLayout>(20);
 
 
     m_header_label = TRY(m_content_widget->try_add<Label>(move(title)));
     m_header_label = TRY(m_content_widget->try_add<Label>(move(title)));
-    m_header_label->set_font(Gfx::FontDatabase::the().get("Pebbleton", 14, 700, Gfx::FontWidth::Normal, 0));
+    m_header_label->set_font(Gfx::FontDatabase::the().get("Pebbleton"_fly_string, 14, 700, Gfx::FontWidth::Normal, 0));
     m_header_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
     m_header_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
     m_header_label->set_fixed_height(48);
     m_header_label->set_fixed_height(48);
 
 

+ 2 - 2
Userland/Libraries/LibGfx/Font/BitmapFont.cpp

@@ -409,14 +409,14 @@ String BitmapFont::variant() const
 
 
 RefPtr<Font> BitmapFont::with_size(float point_size) const
 RefPtr<Font> BitmapFont::with_size(float point_size) const
 {
 {
-    return Gfx::FontDatabase::the().get(family().to_deprecated_string(), point_size, weight(), width(), slope());
+    return Gfx::FontDatabase::the().get(family(), point_size, weight(), width(), slope());
 }
 }
 
 
 Font const& Font::bold_variant() const
 Font const& Font::bold_variant() const
 {
 {
     if (m_bold_variant)
     if (m_bold_variant)
         return *m_bold_variant;
         return *m_bold_variant;
-    m_bold_variant = Gfx::FontDatabase::the().get(family().to_deprecated_string(), presentation_size(), 700, Gfx::FontWidth::Normal, 0);
+    m_bold_variant = Gfx::FontDatabase::the().get(family(), presentation_size(), 700, Gfx::FontWidth::Normal, 0);
     if (!m_bold_variant)
     if (!m_bold_variant)
         m_bold_variant = this;
         m_bold_variant = this;
     return *m_bold_variant;
     return *m_bold_variant;

+ 11 - 10
Userland/Libraries/LibGfx/Font/FontDatabase.cpp

@@ -5,6 +5,7 @@
  */
  */
 
 
 #include <AK/DeprecatedFlyString.h>
 #include <AK/DeprecatedFlyString.h>
+#include <AK/FlyString.h>
 #include <AK/Queue.h>
 #include <AK/Queue.h>
 #include <AK/QuickSort.h>
 #include <AK/QuickSort.h>
 #include <LibCore/DirIterator.h>
 #include <LibCore/DirIterator.h>
@@ -117,7 +118,7 @@ Font& FontDatabase::default_fixed_width_font()
 
 
 struct FontDatabase::Private {
 struct FontDatabase::Private {
     HashMap<DeprecatedString, NonnullRefPtr<Gfx::Font>, CaseInsensitiveStringTraits> full_name_to_font_map;
     HashMap<DeprecatedString, NonnullRefPtr<Gfx::Font>, CaseInsensitiveStringTraits> full_name_to_font_map;
-    HashMap<DeprecatedFlyString, Vector<NonnullRefPtr<Typeface>>, CaseInsensitiveStringTraits> typefaces;
+    HashMap<FlyString, Vector<NonnullRefPtr<Typeface>>, AK::ASCIICaseInsensitiveFlyStringTraits> typefaces;
 };
 };
 
 
 void FontDatabase::load_all_fonts_from_path(DeprecatedString const& root)
 void FontDatabase::load_all_fonts_from_path(DeprecatedString const& root)
@@ -144,20 +145,20 @@ void FontDatabase::load_all_fonts_from_path(DeprecatedString const& root)
                 if (auto font_or_error = Gfx::BitmapFont::try_load_from_file(path); !font_or_error.is_error()) {
                 if (auto font_or_error = Gfx::BitmapFont::try_load_from_file(path); !font_or_error.is_error()) {
                     auto font = font_or_error.release_value();
                     auto font = font_or_error.release_value();
                     m_private->full_name_to_font_map.set(font->qualified_name().to_deprecated_string(), *font);
                     m_private->full_name_to_font_map.set(font->qualified_name().to_deprecated_string(), *font);
-                    auto typeface = get_or_create_typeface(font->family().to_deprecated_string(), font->variant().to_deprecated_string());
+                    auto typeface = get_or_create_typeface(font->family(), font->variant());
                     typeface->add_bitmap_font(font);
                     typeface->add_bitmap_font(font);
                 }
                 }
             } else if (path.ends_with(".ttf"sv)) {
             } else if (path.ends_with(".ttf"sv)) {
                 // FIXME: What about .otf
                 // FIXME: What about .otf
                 if (auto font_or_error = OpenType::Font::try_load_from_file(path); !font_or_error.is_error()) {
                 if (auto font_or_error = OpenType::Font::try_load_from_file(path); !font_or_error.is_error()) {
                     auto font = font_or_error.release_value();
                     auto font = font_or_error.release_value();
-                    auto typeface = get_or_create_typeface(font->family().to_deprecated_string(), font->variant().to_deprecated_string());
+                    auto typeface = get_or_create_typeface(font->family(), font->variant());
                     typeface->set_vector_font(move(font));
                     typeface->set_vector_font(move(font));
                 }
                 }
             } else if (path.ends_with(".woff"sv)) {
             } else if (path.ends_with(".woff"sv)) {
                 if (auto font_or_error = WOFF::Font::try_load_from_file(path); !font_or_error.is_error()) {
                 if (auto font_or_error = WOFF::Font::try_load_from_file(path); !font_or_error.is_error()) {
                     auto font = font_or_error.release_value();
                     auto font = font_or_error.release_value();
-                    auto typeface = get_or_create_typeface(font->family().to_deprecated_string(), font->variant().to_deprecated_string());
+                    auto typeface = get_or_create_typeface(font->family(), font->variant());
                     typeface->set_vector_font(move(font));
                     typeface->set_vector_font(move(font));
                 }
                 }
             }
             }
@@ -204,7 +205,7 @@ RefPtr<Gfx::Font> FontDatabase::get_by_name(StringView name)
             auto slope = parts.take_last().to_int().value_or(0);
             auto slope = parts.take_last().to_int().value_or(0);
             auto weight = parts.take_last().to_int().value_or(0);
             auto weight = parts.take_last().to_int().value_or(0);
             auto size = parts.take_last().to_int().value_or(0);
             auto size = parts.take_last().to_int().value_or(0);
-            auto family = DeprecatedString::join(' ', parts);
+            auto family = MUST(String::join(' ', parts));
             return get(family, size, weight, Gfx::FontWidth::Normal, slope);
             return get(family, size, weight, Gfx::FontWidth::Normal, slope);
         }
         }
         dbgln("Font lookup failed: '{}'", name);
         dbgln("Font lookup failed: '{}'", name);
@@ -213,7 +214,7 @@ RefPtr<Gfx::Font> FontDatabase::get_by_name(StringView name)
     return it->value;
     return it->value;
 }
 }
 
 
-RefPtr<Gfx::Font> FontDatabase::get(DeprecatedFlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope, Font::AllowInexactSizeMatch allow_inexact_size_match)
+RefPtr<Gfx::Font> FontDatabase::get(FlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope, Font::AllowInexactSizeMatch allow_inexact_size_match)
 {
 {
     auto it = m_private->typefaces.find(family);
     auto it = m_private->typefaces.find(family);
     if (it == m_private->typefaces.end())
     if (it == m_private->typefaces.end())
@@ -225,7 +226,7 @@ RefPtr<Gfx::Font> FontDatabase::get(DeprecatedFlyString const& family, float poi
     return nullptr;
     return nullptr;
 }
 }
 
 
-RefPtr<Gfx::Font> FontDatabase::get(DeprecatedFlyString const& family, DeprecatedFlyString const& variant, float point_size, Font::AllowInexactSizeMatch allow_inexact_size_match)
+RefPtr<Gfx::Font> FontDatabase::get(FlyString const& family, FlyString const& variant, float point_size, Font::AllowInexactSizeMatch allow_inexact_size_match)
 {
 {
     auto it = m_private->typefaces.find(family);
     auto it = m_private->typefaces.find(family);
     if (it == m_private->typefaces.end())
     if (it == m_private->typefaces.end())
@@ -237,7 +238,7 @@ RefPtr<Gfx::Font> FontDatabase::get(DeprecatedFlyString const& family, Deprecate
     return nullptr;
     return nullptr;
 }
 }
 
 
-RefPtr<Typeface> FontDatabase::get_or_create_typeface(DeprecatedString const& family, DeprecatedString const& variant)
+RefPtr<Typeface> FontDatabase::get_or_create_typeface(FlyString const& family, FlyString const& variant)
 {
 {
     auto it = m_private->typefaces.find(family);
     auto it = m_private->typefaces.find(family);
     if (it != m_private->typefaces.end()) {
     if (it != m_private->typefaces.end()) {
@@ -260,9 +261,9 @@ void FontDatabase::for_each_typeface(Function<void(Typeface const&)> callback)
     }
     }
 }
 }
 
 
-void FontDatabase::for_each_typeface_with_family_name(String const& family_name, Function<void(Typeface const&)> callback)
+void FontDatabase::for_each_typeface_with_family_name(FlyString const& family_name, Function<void(Typeface const&)> callback)
 {
 {
-    auto it = m_private->typefaces.find(family_name.bytes_as_string_view());
+    auto it = m_private->typefaces.find(family_name);
     if (it == m_private->typefaces.end())
     if (it == m_private->typefaces.end())
         return;
         return;
     for (auto const& typeface : it->value)
     for (auto const& typeface : it->value)

+ 5 - 4
Userland/Libraries/LibGfx/Font/FontDatabase.h

@@ -7,6 +7,7 @@
 #pragma once
 #pragma once
 
 
 #include <AK/DeprecatedString.h>
 #include <AK/DeprecatedString.h>
+#include <AK/FlyString.h>
 #include <AK/Function.h>
 #include <AK/Function.h>
 #include <AK/HashMap.h>
 #include <AK/HashMap.h>
 #include <AK/OwnPtr.h>
 #include <AK/OwnPtr.h>
@@ -48,14 +49,14 @@ public:
     static void set_fixed_width_font_query(DeprecatedString);
     static void set_fixed_width_font_query(DeprecatedString);
     static void set_default_fonts_lookup_path(DeprecatedString);
     static void set_default_fonts_lookup_path(DeprecatedString);
 
 
-    RefPtr<Gfx::Font> get(DeprecatedFlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No);
-    RefPtr<Gfx::Font> get(DeprecatedFlyString const& family, DeprecatedFlyString const& variant, float point_size, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No);
+    RefPtr<Gfx::Font> get(FlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No);
+    RefPtr<Gfx::Font> get(FlyString const& family, FlyString const& variant, float point_size, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No);
     RefPtr<Gfx::Font> get_by_name(StringView);
     RefPtr<Gfx::Font> get_by_name(StringView);
     void for_each_font(Function<void(Gfx::Font const&)>);
     void for_each_font(Function<void(Gfx::Font const&)>);
     void for_each_fixed_width_font(Function<void(Gfx::Font const&)>);
     void for_each_fixed_width_font(Function<void(Gfx::Font const&)>);
 
 
     void for_each_typeface(Function<void(Typeface const&)>);
     void for_each_typeface(Function<void(Typeface const&)>);
-    void for_each_typeface_with_family_name(String const& family_name, Function<void(Typeface const&)>);
+    void for_each_typeface_with_family_name(FlyString const& family_name, Function<void(Typeface const&)>);
 
 
     void load_all_fonts_from_path(DeprecatedString const&);
     void load_all_fonts_from_path(DeprecatedString const&);
 
 
@@ -63,7 +64,7 @@ private:
     FontDatabase();
     FontDatabase();
     ~FontDatabase() = default;
     ~FontDatabase() = default;
 
 
-    RefPtr<Typeface> get_or_create_typeface(DeprecatedString const& family, DeprecatedString const& variant);
+    RefPtr<Typeface> get_or_create_typeface(FlyString const& family, FlyString const& variant);
 
 
     struct Private;
     struct Private;
     OwnPtr<Private> m_private;
     OwnPtr<Private> m_private;

+ 8 - 7
Userland/Libraries/LibGfx/Font/Typeface.h

@@ -7,6 +7,7 @@
 #pragma once
 #pragma once
 
 
 #include <AK/DeprecatedFlyString.h>
 #include <AK/DeprecatedFlyString.h>
+#include <AK/FlyString.h>
 #include <AK/Function.h>
 #include <AK/Function.h>
 #include <AK/RefCounted.h>
 #include <AK/RefCounted.h>
 #include <AK/Vector.h>
 #include <AK/Vector.h>
@@ -18,14 +19,14 @@ namespace Gfx {
 
 
 class Typeface : public RefCounted<Typeface> {
 class Typeface : public RefCounted<Typeface> {
 public:
 public:
-    Typeface(DeprecatedString const& family, DeprecatedString const& variant)
-        : m_family(family)
-        , m_variant(variant)
+    Typeface(FlyString family, FlyString variant)
+        : m_family(move(family))
+        , m_variant(move(variant))
     {
     {
     }
     }
 
 
-    DeprecatedFlyString const& family() const { return m_family; }
-    DeprecatedFlyString const& variant() const { return m_variant; }
+    FlyString const& family() const { return m_family; }
+    FlyString const& variant() const { return m_variant; }
     unsigned weight() const;
     unsigned weight() const;
     unsigned width() const;
     unsigned width() const;
     u8 slope() const;
     u8 slope() const;
@@ -40,8 +41,8 @@ public:
     RefPtr<Font> get_font(float point_size, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No) const;
     RefPtr<Font> get_font(float point_size, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No) const;
 
 
 private:
 private:
-    DeprecatedFlyString m_family;
-    DeprecatedFlyString m_variant;
+    FlyString m_family;
+    FlyString m_variant;
 
 
     Vector<RefPtr<BitmapFont>> m_bitmap_fonts;
     Vector<RefPtr<BitmapFont>> m_bitmap_fonts;
     RefPtr<VectorFont> m_vector_font;
     RefPtr<VectorFont> m_vector_font;

+ 9 - 9
Userland/Libraries/LibPDF/Fonts/PDFFont.cpp

@@ -61,25 +61,25 @@ PDFErrorOr<NonnullRefPtr<Gfx::Font>> PDFFont::replacement_for(StringView name, f
     bool is_bold = name.contains("bold"sv, CaseSensitivity::CaseInsensitive);
     bool is_bold = name.contains("bold"sv, CaseSensitivity::CaseInsensitive);
     bool is_italic = name.contains("italic"sv, CaseSensitivity::CaseInsensitive);
     bool is_italic = name.contains("italic"sv, CaseSensitivity::CaseInsensitive);
 
 
-    DeprecatedString font_family;
+    FlyString font_family;
     if (name.contains("times"sv, CaseSensitivity::CaseInsensitive)) {
     if (name.contains("times"sv, CaseSensitivity::CaseInsensitive)) {
-        font_family = "Liberation Serif";
+        font_family = "Liberation Serif"_fly_string;
     } else if (name.contains("courier"sv, CaseSensitivity::CaseInsensitive)) {
     } else if (name.contains("courier"sv, CaseSensitivity::CaseInsensitive)) {
-        font_family = "Liberation Mono";
+        font_family = "Liberation Mono"_fly_string;
     } else {
     } else {
-        font_family = "Liberation Sans";
+        font_family = "Liberation Sans"_fly_string;
     }
     }
 
 
-    DeprecatedString font_variant;
+    FlyString font_variant;
 
 
     if (is_bold && is_italic) {
     if (is_bold && is_italic) {
-        font_variant = "BoldItalic";
+        font_variant = "BoldItalic"_fly_string;
     } else if (is_bold) {
     } else if (is_bold) {
-        font_variant = "Bold";
+        font_variant = "Bold"_fly_string;
     } else if (is_italic) {
     } else if (is_italic) {
-        font_variant = "Italic";
+        font_variant = "Italic"_fly_string;
     } else {
     } else {
-        font_variant = "Regular";
+        font_variant = "Regular"_fly_string;
     }
     }
 
 
     float point_size = (font_size * POINTS_PER_INCH) / DEFAULT_DPI;
     float point_size = (font_size * POINTS_PER_INCH) / DEFAULT_DPI;

+ 2 - 2
Userland/Libraries/LibWeb/CSS/StyleComputer.cpp

@@ -1848,7 +1848,7 @@ RefPtr<Gfx::Font const> StyleComputer::font_matching_algorithm(FontFaceKey const
     Gfx::FontDatabase::the().for_each_typeface_with_family_name(key.family_name.to_string(), [&](Gfx::Typeface const& typeface) {
     Gfx::FontDatabase::the().for_each_typeface_with_family_name(key.family_name.to_string(), [&](Gfx::Typeface const& typeface) {
         matching_family_fonts.empend(
         matching_family_fonts.empend(
             FontFaceKey {
             FontFaceKey {
-                .family_name = MUST(FlyString::from_deprecated_fly_string(typeface.family())),
+                .family_name = typeface.family(),
                 .weight = static_cast<int>(typeface.weight()),
                 .weight = static_cast<int>(typeface.weight()),
                 .slope = typeface.slope(),
                 .slope = typeface.slope(),
             },
             },
@@ -2022,7 +2022,7 @@ RefPtr<Gfx::Font const> StyleComputer::compute_font_for_style_values(DOM::Elemen
         if (auto found_font = font_matching_algorithm(key, font_size_in_pt))
         if (auto found_font = font_matching_algorithm(key, font_size_in_pt))
             return found_font;
             return found_font;
 
 
-        if (auto found_font = Gfx::FontDatabase::the().get(family.to_deprecated_string(), font_size_in_pt, weight, width, slope, Gfx::Font::AllowInexactSizeMatch::Yes))
+        if (auto found_font = Gfx::FontDatabase::the().get(family, font_size_in_pt, weight, width, slope, Gfx::Font::AllowInexactSizeMatch::Yes))
             return found_font;
             return found_font;
 
 
         return {};
         return {};