FontManager.lua 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. Polycore.__ptr_lookup[self.__ptr] = self
  13. end
  14. end
  15. function FontManager:registerFont(fontName, fontPath)
  16. local retVal = Polycore.FontManager_registerFont(self.__ptr, fontName, fontPath)
  17. end
  18. function FontManager:getFontByName(fontName)
  19. local retVal = Polycore.FontManager_getFontByName(self.__ptr, fontName)
  20. if Polycore.__ptr_lookup[retVal] ~= nil then
  21. return Polycore.__ptr_lookup[retVal]
  22. else
  23. Polycore.__ptr_lookup[retVal] = Font("__skip_ptr__")
  24. Polycore.__ptr_lookup[retVal].__ptr = retVal
  25. return Polycore.__ptr_lookup[retVal]
  26. end
  27. end
  28. function FontManager:__delete()
  29. Polycore.__ptr_lookup[self.__ptr] = nil
  30. Polycore.delete_FontManager(self.__ptr)
  31. end