1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

LibGfx: Allow changing the default font path

This commit is contained in:
Filiph Sandström 2022-02-13 12:59:11 +01:00 committed by Linus Groh
parent 62102e3130
commit 8b7987be86
2 changed files with 16 additions and 1 deletions

View file

@ -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);