| 22 | } |
| 23 | |
| 24 | std::shared_ptr<const sf::Font> ResourceManager::GetFont( const std::string& path ) { |
| 25 | { |
| 26 | auto font_iter = m_fonts.find( path ); |
| 27 | |
| 28 | if( font_iter != m_fonts.end() ) { |
| 29 | return font_iter->second; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | if( path == "Default" ) { |
| 34 | if( m_use_default_font ) { |
| 35 | #if defined( SFGUI_INCLUDE_FONT ) |
| 36 | auto font = std::make_shared<sf::Font>( LoadDejaVuSansFont() ); |
| 37 | #else |
| 38 | #if defined( SFGUI_DEBUG ) |
| 39 | std::cerr << "SFGUI warning: No default font available. (SFGUI_INCLUDE_FONT = FALSE)\n"; |
| 40 | #endif |
| 41 | auto font = std::make_shared<sf::Font>(); |
| 42 | #endif |
| 43 | m_fonts[path] = font; |
| 44 | |
| 45 | return font; |
| 46 | } |
| 47 | |
| 48 | return std::shared_ptr<const sf::Font>(); |
| 49 | } |
| 50 | |
| 51 | // Try to load. |
| 52 | auto loader = GetMatchingLoader( path ); |
| 53 | |
| 54 | if( !loader ) { |
| 55 | auto font = GetFont( "Default" ); |
| 56 | #if defined( SFGUI_DEBUG ) |
| 57 | std::cerr << "SFGUI warning: Couldn't find a loader for the font \"" << path << "\".\n"; |
| 58 | #endif |
| 59 | m_fonts[path] = font; |
| 60 | return font; |
| 61 | } |
| 62 | |
| 63 | auto font = loader->LoadFont( GetFilename( path, *loader ) ); |
| 64 | |
| 65 | if( !font ) { |
| 66 | font = GetFont( "Default" ); |
| 67 | #if defined( SFGUI_DEBUG ) |
| 68 | std::cerr << "SFGUI warning: Couldn't load the font \"" << path << "\".\n"; |
| 69 | #endif |
| 70 | m_fonts[path] = font; |
| 71 | return font; |
| 72 | } |
| 73 | |
| 74 | // Cache. |
| 75 | m_fonts[path] = font; |
| 76 | return font; |
| 77 | } |
| 78 | |
| 79 | std::shared_ptr<const sf::Image> ResourceManager::GetImage( const std::string& path ) { |
| 80 | auto image_iter = m_images.find( path ); |
no test coverage detected