LibGfx: Rely on fontconfig(if enabled) for font directory resolution

this commit also introduces GlobalFontConfig class that is now
responsible for fontconfig initialization. it seems sane, even thought
FcInit's docs state that if the default configuration has already been
loaded, this routine does nothing.
This commit is contained in:
blukai 2025-05-21 02:55:15 +02:00 committed by Andrew Kaster
commit e356a4bd01
Notes: github-actions[bot] 2025-05-26 18:15:33 +00:00
5 changed files with 86 additions and 10 deletions

View file

@ -16,7 +16,7 @@
#include <LibWebView/Plugins/FontPlugin.h>
#ifdef USE_FONTCONFIG
# include <fontconfig/fontconfig.h>
# include <LibGfx/Font/GlobalFontConfig.h>
#endif
namespace WebView {
@ -24,13 +24,6 @@ namespace WebView {
FontPlugin::FontPlugin(bool is_layout_test_mode, Gfx::SystemFontProvider* font_provider)
: m_is_layout_test_mode(is_layout_test_mode)
{
#ifdef USE_FONTCONFIG
{
auto fontconfig_initialized = FcInit();
VERIFY(fontconfig_initialized);
}
#endif
if (!font_provider)
font_provider = &static_cast<Gfx::PathFontProvider&>(Gfx::FontDatabase::the().install_system_font_provider(make<Gfx::PathFontProvider>()));
if (is<Gfx::PathFontProvider>(*font_provider)) {
@ -114,7 +107,7 @@ static Optional<String> query_fontconfig_for_generic_family(Web::Platform::Gener
VERIFY_NOT_REACHED();
}
auto* config = FcConfigGetCurrent();
auto* config = Gfx::GlobalFontConfig::the().get();
VERIFY(config);
FcPattern* pattern = FcNameParse(reinterpret_cast<FcChar8 const*>(pattern_string));