Meta+LibGfx: Remove fontconfig dependency on Windows

Previously when launching a UI process and/or a WebContent process on
Windows, the following message would be output to the console:

Fontconfig error: Cannot load default config file: No such file: (null)

Apparently on Windows, you have to provide a font .conf file to
fontconfig explicitly. Since we are not doing that, the default fonts
that are backed off to are not ideal.

Similar to how we aren't using fontconfig on Android, Windows also has
native font infrastructure in terms of both a collection of System
installed fonts as well as skia support for font managers that use
native Windows APIs. With that, we can remove the usage of fontconfig
entirely and improve the fonts used on websites like ladybird.org or
google.com.
This commit is contained in:
ayeteadoe
2025-11-18 16:34:00 -08:00
committed by Tim Flynn
parent 4fb1ba0193
commit 59c963f98f
Notes: github-actions[bot] 2025-11-22 12:52:59 +00:00
3 changed files with 23 additions and 9 deletions

View File

@@ -12,10 +12,12 @@
#include <core/SkFontMgr.h>
#include <core/SkStream.h>
#include <core/SkTypeface.h>
#ifndef AK_OS_ANDROID
# include <ports/SkFontMgr_fontconfig.h>
#else
#if defined(AK_OS_ANDROID)
# include <ports/SkFontMgr_android.h>
#elif defined(AK_OS_WINDOWS)
# include <ports/SkTypeface_win.h>
#else
# include <ports/SkFontMgr_fontconfig.h>
#endif
#ifdef AK_OS_MACOS
@@ -38,12 +40,14 @@ ErrorOr<NonnullRefPtr<TypefaceSkia>> TypefaceSkia::load_from_buffer(AK::Readonly
s_font_manager = SkFontMgr_New_CoreText(nullptr);
}
#endif
#ifndef AK_OS_ANDROID
#if defined(AK_OS_ANDROID)
s_font_manager = SkFontMgr_New_Android(nullptr);
#elif defined(AK_OS_WINDOWS)
s_font_manager = SkFontMgr_New_DirectWrite();
#else
if (!s_font_manager) {
s_font_manager = SkFontMgr_New_FontConfig(nullptr);
}
#else
s_font_manager = SkFontMgr_New_Android(nullptr);
#endif
}

View File

@@ -1,6 +1,6 @@
include_guard()
if (NOT APPLE AND NOT ANDROID)
if (NOT APPLE AND NOT ANDROID AND NOT WIN32)
find_package(Fontconfig REQUIRED)
set(HAS_FONTCONFIG ON CACHE BOOL "" FORCE)
add_cxx_compile_definitions(USE_FONTCONFIG=1)

View File

@@ -56,7 +56,7 @@
},
{
"name": "fontconfig",
"platform": "linux | freebsd | openbsd | osx | windows"
"platform": "linux | freebsd | openbsd | osx"
},
{
"name": "harfbuzz",
@@ -175,7 +175,17 @@
},
{
"name": "skia",
"platform": "linux | freebsd | openbsd | windows",
"platform": "windows",
"features": [
"freetype",
"harfbuzz",
"icu",
"vulkan"
]
},
{
"name": "skia",
"platform": "linux | freebsd | openbsd",
"features": [
"freetype",
"fontconfig",