mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibCore: Add StandardPaths::font_directories()
This provides a list of well-known directories containing font files, e.g. for use with Gfx::FontDatabase::load_all_fonts_from_path().
This commit is contained in:
parent
eed63e8174
commit
c5cadca542
Notes:
sideshowbarker
2024-07-17 02:35:27 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/c5cadca542 Pull-request: https://github.com/SerenityOS/serenity/pull/16962 Reviewed-by: https://github.com/awesomekling ✅
2 changed files with 21 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -7,6 +8,7 @@
|
|||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/SessionManagement.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
|
@ -110,4 +112,21 @@ DeprecatedString StandardPaths::tempfile_directory()
|
|||
return "/tmp";
|
||||
}
|
||||
|
||||
ErrorOr<Vector<String>> StandardPaths::font_directories()
|
||||
{
|
||||
return Vector { {
|
||||
#if defined(AK_OS_SERENITY)
|
||||
TRY(String::from_utf8("/res/fonts"sv)),
|
||||
#elif defined(AK_OS_MACOS)
|
||||
TRY(String::from_utf8("/System/Library/Fonts"sv)),
|
||||
TRY(String::from_utf8("/Library/Fonts"sv)),
|
||||
TRY(String::formatted("{}/Library/Fonts"sv, home_directory())),
|
||||
#else
|
||||
TRY(String::from_utf8("/usr/share/fonts"sv)),
|
||||
TRY(String::from_utf8("/usr/local/share/fonts"sv)),
|
||||
TRY(String::formatted("{}/.local/share/fonts"sv, home_directory())),
|
||||
#endif
|
||||
} };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -21,6 +22,7 @@ public:
|
|||
static DeprecatedString config_directory();
|
||||
static DeprecatedString data_directory();
|
||||
static ErrorOr<DeprecatedString> runtime_directory();
|
||||
static ErrorOr<Vector<String>> font_directories();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue