mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
LibGfx: Allow changing the default font path
This commit is contained in:
parent
62102e3130
commit
8b7987be86
Notes:
sideshowbarker
2024-07-17 18:53:53 +09:00
Author: https://github.com/filiphsps Commit: https://github.com/SerenityOS/serenity/commit/8b7987be86
@ -25,6 +25,7 @@ static RefPtr<Font> s_default_font;
|
||||
static String s_default_font_query;
|
||||
static RefPtr<Font> s_fixed_width_font;
|
||||
static String s_fixed_width_font_query;
|
||||
static String s_default_fonts_lookup_path = "/res/fonts";
|
||||
|
||||
void FontDatabase::set_default_font_query(String query)
|
||||
{
|
||||
@ -39,6 +40,18 @@ String FontDatabase::default_font_query()
|
||||
return s_default_font_query;
|
||||
}
|
||||
|
||||
void FontDatabase::set_default_fonts_lookup_path(String path)
|
||||
{
|
||||
if (s_default_fonts_lookup_path == path)
|
||||
return;
|
||||
s_default_fonts_lookup_path = move(path);
|
||||
}
|
||||
|
||||
String FontDatabase::default_fonts_lookup_path()
|
||||
{
|
||||
return s_default_fonts_lookup_path;
|
||||
}
|
||||
|
||||
Font& FontDatabase::default_font()
|
||||
{
|
||||
if (!s_default_font) {
|
||||
@ -80,7 +93,7 @@ struct FontDatabase::Private {
|
||||
FontDatabase::FontDatabase()
|
||||
: m_private(make<Private>())
|
||||
{
|
||||
Core::DirIterator dir_iterator("/res/fonts", Core::DirIterator::SkipDots);
|
||||
Core::DirIterator dir_iterator(s_default_fonts_lookup_path, Core::DirIterator::SkipDots);
|
||||
if (dir_iterator.has_error()) {
|
||||
warnln("DirIterator: {}", dir_iterator.error_string());
|
||||
exit(1);
|
||||
|
@ -39,8 +39,10 @@ public:
|
||||
|
||||
static String default_font_query();
|
||||
static String fixed_width_font_query();
|
||||
static String default_fonts_lookup_path();
|
||||
static void set_default_font_query(String);
|
||||
static void set_fixed_width_font_query(String);
|
||||
static void set_default_fonts_lookup_path(String);
|
||||
|
||||
RefPtr<Gfx::Font> get(const String& family, unsigned size, unsigned weight, unsigned slope);
|
||||
RefPtr<Gfx::Font> get(const String& family, const String& variant, unsigned size);
|
||||
|
Loading…
Reference in New Issue
Block a user