From f49a65cb28891b8053d7c36d8d582ea258977c8d Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 11 Jan 2023 20:34:59 +0000 Subject: [PATCH] Ladybird: Use standard font paths in FontPluginQt This makes vector fonts load on macOS, where /usr/share/fonts doesn't exist and Ladybird would only load the bitmap fonts from ./res/fonts in the SerenityOS resource root directory. Additionally, fonts in {/usr/share/local,~/.local}/fonts are now loaded on Linux. --- Ladybird/FontPluginQt.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Ladybird/FontPluginQt.cpp b/Ladybird/FontPluginQt.cpp index da45b3198a2..e6babcbe39b 100644 --- a/Ladybird/FontPluginQt.cpp +++ b/Ladybird/FontPluginQt.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, Andreas Kling + * Copyright (c) 2023, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -8,6 +9,8 @@ #include "FontPluginQt.h" #include +#include +#include #include #include #include @@ -21,8 +24,9 @@ FontPluginQt::FontPluginQt() // Load the default SerenityOS fonts... Gfx::FontDatabase::set_default_fonts_lookup_path(DeprecatedString::formatted("{}/res/fonts", s_serenity_resource_root)); - // ...and also anything we can find in /usr/share/fonts - Gfx::FontDatabase::the().load_all_fonts_from_path("/usr/share/fonts"); + // ...and also anything we can find in the system's font directories + for (auto const& path : Core::StandardPaths::font_directories().release_value_but_fixme_should_propagate_errors()) + Gfx::FontDatabase::the().load_all_fonts_from_path(path.to_deprecated_string()); Gfx::FontDatabase::set_default_font_query("Katica 10 400 0"); Gfx::FontDatabase::set_fixed_width_font_query("Csilla 10 400 0");