mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:32:44 +00:00 
			
		
		
		
	LibGfx: Minor clean-ups in Gfx::FontDatabase
Use Core::DirIterator::next_full_path() instead of manually building each path. Also convert a fprintf(stderr, ...) to warnln()
This commit is contained in:
		
							parent
							
								
									d342e9608c
								
							
						
					
					
						commit
						d996e43df6
					
				
					 1 changed files with 7 additions and 9 deletions
				
			
		|  | @ -31,7 +31,6 @@ | ||||||
| #include <LibGfx/FontDatabase.h> | #include <LibGfx/FontDatabase.h> | ||||||
| #include <LibGfx/Typeface.h> | #include <LibGfx/Typeface.h> | ||||||
| #include <LibTTF/Font.h> | #include <LibTTF/Font.h> | ||||||
| #include <stdio.h> |  | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| 
 | 
 | ||||||
| namespace Gfx { | namespace Gfx { | ||||||
|  | @ -93,22 +92,21 @@ struct FontDatabase::Private { | ||||||
| FontDatabase::FontDatabase() | FontDatabase::FontDatabase() | ||||||
|     : m_private(make<Private>()) |     : m_private(make<Private>()) | ||||||
| { | { | ||||||
|     Core::DirIterator di("/res/fonts", Core::DirIterator::SkipDots); |     Core::DirIterator dir_iterator("/res/fonts", Core::DirIterator::SkipDots); | ||||||
|     if (di.has_error()) { |     if (dir_iterator.has_error()) { | ||||||
|         fprintf(stderr, "DirIterator: %s\n", di.error_string()); |         warnln("DirIterator: {}", dir_iterator.error_string()); | ||||||
|         exit(1); |         exit(1); | ||||||
|     } |     } | ||||||
|     while (di.has_next()) { |     while (dir_iterator.has_next()) { | ||||||
|         String name = di.next_path(); |         auto path = dir_iterator.next_full_path(); | ||||||
| 
 | 
 | ||||||
|         auto path = String::format("/res/fonts/%s", name.characters()); |         if (path.ends_with(".font"sv)) { | ||||||
|         if (name.ends_with(".font")) { |  | ||||||
|             if (auto font = Gfx::BitmapFont::load_from_file(path)) { |             if (auto font = Gfx::BitmapFont::load_from_file(path)) { | ||||||
|                 m_private->full_name_to_font_map.set(font->qualified_name(), font); |                 m_private->full_name_to_font_map.set(font->qualified_name(), font); | ||||||
|                 auto typeface = get_or_create_typeface(font->family(), font->variant()); |                 auto typeface = get_or_create_typeface(font->family(), font->variant()); | ||||||
|                 typeface->add_bitmap_font(font); |                 typeface->add_bitmap_font(font); | ||||||
|             } |             } | ||||||
|         } else if (name.ends_with(".ttf")) { |         } else if (path.ends_with(".ttf"sv)) { | ||||||
|             // FIXME: What about .otf and .woff
 |             // FIXME: What about .otf and .woff
 | ||||||
|             if (auto font = TTF::Font::load_from_file(path)) { |             if (auto font = TTF::Font::load_from_file(path)) { | ||||||
|                 auto typeface = get_or_create_typeface(font->family(), font->variant()); |                 auto typeface = get_or_create_typeface(font->family(), font->variant()); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling