GlyphData.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. class "GlyphData"
  2. function GlyphData:__getvar(name)
  3. if name == "glyphs" then
  4. local retVal = Polycore.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 = Polycore.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 = Polycore.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 Polycore.GlyphData_get_trailingAdvance(self.__ptr)
  23. end
  24. end
  25. function GlyphData:__setvar(name,value)
  26. if name == "num_glyphs" then
  27. Polycore.GlyphData_set_num_glyphs(self.__ptr, value.__ptr)
  28. return true
  29. elseif name == "trailingAdvance" then
  30. Polycore.GlyphData_set_trailingAdvance(self.__ptr, value)
  31. return true
  32. end
  33. return false
  34. end
  35. function GlyphData:GlyphData(...)
  36. local arg = {...}
  37. for k,v in pairs(arg) do
  38. if type(v) == "table" then
  39. if v.__ptr ~= nil then
  40. arg[k] = v.__ptr
  41. end
  42. end
  43. end
  44. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  45. self.__ptr = Polycore.GlyphData(unpack(arg))
  46. end
  47. end
  48. function GlyphData:clearData()
  49. local retVal = Polycore.GlyphData_clearData(self.__ptr)
  50. end
  51. function GlyphData:__delete()
  52. if self then Polycore.delete_GlyphData(self.__ptr) end
  53. end