Skip to content

Commit 59c963f

Browse files
ayeteadoetrflynn89
authored andcommitted
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.
1 parent 4fb1ba0 commit 59c963f

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

Libraries/LibGfx/Font/TypefaceSkia.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
#include <core/SkFontMgr.h>
1313
#include <core/SkStream.h>
1414
#include <core/SkTypeface.h>
15-
#ifndef AK_OS_ANDROID
16-
# include <ports/SkFontMgr_fontconfig.h>
17-
#else
15+
#if defined(AK_OS_ANDROID)
1816
# include <ports/SkFontMgr_android.h>
17+
#elif defined(AK_OS_WINDOWS)
18+
# include <ports/SkTypeface_win.h>
19+
#else
20+
# include <ports/SkFontMgr_fontconfig.h>
1921
#endif
2022

2123
#ifdef AK_OS_MACOS
@@ -38,12 +40,14 @@ ErrorOr<NonnullRefPtr<TypefaceSkia>> TypefaceSkia::load_from_buffer(AK::Readonly
3840
s_font_manager = SkFontMgr_New_CoreText(nullptr);
3941
}
4042
#endif
41-
#ifndef AK_OS_ANDROID
43+
#if defined(AK_OS_ANDROID)
44+
s_font_manager = SkFontMgr_New_Android(nullptr);
45+
#elif defined(AK_OS_WINDOWS)
46+
s_font_manager = SkFontMgr_New_DirectWrite();
47+
#else
4248
if (!s_font_manager) {
4349
s_font_manager = SkFontMgr_New_FontConfig(nullptr);
4450
}
45-
#else
46-
s_font_manager = SkFontMgr_New_Android(nullptr);
4751
#endif
4852
}
4953

Meta/CMake/fontconfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include_guard()
22

3-
if (NOT APPLE AND NOT ANDROID)
3+
if (NOT APPLE AND NOT ANDROID AND NOT WIN32)
44
find_package(Fontconfig REQUIRED)
55
set(HAS_FONTCONFIG ON CACHE BOOL "" FORCE)
66
add_cxx_compile_definitions(USE_FONTCONFIG=1)

vcpkg.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
},
5757
{
5858
"name": "fontconfig",
59-
"platform": "linux | freebsd | openbsd | osx | windows"
59+
"platform": "linux | freebsd | openbsd | osx"
6060
},
6161
{
6262
"name": "harfbuzz",
@@ -175,7 +175,17 @@
175175
},
176176
{
177177
"name": "skia",
178-
"platform": "linux | freebsd | openbsd | windows",
178+
"platform": "windows",
179+
"features": [
180+
"freetype",
181+
"harfbuzz",
182+
"icu",
183+
"vulkan"
184+
]
185+
},
186+
{
187+
"name": "skia",
188+
"platform": "linux | freebsd | openbsd",
179189
"features": [
180190
"freetype",
181191
"fontconfig",

0 commit comments

Comments
 (0)