FontManager.lua 1002 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 retVal == nil then return nil end
  21. if Polycore.__ptr_lookup[retVal] ~= nil then
  22. return Polycore.__ptr_lookup[retVal]
  23. else
  24. Polycore.__ptr_lookup[retVal] = Font("__skip_ptr__")
  25. Polycore.__ptr_lookup[retVal].__ptr = retVal
  26. return Polycore.__ptr_lookup[retVal]
  27. end
  28. end
  29. function FontManager:__delete()
  30. Polycore.__ptr_lookup[self.__ptr] = nil
  31. Polycore.delete_FontManager(self.__ptr)
  32. end