mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:22:46 +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
					
				
					 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_width() % scale == 0); | ||||||
|     VERIFY(bitmap.physical_height() % scale == 0); |     VERIFY(bitmap.physical_height() % scale == 0); | ||||||
|     m_state_stack.append(State()); |     m_state_stack.append(State()); | ||||||
|     state().font = &FontDatabase::default_font(); |     state().font = nullptr; | ||||||
|     state().clip_rect = { { 0, 0 }, bitmap.size() }; |     state().clip_rect = { { 0, 0 }, bitmap.size() }; | ||||||
|     state().scale = scale; |     state().scale = scale; | ||||||
|     m_clip_origin = state().clip_rect; |     m_clip_origin = state().clip_rect; | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ | ||||||
| #include <AK/NonnullRefPtr.h> | #include <AK/NonnullRefPtr.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <LibGfx/Color.h> | #include <LibGfx/Color.h> | ||||||
|  | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Forward.h> | #include <LibGfx/Forward.h> | ||||||
| #include <LibGfx/Point.h> | #include <LibGfx/Point.h> | ||||||
| #include <LibGfx/Rect.h> | #include <LibGfx/Rect.h> | ||||||
|  | @ -108,7 +109,12 @@ public: | ||||||
|     }; |     }; | ||||||
|     void fill_path(Path const&, Color, WindingRule rule = WindingRule::Nonzero); |     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; } |     void set_font(Font const& font) { state().font = &font; } | ||||||
| 
 | 
 | ||||||
|     enum class DrawOp { |     enum class DrawOp { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Hendiadyoin1
						Hendiadyoin1