FontManager.lua 801 B

123456789101112131415161718192021222324252627282930313233343536
  1. class "FontManager"
  2. function FontManager:FontManager(...)
  3. for k,v in pairs(arg) do
  4. if type(v) == "table" then
  5. if v.__ptr ~= nil then
  6. arg[k] = v.__ptr
  7. end
  8. end
  9. end
  10. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  11. self.__ptr = Polycore.FontManager(unpack(arg))
  12. end
  13. end
  14. function FontManager:registerFont(fontName, fontPath)
  15. local retVal = Polycore.FontManager_registerFont(self.__ptr, fontName, fontPath)
  16. end
  17. function FontManager:getFontByName(fontName)
  18. local retVal = Polycore.FontManager_getFontByName(self.__ptr, fontName)
  19. if Polycore.__ptr_lookup[retVal] ~= nil then
  20. return Polycore.__ptr_lookup[retVal]
  21. else
  22. Polycore.__ptr_lookup[retVal] = Font("__skip_ptr__")
  23. Polycore.__ptr_lookup[retVal].__ptr = retVal
  24. return Polycore.__ptr_lookup[retVal]
  25. end
  26. end