mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibGfx: Improve logical separation of font_directories' ifdefs
in addition to what was proposed in https://github.com/LadybirdBrowser/ladybird/pull/4830#discussion_r2101301978
This commit is contained in:
parent
e356a4bd01
commit
3ab50be36a
Notes:
github-actions[bot]
2025-05-26 18:15:28 +00:00
Author: https://github.com/blukai
Commit: 3ab50be36a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4830
Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 22 additions and 7 deletions
|
@ -64,6 +64,7 @@ ErrorOr<Vector<String>> FontDatabase::font_directories()
|
|||
paths.append(TRY(String::from_utf8(StringView { dir_cstring, strlen(dir_cstring) })));
|
||||
}
|
||||
return paths;
|
||||
|
||||
#elif defined(AK_OS_HAIKU)
|
||||
Vector<String> paths_vector;
|
||||
char** paths;
|
||||
|
@ -76,34 +77,48 @@ ErrorOr<Vector<String>> FontDatabase::font_directories()
|
|||
}
|
||||
}
|
||||
return paths_vector;
|
||||
|
||||
#else
|
||||
auto paths = Vector { {
|
||||
# if defined(AK_OS_SERENITY)
|
||||
return Vector<String> { {
|
||||
"/res/fonts"_string,
|
||||
} };
|
||||
|
||||
# elif defined(AK_OS_MACOS)
|
||||
return Vector<String> { {
|
||||
"/System/Library/Fonts"_string,
|
||||
"/Library/Fonts"_string,
|
||||
TRY(String::formatted("{}/Library/Fonts"sv, Core::StandardPaths::home_directory())),
|
||||
} };
|
||||
|
||||
# elif defined(AK_OS_ANDROID)
|
||||
return Vector<String> { {
|
||||
// FIXME: We should be using the ASystemFontIterator NDK API here.
|
||||
// There is no guarantee that this will continue to exist on future versions of Android.
|
||||
"/system/fonts"_string,
|
||||
} };
|
||||
|
||||
# elif defined(AK_OS_WINDOWS)
|
||||
return Vector<String> { {
|
||||
TRY(String::formatted(R"({}\Fonts)"sv, getenv("WINDIR"))),
|
||||
TRY(String::formatted(R"({}\Microsoft\Windows\Fonts)"sv, getenv("LOCALAPPDATA"))),
|
||||
# else
|
||||
TRY(String::formatted("{}/fonts", Core::StandardPaths::user_data_directory())),
|
||||
TRY(String::formatted("{}/X11/fonts", Core::StandardPaths::user_data_directory())),
|
||||
# endif
|
||||
} };
|
||||
# if !(defined(AK_OS_SERENITY) || defined(AK_OS_MACOS) || defined(AK_OS_WINDOWS))
|
||||
|
||||
# else
|
||||
Vector<String> paths;
|
||||
|
||||
auto user_data_directory = Core::StandardPaths::user_data_directory();
|
||||
paths.append(TRY(String::formatted("{}/fonts", user_data_directory)));
|
||||
paths.append(TRY(String::formatted("{}/X11/fonts", user_data_directory)));
|
||||
|
||||
auto data_directories = Core::StandardPaths::system_data_directories();
|
||||
for (auto& data_directory : data_directories) {
|
||||
paths.append(TRY(String::formatted("{}/fonts", data_directory)));
|
||||
paths.append(TRY(String::formatted("{}/X11/fonts", data_directory)));
|
||||
}
|
||||
# endif
|
||||
|
||||
return paths;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue