F TextOrigin.BOTTOM —with this option, the reference coordinate system for the text
starts from the lower left-hand side corner of the bounding box of last line rendering
the descending tail of the most descending letter along the y coordinate as shown in
the previous figure.
By default when you use the Text class, it will render your text in a single line. If you want to
render the text in multiple lines, you have two options:
F New Line Character —The text content can include the new line character ' \n ' to force
the text to explicitly wrap to the next line. When you use this approach, the bounding
box is as wide as the longest text segment.
F wrappingWidth:Number property —the wrappingWidth property allows you
to specify the width of the bounding box for the text. The text will be wrapped at
word boundaries at the specified width as shown in the output for the previous
With the text textAlignment property, you can influence the text flow when the text
is rendered. The next code snippet shows how to center the text within its bounding
box. You can see all alignment options shown in ch02/source-code/src/text/
x:50 y: 25
content: "This is a simple text demo."
"It shows how the text is automatically"
"centered using TextAlignment.CENTER"
The code renders the text as shown:
Other supported alignments include TextAlignment.LEFT , TextAlignment.RIGHT , and