MCPcopy Create free account
hub / github.com/ImageEngine/cortex / load

Method load

src/IECoreGL/FontLoader.cpp:50–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50FontPtr 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
84void FontLoader::clear()
85{

Callers 2

testMethod · 0.95

Calls 3

whatMethod · 0.80
findMethod · 0.45
endMethod · 0.45

Tested by 1

testMethod · 0.76