CreateTextObject -- create a text object
[id] = CreateTextObject(id, text$[, table])
This function creates a new text object containing the data specified by text$ and assigns the specified id to it. If you pass Nil in id, CreateTextObject() will automatically choose a vacant identifier and return it. The text is rendered in the current color and with the currently selected font.

The advantage of text objects compared to standard text (output via Print() for example) is that you can easily position text objects on the screen, remove them or even scroll them using MoveTextObject().

Starting with Hollywood 2.5, you can use format tags in the string you pass to CreateTextObject(). Using these tags you can control the font style and color of your text on-the-fly. Format tags always start and end with a square bracket ('['). In case you just want to print a square bracket, you will have to use two square brackets. If there is only one square bracket, Hollywood will always expect a format tag. Please see the chapter about format tags for more information on this topic.

In Hollywood 5.0 the syntax of this function changed slightly. While the old syntax is still supported for compatibility, new scripts should use the new syntax which accepts a table as argument 4. The table can contain the following elements:

Allows you to specify the text's alignment. The following alignments are currently supported:

Left alignment.

Right alignment.

Center lines.

Lay out text in justified lines. (V7.0)

The default value for Align is #LEFT.

CreateTextObject() can do automatic word-wrapping for you if you specify this additional parameter. You can use this tag to specify a maximum width for your text. CreateTextObject() will then use word wrapping to make sure that no text runs beyond this limit. If you do not set this argument or set it to 0 (which is also the default), the text will be as wide as it is required.

This argument can be used to specify the character encoding inside text$. This defaults to the default character encoding for the text library as set by SetDefaultEncoding(). See SetDefaultEncoding for details.

This tag allows you to specify the text color. The color must be provided as an ARGB value. If you do not specify this tag, CreateTextObject() will use the color that was set using the SetFontColor() command instead.

Note that Hollywood currently only supports standard left-to-right based text aligned on horizontal lines. Right to left and vertical text is currently not supported.

identifier of the new text object or Nil for auto id selection
text for the text object
optional: a table containing further options for the text object
optional: identifier of the text object; will only be returned when you pass Nil as argument 1 (see above)
SetFont("times.font", 18)
CreateTextObject(1, "Hello World!")
DisplayTextObject(1, #CENTER, #CENTER)
The above code creates a text object with the font "times" (size 18) and with the color red. The text is "Hello World". After its creation, the text object is displayed in the center of the screen.

Show TOC