Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. // Load the font from a file
  2. printf("├─ Loading file from %s..\n│ └─ ", file.c_str());
  3. sf::Font font;
  4. if (font.loadFromFile(file)) {
  5. printf("Success!\n├─ Creating resource..\n");
  6.  
  7. // Begin making the resource inside the shared_ptr
  8. // and place inside the map of resources
  9. fonts_.insert(std::make_pair(file,
  10. std::make_shared<Resource<sf::Font>>
  11. (Resource<sf::Font>(font))));
  12.  
  13. printf("├─ Retrieving font from resource..\n");
  14. found = fonts_.find(file);
  15.  
  16. // If a resource was found
  17. if (found != fonts_.end()) {
  18. printf("└─ Font found!\n");
  19. return found->second->copy();
  20.  
  21.  
  22. // Snippet of my terminal with the output of the program
  23.  
  24. ├─ Loading file from Assets/Fonts/Roboto/Roboto-Regular.ttf..
  25. │ └─ Success!
  26. ├─ Creating resource..
  27. Resource created.
  28. Resource deleted.
  29. ├─ Retrieving font from resource..
  30. └─ Font found!
  31. // Then another resource gets deleted at the end of the program when I expect it to be released
  32.  
  33. // Note that the program acts as expected, with fonts working correctly
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement