mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:12:43 +00:00 
			
		
		
		
	LibGfx+LibGUI+Clients: Make fonts findable by their qualified name
The qualified name of a font is "<Family> <Size> <Weight>". You can get the QN of a Font via the Font::qualified_name() API, and you can get any system font by QN from the GUI::FontDatabase. :^)
This commit is contained in:
		
							parent
							
								
									260b52215c
								
							
						
					
					
						commit
						9d347352a1
					
				
					 8 changed files with 57 additions and 61 deletions
				
			
		|  | @ -33,30 +33,20 @@ | |||
| 
 | ||||
| namespace GUI { | ||||
| 
 | ||||
| struct Metadata { | ||||
|     String path; | ||||
|     bool is_fixed_width; | ||||
|     int glyph_height; | ||||
| }; | ||||
| 
 | ||||
| class FontDatabase { | ||||
| public: | ||||
|     static FontDatabase& the(); | ||||
| 
 | ||||
|     RefPtr<Gfx::Font> get_by_name(const StringView&); | ||||
|     void for_each_font(Function<void(const StringView&)>); | ||||
|     void for_each_fixed_width_font(Function<void(const StringView&)>); | ||||
| 
 | ||||
|     Optional<Metadata> get_metadata_by_name(const StringView& name) const | ||||
|     { | ||||
|         return m_name_to_metadata.get(name); | ||||
|     } | ||||
|     void for_each_font(Function<void(const Gfx::Font&)>); | ||||
|     void for_each_fixed_width_font(Function<void(const Gfx::Font&)>); | ||||
| 
 | ||||
| private: | ||||
|     FontDatabase(); | ||||
|     ~FontDatabase(); | ||||
| 
 | ||||
|     HashMap<String, Metadata> m_name_to_metadata; | ||||
|     struct Private; | ||||
|     OwnPtr<Private> m_private; | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling