Browse Source

LibWeb+Ladybird: Remove FontPluginSerenity (+ use Ladybird::FontPlugin)

Andreas Kling 1 year ago
parent
commit
966d442152

+ 1 - 0
Ladybird/WebWorker/CMakeLists.txt

@@ -8,6 +8,7 @@ set(WEBWORKER_SOURCES
     "${WEBWORKER_SOURCE_DIR}/ConnectionFromClient.cpp"
     "${WEBWORKER_SOURCE_DIR}/DedicatedWorkerHost.cpp"
     "${WEBWORKER_SOURCE_DIR}/PageHost.cpp"
+    ../FontPlugin.cpp
     ../HelperProcess.cpp
     ../Utilities.cpp
 )

+ 1 - 2
Ladybird/WebWorker/main.cpp

@@ -20,7 +20,6 @@
 #include <LibWeb/Loader/ResourceLoader.h>
 #include <LibWeb/Platform/EventLoopPlugin.h>
 #include <LibWeb/Platform/EventLoopPluginSerenity.h>
-#include <LibWeb/Platform/FontPluginSerenity.h>
 #include <LibWeb/WebSockets/WebSocket.h>
 #include <LibWebView/RequestServerAdapter.h>
 #include <LibWebView/WebSocketClientAdapter.h>
@@ -45,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity);
     Core::EventLoop event_loop;
 
-    Web::Platform::FontPlugin::install(*new Web::Platform::FontPluginSerenity);
+    Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(false));
 
     TRY(initialize_lagom_networking(request_server_socket));
 

+ 0 - 1
Meta/gn/secondary/Userland/Libraries/LibWeb/Platform/BUILD.gn

@@ -7,7 +7,6 @@ source_set("Platform") {
     "EventLoopPlugin.cpp",
     "EventLoopPluginSerenity.cpp",
     "FontPlugin.cpp",
-    "FontPluginSerenity.cpp",
     "ImageCodecPlugin.cpp",
     "Timer.cpp",
     "TimerSerenity.cpp",

+ 0 - 1
Userland/Libraries/LibWeb/CMakeLists.txt

@@ -579,7 +579,6 @@ set(SOURCES
     Platform/EventLoopPlugin.cpp
     Platform/EventLoopPluginSerenity.cpp
     Platform/FontPlugin.cpp
-    Platform/FontPluginSerenity.cpp
     Platform/ImageCodecPlugin.cpp
     Platform/Timer.cpp
     Platform/TimerSerenity.cpp

+ 0 - 55
Userland/Libraries/LibWeb/Platform/FontPluginSerenity.cpp

@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "FontPluginSerenity.h"
-#include <AK/ByteString.h>
-#include <LibGfx/Font/FontDatabase.h>
-
-namespace Web::Platform {
-
-FontPluginSerenity::FontPluginSerenity()
-{
-    // NOTE: These will eventually get replaced by system defaults.
-    Gfx::FontDatabase::set_default_font_query("Katica 10 400 0");
-    Gfx::FontDatabase::set_fixed_width_font_query("Csilla 10 400 0");
-}
-
-FontPluginSerenity::~FontPluginSerenity() = default;
-
-Gfx::Font& FontPluginSerenity::default_font()
-{
-    return Gfx::FontDatabase::default_font();
-}
-
-Gfx::Font& FontPluginSerenity::default_fixed_width_font()
-{
-    return Gfx::FontDatabase::default_fixed_width_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) {
-    case GenericFont::SansSerif:
-    case GenericFont::UiSansSerif:
-    case GenericFont::Cursive:
-    case GenericFont::UiRounded:
-        return default_font().family();
-    case GenericFont::Monospace:
-    case GenericFont::UiMonospace:
-        return default_fixed_width_font().family();
-    case GenericFont::Serif:
-    case GenericFont::UiSerif:
-        return "Roman"_fly_string;
-    case GenericFont::Fantasy:
-        return "Comic Book"_fly_string;
-    case GenericFont::__Count:
-        VERIFY_NOT_REACHED();
-    }
-    VERIFY_NOT_REACHED();
-}
-
-}

+ 0 - 24
Userland/Libraries/LibWeb/Platform/FontPluginSerenity.h

@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Vector.h>
-#include <LibWeb/Platform/FontPlugin.h>
-
-namespace Web::Platform {
-
-class FontPluginSerenity final : public FontPlugin {
-public:
-    FontPluginSerenity();
-    virtual ~FontPluginSerenity();
-
-    virtual Gfx::Font& default_font() override;
-    virtual Gfx::Font& default_fixed_width_font() override;
-    virtual FlyString generic_font_name(GenericFont) override;
-};
-
-}