Skip to content

Class DrawableText ​

Text on one line, or several with wrap, made with Drawable.text.

Extends: Drawable

Drawable.text(spec) takes the same fields by name: the ones below and the shared ones except height. Text is as tall as its lines.

Errors when both top and bottom are set.

A clock centred at the top of an output:

lua
local clock = Drawable.text({
	left = 0, right = 0, top = 8, align = "center",
	text = os.date("%H:%M"), font = { family = "monospace", size = 16 },
})
output.drawables:add(clock)

Properties ​

drawable.text: stringtext ​

What to show.

  • Default: "".
  • A number is turned into a string.
  • Line breaks and tabs show as spaces. Text past 2048 characters is cut.

drawable.font: Fontfont ​

Family, file, size and weight. See Font.

  • Default: {}, 14 px sans-serif at weight 400.
  • Setting it replaces the whole font, so fields left out go back to their defaults.
  • It reads back as a new table. Changing that table changes nothing.

drawable.color: string | Animatedcolor ​

The text colour, "#rrggbb" or "#rrggbbaa". Reads back as an Animated.

  • Default: "#ffffffff", white.

drawable.max_width: integer?max_width ​

Text wider than this is cut with an ellipsis ("…"), or with wrap broken into lines.

  • Default: nil, never cut. false clears it too.
  • 0 to 16384.
  • When even the ellipsis doesn't fit, nothing is shown.

drawable.wrap: booleanwrap ​

With max_width set, breaks longer text into lines instead of cutting it, the same as Text.measure with wrap.

  • Default: false.

drawable.align: "left" | "center" | "right"align ​

Where the text sits in its box, and wrapped lines against each other.

  • Default: "left".
  • The box is width, or the space between left and right.
  • Text wider than its box spills out of it. Set max_width to cut or wrap it.