| 48 | } |
| 49 | |
| 50 | FontPtr FontLoader::load( const std::string &name ) |
| 51 | { |
| 52 | FontMap::const_iterator it = m_fonts.find( name ); |
| 53 | if( it!=m_fonts.end() ) |
| 54 | { |
| 55 | return it->second; |
| 56 | } |
| 57 | |
| 58 | boost::filesystem::path path = m_searchPaths.find( name ); |
| 59 | if( path.empty() ) |
| 60 | { |
| 61 | IECore::msg( IECore::Msg::Error, "IECoreGL::FontLoader::load", boost::format( "Couldn't find \"%s\"." ) % name ); |
| 62 | m_fonts[name] = nullptr; // to save us trying over and over again |
| 63 | return nullptr; |
| 64 | } |
| 65 | |
| 66 | IECoreScene::FontPtr coreFont = nullptr; |
| 67 | try |
| 68 | { |
| 69 | coreFont = new IECoreScene::Font( path.string() ); |
| 70 | } |
| 71 | catch( const std::exception &e ) |
| 72 | { |
| 73 | IECore::msg( IECore::Msg::Error, "IECoreGL::Font::load", boost::format( "Failed to load \"%s\" ( %s )." ) % path.string() % e.what() ); |
| 74 | m_fonts[name] = nullptr; // to save us trying over and over again |
| 75 | return nullptr; |
| 76 | } |
| 77 | |
| 78 | FontPtr result = new Font( coreFont ); |
| 79 | m_fonts[name] = result; |
| 80 | |
| 81 | return result; |
| 82 | } |
| 83 | |
| 84 | void FontLoader::clear() |
| 85 | { |