text.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. return {
  2. tag = 'drawing',
  3. summary = 'Draw text.',
  4. description = [[
  5. Draws text. The font can be changed using `Pass:setFont`.
  6. ]],
  7. arguments = {
  8. text = {
  9. type = 'string',
  10. description = 'The text to render.'
  11. },
  12. colortext = {
  13. type = 'table',
  14. description = [[
  15. A table of strings with colors to render, in the form
  16. `{ color1, string1, color2, string2 }`, where color is a `Vec3`, `Vec4`, hexcode, or table
  17. of numbers.
  18. ]]
  19. },
  20. x = {
  21. type = 'number',
  22. default = '0',
  23. description = 'The x coordinate of the text origin.'
  24. },
  25. y = {
  26. type = 'number',
  27. default = '0',
  28. description = 'The y coordinate of the text origin.'
  29. },
  30. z = {
  31. type = 'number',
  32. default = '0',
  33. description = 'The z coordinate of the text origin.'
  34. },
  35. scale = {
  36. type = 'number',
  37. default = '1',
  38. description = 'The scale of the text (with the default pixel density, units are meters).'
  39. },
  40. angle = {
  41. type = 'number',
  42. default = '0',
  43. description = 'The rotation of the text around its rotation axis, in radians.'
  44. },
  45. ax = {
  46. type = 'number',
  47. default = '0',
  48. description = 'The x component of the axis of rotation.'
  49. },
  50. ay = {
  51. type = 'number',
  52. default = '1',
  53. description = 'The y component of the axis of rotation.'
  54. },
  55. az = {
  56. type = 'number',
  57. default = '0',
  58. description = 'The z component of the axis of rotation.'
  59. },
  60. position = {
  61. type = 'Vec3',
  62. description = 'The position of the text.'
  63. },
  64. orientation = {
  65. type = 'Quat',
  66. description = 'The orientation of the text.'
  67. },
  68. transform = {
  69. type = 'Mat4',
  70. description = 'The transform of the text.'
  71. },
  72. wrap = {
  73. type = 'number',
  74. default = '0',
  75. description = [[
  76. The maximum width of each line in meters (before scale is applied). When zero, the text
  77. will not wrap.
  78. ]]
  79. },
  80. halign = {
  81. type = 'HorizontalAlign',
  82. default = [['center']],
  83. description = 'The horizontal alignment relative to the text origin.'
  84. },
  85. valign = {
  86. type = 'VerticalAlign',
  87. default = [['middle']],
  88. description = 'The vertical alignment relative to the text origin.'
  89. }
  90. },
  91. returns = {},
  92. variants = {
  93. {
  94. arguments = { 'text', 'x', 'y', 'z', 'scale', 'angle', 'ax', 'ay', 'az', 'wrap', 'halign', 'valign' },
  95. returns = {}
  96. },
  97. {
  98. arguments = { 'text', 'position', 'scale', 'orientation', 'wrap', 'halign', 'valign' },
  99. returns = {}
  100. },
  101. {
  102. arguments = { 'text', 'transform', 'wrap', 'halign', 'valign' },
  103. returns = {}
  104. },
  105. {
  106. description = 'Renders multicolor text.',
  107. arguments = { 'colortext', 'x', 'y', 'z', 'scale', 'angle', 'ax', 'ay', 'az', 'wrap', 'halign', 'valign' },
  108. returns = {}
  109. },
  110. {
  111. description = 'Renders multicolor text.',
  112. arguments = { 'colortext', 'position', 'scale', 'orientation', 'wrap', 'halign', 'valign' },
  113. returns = {}
  114. },
  115. {
  116. description = 'Renders multicolor text.',
  117. arguments = { 'colortext', 'transform', 'wrap', 'halign', 'valign' },
  118. returns = {}
  119. }
  120. },
  121. notes = [[
  122. UTF-8 encoded strings are supported.
  123. Newlines will start a new line of text. Tabs will be rendered as four spaces. Carriage returns
  124. are ignored.
  125. With the default font pixel density, a scale of 1.0 makes the text height 1 meter.
  126. The wrap value does not take into account the text's scale.
  127. Text rendering requires a special shader, which will only be automatically used when the active
  128. shader is set to `nil`.
  129. Blending should be enabled when rendering text (it's on by default).
  130. This function can draw up to 16384 visible characters at a time, and will currently throw an
  131. error if the string is too long.
  132. ]],
  133. related = {
  134. 'Pass:setFont',
  135. 'lovr.graphics.getDefaultFont',
  136. 'Pass:setShader',
  137. 'Font:getWidth',
  138. 'Font:getHeight',
  139. 'Font:getLines',
  140. 'Font:getVertices',
  141. 'Font'
  142. }
  143. }