mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-24 13:35:12 +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:
parent
e69276e704
commit
9e7c16d0a4
Notes:
sideshowbarker
2024-07-18 00:29:58 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/9e7c16d0a44 Pull-request: https://github.com/SerenityOS/serenity/pull/11118 Reviewed-by: https://github.com/alimpfard ✅ Reviewed-by: https://github.com/sunverwerth ✅
2 changed files with 8 additions and 2 deletions
|
@ -64,7 +64,7 @@ Painter::Painter(Gfx::Bitmap& bitmap)
|
|||
VERIFY(bitmap.physical_width() % scale == 0);
|
||||
VERIFY(bitmap.physical_height() % scale == 0);
|
||||
m_state_stack.append(State());
|
||||
state().font = &FontDatabase::default_font();
|
||||
state().font = nullptr;
|
||||
state().clip_rect = { { 0, 0 }, bitmap.size() };
|
||||
state().scale = scale;
|
||||
m_clip_origin = state().clip_rect;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue