GlyphData.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. class "GlyphData"
  2. function GlyphData:__getvar(name)
  3. if name == "glyphs" then
  4. local retVal = Polycode.GlyphData_get_glyphs(self.__ptr)
  5. if retVal == nil then return nil end
  6. local __c = _G["FT_Glyph"]("__skip_ptr__")
  7. __c.__ptr = retVal
  8. return __c
  9. elseif name == "positions" then
  10. local retVal = Polycode.GlyphData_get_positions(self.__ptr)
  11. if retVal == nil then return nil end
  12. local __c = _G["FT_Vector"]("__skip_ptr__")
  13. __c.__ptr = retVal
  14. return __c
  15. elseif name == "num_glyphs" then
  16. local retVal = Polycode.GlyphData_get_num_glyphs(self.__ptr)
  17. if retVal == nil then return nil end
  18. local __c = _G["FT_UInt"]("__skip_ptr__")
  19. __c.__ptr = retVal
  20. return __c
  21. elseif name == "trailingAdvance" then
  22. return Polycode.GlyphData_get_trailingAdvance(self.__ptr)
  23. end
  24. end
  25. function GlyphData:__setvar(name,value)
  26. if name == "glyphs" then
  27. Polycode.GlyphData_set_glyphs(self.__ptr, value.__ptr)
  28. return true
  29. elseif name == "positions" then
  30. Polycode.GlyphData_set_positions(self.__ptr, value.__ptr)
  31. return true
  32. elseif name == "num_glyphs" then
  33. Polycode.GlyphData_set_num_glyphs(self.__ptr, value.__ptr)
  34. return true
  35. elseif name == "trailingAdvance" then
  36. Polycode.GlyphData_set_trailingAdvance(self.__ptr, value)
  37. return true
  38. end
  39. return false
  40. end
  41. function GlyphData:GlyphData(...)
  42. local arg = {...}
  43. for k,v in pairs(arg) do
  44. if type(v) == "table" then
  45. if v.__ptr ~= nil then
  46. arg[k] = v.__ptr
  47. end
  48. end
  49. end
  50. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  51. self.__ptr = Polycode.GlyphData(unpack(arg))
  52. end
  53. end
  54. function GlyphData:clearData()
  55. local retVal = Polycode.GlyphData_clearData(self.__ptr)
  56. end
  57. function GlyphData:__delete()
  58. if self then Polycode.delete_GlyphData(self.__ptr) end
  59. end