[id] = CreateTextObject(id, text$[, table])
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:
Align:
#LEFT
#RIGHT
#CENTER
#JUSTIFIED
The default value for Align
is #LEFT
.
WordWrap:
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.
Encoding:
text$
. This defaults to the default character encoding
for the text library as set by SetDefaultEncoding().
See SetDefaultEncoding for details.
Color:
CreateTextObject()
will use the color that was set using the
SetFontColor() command instead.
Pen:
#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)
Linespacing:
Charspacing:
NoAdjust:
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.
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.