[id] = CreateTextObject(id, text$[, table])
text$and assigns the specified
idto it. If you pass Nil in
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
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:
The default value for
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.
text$. This defaults to the default character encoding for the text library as set by SetDefaultEncoding(). See SetDefaultEncoding for details.
CreateTextObject()will use the color that was set using the SetFontColor() command instead.
#PALETTEMODE_PEN, this tag can be used to set the pen that should be used for drawing the text. If palette mode is
Penis not specified, the pen set using SetDrawPen() will be used instead. (V9.0)
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
Falsecan be found out by querying the
#ATTRADJUSTYtags. Defaults to
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
#PALETTEMODE_PEN, this function will draw using the pen set via SetDrawPen()
instead of the color set via SetFontColor() or the
SetFontColor(#RED) 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.