You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.0 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include "core.h"
  14. namespace lol
  15. {
  16. /*
  17. * Forge implementation class
  18. */
  19. static class ForgeData
  20. {
  21. friend class Forge;
  22. public:
  23. Dict fonts;
  24. }
  25. forgedata;
  26. static ForgeData * const data = &forgedata;
  27. /*
  28. * Public Forge class
  29. */
  30. int Forge::Register(char const *path)
  31. {
  32. int id = data->fonts.MakeSlot(path);
  33. if (!data->fonts.GetEntity(id))
  34. {
  35. Font *font = new Font(path);
  36. data->fonts.SetEntity(id, font);
  37. }
  38. return id;
  39. }
  40. void Forge::Deregister(int id)
  41. {
  42. data->fonts.RemoveSlot(id);
  43. }
  44. Font *Forge::GetFont(int id)
  45. {
  46. return (Font *)data->fonts.GetEntity(id);
  47. }
  48. } /* namespace lol */