getWidth.lua 871 B

123456789101112131415161718192021222324252627282930313233343536
  1. return {
  2. summary = 'Measure a line of text.',
  3. description = [[
  4. Returns the width and line count of a string when rendered using the font, taking into account
  5. an optional wrap limit.
  6. ]],
  7. arguments = {
  8. {
  9. name = 'text',
  10. type = 'string',
  11. description = 'The text to get the width of.'
  12. },
  13. {
  14. name = 'wrap',
  15. type = 'number',
  16. default = '0',
  17. description = 'The width at which to wrap lines, or 0 for no wrap.'
  18. }
  19. },
  20. returns = {
  21. {
  22. name = 'width',
  23. type = 'number',
  24. description = 'The maximum width of any line in the text.'
  25. },
  26. {
  27. name = 'lines',
  28. type = 'number',
  29. description = 'The number of lines in the wrapped text.'
  30. }
  31. },
  32. notes = [[
  33. To get the correct units returned, make sure the pixel density is set with
  34. `Font:setPixelDensity`.
  35. ]]
  36. }