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 an 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. Starting with Hollywood 9.1, you can also use soft hyphens or zero-width space characters to customize word wrapping but since these are Unicode characters, you need to make sure that you use UTF-8 encoding in that case.

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.

When palette mode is #PALETTEMODE_PEN, this tag can be used to set the pen that should be used for drawing the text. If palette mode is #PALETTEMODE_PEN and Pen is not specified, the pen set using SetDrawPen() will be used instead. (V9.0)

This tag can be used to customize the spacing pixels between lines. It can be set to a positive or a negative value. A negative value moves lines closer together, whereas a positive value increases the spacing between the lines. A value of 0 means no custom line spacing. Defaults to 0. (V10.0)

Allows you to adjust the space between characters. You can set this to a positive or negative value. A positive value will increase the space between characters, a negative value will decrease it. (V10.0)

When drawing text objects using DisplayTextObject() Hollywood will position them in a way that they appear as if they had been drawn using TextOut() which means that they could be offset to the left and top in case parts of some characters are designed to appear in the area of previous characters. This is often the case with characters like "j". If you don't want that, set NoAdjust to True. In that case, calling DisplayTextObject() will never lead to any adjustments in positioning but the text object will strictly be drawn at the specified position. The adjustment offsets applied to a text object by Hollywood in case NoAdjust is False can be found out by querying the #ATTRADJUSTX and #ATTRADJUSTY tags. Defaults to False. (V10.0)

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.

Note that when drawing to a palette-based target and the palette mode is set to #PALETTEMODE_PEN, this function will draw using the pen set via SetDrawPen() instead of the color set via SetFontColor() or the Color tag above.

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