diff --git a/Ladybird/FontPlugin.cpp b/Ladybird/FontPlugin.cpp index 3fd560b15f8..106f4d679ec 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(MUST(String::from_deprecated_string(default_font_name)), 12.0, 400, Gfx::FontWidth::Normal, 0); + m_default_font = Gfx::FontDatabase::the().get(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(MUST(String::from_deprecated_string(default_fixed_width_font_name)), 12.0, 400, Gfx::FontWidth::Normal, 0); + m_default_fixed_width_font = Gfx::FontDatabase::the().get(default_fixed_width_font_name, 12.0, 400, Gfx::FontWidth::Normal, 0); VERIFY(m_default_fixed_width_font); } @@ -66,16 +66,16 @@ void FontPlugin::update_generic_fonts() m_generic_font_names.resize(static_cast(Web::Platform::GenericFont::__Count)); - auto update_mapping = [&](Web::Platform::GenericFont generic_font, ReadonlySpan fallbacks) { + auto update_mapping = [&](Web::Platform::GenericFont generic_font, ReadonlySpan fallbacks) { if (m_is_layout_test_mode) { - m_generic_font_names[static_cast(generic_font)] = "SerenitySans"; + m_generic_font_names[static_cast(generic_font)] = "SerenitySans"_fly_string; return; } RefPtr gfx_font; for (auto& fallback : fallbacks) { - gfx_font = Gfx::FontDatabase::the().get(MUST(String::from_deprecated_string(fallback)), 16, 400, Gfx::FontWidth::Normal, 0, Gfx::Font::AllowInexactSizeMatch::Yes); + gfx_font = Gfx::FontDatabase::the().get(fallback, 16, 400, Gfx::FontWidth::Normal, 0, Gfx::Font::AllowInexactSizeMatch::Yes); if (gfx_font) break; } @@ -87,16 +87,16 @@ void FontPlugin::update_generic_fonts() gfx_font = Gfx::FontDatabase::default_font(); } - m_generic_font_names[static_cast(generic_font)] = gfx_font->family().to_deprecated_string(); + m_generic_font_names[static_cast(generic_font)] = gfx_font->family(); }; // Fallback fonts to look for if Gfx::Font can't load expected font // The lists are basically arbitrary, taken from https://www.w3.org/Style/Examples/007/fonts.en.html - Vector cursive_fallbacks { "Comic Sans MS", "Comic Sans", "Apple Chancery", "Bradley Hand", "Brush Script MT", "Snell Roundhand", "URW Chancery L" }; - Vector fantasy_fallbacks { "Impact", "Luminari", "Chalkduster", "Jazz LET", "Blippo", "Stencil Std", "Marker Felt", "Trattatello" }; - Vector monospace_fallbacks { "Andale Mono", "Courier New", "Courier", "FreeMono", "OCR A Std", "DejaVu Sans Mono", "Liberation Mono", "Csilla" }; - Vector sans_serif_fallbacks { "Arial", "Helvetica", "Verdana", "Trebuchet MS", "Gill Sans", "Noto Sans", "Avantgarde", "Optima", "Arial Narrow", "Liberation Sans", "Katica" }; - Vector serif_fallbacks { "Times", "Times New Roman", "Didot", "Georgia", "Palatino", "Bookman", "New Century Schoolbook", "American Typewriter", "Liberation Serif", "Roman" }; + Vector cursive_fallbacks { "Comic Sans MS"_fly_string, "Comic Sans"_fly_string, "Apple Chancery"_fly_string, "Bradley Hand"_fly_string, "Brush Script MT"_fly_string, "Snell Roundhand"_fly_string, "URW Chancery L"_fly_string }; + Vector fantasy_fallbacks { "Impact"_fly_string, "Luminari"_fly_string, "Chalkduster"_fly_string, "Jazz LET"_fly_string, "Blippo"_fly_string, "Stencil Std"_fly_string, "Marker Felt"_fly_string, "Trattatello"_fly_string }; + Vector monospace_fallbacks { "Andale Mono"_fly_string, "Courier New"_fly_string, "Courier"_fly_string, "FreeMono"_fly_string, "OCR A Std"_fly_string, "DejaVu Sans Mono"_fly_string, "Liberation Mono"_fly_string, "Csilla"_fly_string }; + Vector sans_serif_fallbacks { "Arial"_fly_string, "Helvetica"_fly_string, "Verdana"_fly_string, "Trebuchet MS"_fly_string, "Gill Sans"_fly_string, "Noto Sans"_fly_string, "Avantgarde"_fly_string, "Optima"_fly_string, "Arial Narrow"_fly_string, "Liberation Sans"_fly_string, "Katica"_fly_string }; + Vector serif_fallbacks { "Times"_fly_string, "Times New Roman"_fly_string, "Didot"_fly_string, "Georgia"_fly_string, "Palatino"_fly_string, "Bookman"_fly_string, "New Century Schoolbook"_fly_string, "American Typewriter"_fly_string, "Liberation Serif"_fly_string, "Roman"_fly_string }; update_mapping(Web::Platform::GenericFont::Cursive, cursive_fallbacks); update_mapping(Web::Platform::GenericFont::Fantasy, fantasy_fallbacks); @@ -109,7 +109,7 @@ void FontPlugin::update_generic_fonts() update_mapping(Web::Platform::GenericFont::UiSerif, serif_fallbacks); } -DeprecatedString FontPlugin::generic_font_name(Web::Platform::GenericFont generic_font) +FlyString FontPlugin::generic_font_name(Web::Platform::GenericFont generic_font) { return m_generic_font_names[static_cast(generic_font)]; } diff --git a/Ladybird/FontPlugin.h b/Ladybird/FontPlugin.h index cfb09faa11c..56d7ff51d64 100644 --- a/Ladybird/FontPlugin.h +++ b/Ladybird/FontPlugin.h @@ -19,12 +19,12 @@ public: virtual Gfx::Font& default_font() override; virtual Gfx::Font& default_fixed_width_font() override; - virtual DeprecatedString generic_font_name(Web::Platform::GenericFont) override; + virtual FlyString generic_font_name(Web::Platform::GenericFont) override; void update_generic_fonts(); private: - Vector m_generic_font_names; + Vector m_generic_font_names; RefPtr m_default_font; RefPtr m_default_fixed_width_font; bool m_is_layout_test_mode { false }; diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 2dfdd6bb377..d6ac56663a7 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -2001,7 +2001,7 @@ RefPtr StyleComputer::compute_font_for_style_values(DOM::Elemen float const font_size_in_pt = font_size_in_px * 0.75f; - auto find_font = [&](String const& family) -> RefPtr { + auto find_font = [&](FlyString const& family) -> RefPtr { font_selector = { family, font_size_in_pt, weight, width, slope }; FontFaceKey key { @@ -2060,7 +2060,7 @@ RefPtr StyleComputer::compute_font_for_style_values(DOM::Elemen default: return {}; } - return find_font(String::from_deprecated_string(Platform::FontPlugin::the().generic_font_name(generic_font)).release_value_but_fixme_should_propagate_errors()); + return find_font(Platform::FontPlugin::the().generic_font_name(generic_font)); }; RefPtr found_font; diff --git a/Userland/Libraries/LibWeb/Platform/FontPlugin.h b/Userland/Libraries/LibWeb/Platform/FontPlugin.h index 825a54a7171..0825c909e5a 100644 --- a/Userland/Libraries/LibWeb/Platform/FontPlugin.h +++ b/Userland/Libraries/LibWeb/Platform/FontPlugin.h @@ -34,7 +34,7 @@ public: virtual Gfx::Font& default_font() = 0; virtual Gfx::Font& default_fixed_width_font() = 0; - virtual DeprecatedString generic_font_name(GenericFont) = 0; + virtual FlyString generic_font_name(GenericFont) = 0; }; } diff --git a/Userland/Libraries/LibWeb/Platform/FontPluginSerenity.cpp b/Userland/Libraries/LibWeb/Platform/FontPluginSerenity.cpp index c8f437e98c5..c9faa15001a 100644 --- a/Userland/Libraries/LibWeb/Platform/FontPluginSerenity.cpp +++ b/Userland/Libraries/LibWeb/Platform/FontPluginSerenity.cpp @@ -29,7 +29,7 @@ Gfx::Font& FontPluginSerenity::default_fixed_width_font() return Gfx::FontDatabase::default_fixed_width_font(); } -DeprecatedString FontPluginSerenity::generic_font_name(GenericFont generic_font) +FlyString FontPluginSerenity::generic_font_name(GenericFont generic_font) { // FIXME: Make these configurable at the browser settings level. Fall back to system defaults. switch (generic_font) { @@ -37,15 +37,15 @@ DeprecatedString FontPluginSerenity::generic_font_name(GenericFont generic_font) case GenericFont::UiSansSerif: case GenericFont::Cursive: case GenericFont::UiRounded: - return default_font().family().to_deprecated_string(); + return default_font().family(); case GenericFont::Monospace: case GenericFont::UiMonospace: - return default_fixed_width_font().family().to_deprecated_string(); + return default_fixed_width_font().family(); case GenericFont::Serif: case GenericFont::UiSerif: - return "Roman"; + return "Roman"_fly_string; case GenericFont::Fantasy: - return "Comic Book"; + return "Comic Book"_fly_string; case GenericFont::__Count: VERIFY_NOT_REACHED(); } diff --git a/Userland/Libraries/LibWeb/Platform/FontPluginSerenity.h b/Userland/Libraries/LibWeb/Platform/FontPluginSerenity.h index fccb3112eeb..20e89f4bd44 100644 --- a/Userland/Libraries/LibWeb/Platform/FontPluginSerenity.h +++ b/Userland/Libraries/LibWeb/Platform/FontPluginSerenity.h @@ -18,7 +18,7 @@ public: virtual Gfx::Font& default_font() override; virtual Gfx::Font& default_fixed_width_font() override; - virtual DeprecatedString generic_font_name(GenericFont) override; + virtual FlyString generic_font_name(GenericFont) override; }; }