FontManager.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #pragma once
  23. #include "ResourceManager.h"
  24. #include "Font.h"
  25. namespace crown
  26. {
  27. /**
  28. * Manages font loading.
  29. */
  30. class FontManager : public ResourceManager
  31. {
  32. public:
  33. FontManager();
  34. /**
  35. * Creates a font resource with the given name.
  36. * If a resource with the same name already exists, the
  37. * already existent resource will be returned.
  38. * @param name The name of the resource
  39. * @return A point32_ter to the created resource
  40. */
  41. Font* Create(const char* name, bool& created);
  42. /**
  43. * Loads a font resource from file.
  44. * @note Generally, the name of the file determines the name of the resource and vice-versa.
  45. * Here is not the case, since from a single TrueType file, multiple fonts
  46. * can be generated (e.g. You may want to generate various character
  47. * sizes from a single .ttf).
  48. * @param name Tha name of the resource
  49. * @param filename The name of the file containing the resource
  50. * @param ttSize The size of characters in pixels
  51. * @param ttResolution The resolution of characters in DPI (Dots Per Inch)
  52. * @return A point32_ter to the loaded resource
  53. */
  54. Font* Load(const char* name);
  55. virtual Font* CreateSpecific(const char* name);
  56. private:
  57. // Disable copying
  58. FontManager(const FontManager&);
  59. FontManager& operator=(const FontManager&);
  60. };
  61. FontManager* GetFontManager();
  62. } // namespace crown