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

LibGfx: Load default font lazily

This is required when trying to use a Painter from lagom, due to
/res/font not being present
This commit is contained in:
Hendiadyoin1 2021-11-28 16:09:38 +01:00 committed by Ali Mohammad Pur
parent e69276e704
commit 9e7c16d0a4
2 changed files with 8 additions and 2 deletions

View file

@ -10,6 +10,7 @@
#include <AK/NonnullRefPtr.h>
#include <AK/Vector.h>
#include <LibGfx/Color.h>
#include <LibGfx/FontDatabase.h>
#include <LibGfx/Forward.h>
#include <LibGfx/Point.h>
#include <LibGfx/Rect.h>
@ -108,7 +109,12 @@ public:
};
void fill_path(Path const&, Color, WindingRule rule = WindingRule::Nonzero);
Font const& font() const { return *state().font; }
Font const& font() const
{
if (!state().font)
return FontDatabase::default_font();
return *state().font;
}
void set_font(Font const& font) { state().font = &font; }
enum class DrawOp {