Font.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. class "Font"
  2. function Font:__index__(name)
  3. if name == "loaded" then
  4. return Polycore.Font_get_loaded(self.__ptr)
  5. end
  6. end
  7. function Font:__set_callback(name,value)
  8. if name == "loaded" then
  9. Polycore.Font_set_loaded(self.__ptr, value)
  10. return true
  11. end
  12. return false
  13. end
  14. function Font:Font(...)
  15. for k,v in pairs(arg) do
  16. if type(v) == "table" then
  17. if v.__ptr ~= nil then
  18. arg[k] = v.__ptr
  19. end
  20. end
  21. end
  22. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  23. self.__ptr = Polycore.Font(unpack(arg))
  24. Polycore.__ptr_lookup[self.__ptr] = self
  25. end
  26. end
  27. function Font:getFace()
  28. local retVal = Polycore.Font_getFace(self.__ptr)
  29. if retVal == nil then return nil end
  30. if Polycore.__ptr_lookup[retVal] ~= nil then
  31. return Polycore.__ptr_lookup[retVal]
  32. else
  33. Polycore.__ptr_lookup[retVal] = FT_Face("__skip_ptr__")
  34. Polycore.__ptr_lookup[retVal].__ptr = retVal
  35. return Polycore.__ptr_lookup[retVal]
  36. end
  37. end
  38. function Font:isValid()
  39. local retVal = Polycore.Font_isValid(self.__ptr)
  40. return retVal
  41. end
  42. function Font:__delete()
  43. Polycore.__ptr_lookup[self.__ptr] = nil
  44. Polycore.delete_Font(self.__ptr)
  45. end