3.9 Text formatting codes

MUI's text engine is very powerful and allows you to include special character codes for on-the-fly text formatting. For example, it is possible to specify text alignment and font style (bold, italics, etc.) using formatting codes. With MUI 3.9 or better it is even possible to embed images (from a Hollywood brush source) in your text objects.

Formatting codes always start with an escape character followed by a sequence of characters that describe the formatting code. In decimal notation the escape character equals ASCII code 27, which is 33 in octal and $1B in hexadecimal notation. Care has to be taken when using formatting codes because usage is different between XML files and Hollywood source files. In XML files the octal notation is used, i.e. you start an escape sequence using a backslash and the octal number 33 ('\33'). In Hollywood source codes, however, octal numbers are not supported after a backslash. Hollywood always expects the ASCII code in decimal notation after a backslash. That is why you have to use '\27' to initiate an escape sequence from Hollywood code.

To illustrate this difference a little bit better, let us have a look at two examples. Here is an example for creating a bold text object in an XML file. Bold text is enabled by using the character 'b' after the escape character:

 
<text id="mytext">\33bBold text</text>

You can see that the octal notation is used here because XML files expect an octal number after a backslash. In Hollywood, however, it is different because Hollywood expects a decimal character after a backslash. So here is how you have to specify escape codes when using them from a Hollywood source file:

 
mui.Set("mytext", "contents", "\27bBold text")

You can see that the code is the same except that we use \27b instead of \33b because Hollywood always uses decimal instead of octal numbers after a backslash.

The following formatting codes are currently supported:

\33u
Set the soft style to underline.

\33b
Set the soft style to bold.

\33i
Set the soft style to italic.

\33n
Set the soft style back to normal.

\33<n>
Use pen number n (2..9) as front pen. n must be a valid DrawInfo pen as specified in intuition/screens.h.

\33P[RRGGBB]
Change front color to the specified RGB color. The RGB color has to be specified in the form of six hexadecimal digits RRGGBB. This is only possible on true colour screens. It also requires at least MUI 3.9.

\33P[AARRGGBB]
Change front color to the specified RGB color and apply alpha blending at the specified intensity. The RGB color has to be specified in the form of six hexadecimal digits RRGGBB which have to be prefaced with two alpha channel digits AA specifying the blending intensity. This is only possible on true colour screens. It also requires at least MUI 3.9. Due to limitations in Picasso96 this does not work with AmigaOS 4 yet (as of AmigaOS 4.1 Update 6).

\33c
Center current (and following) line(s). This sequence is only valid at the beginning of a string or after a newline character.

\33r
Right justify current (and following) line(s). This sequence is only valid at the beginning of a string or after a newline character.

\33l
Left justify current (and following) line(s). This sequence is only valid at the beginning of a string or after a newline character.

\33A[s]
Include the Hollywood brush that uses the identifier <s> in the text object. This feature requires at least MUI 3.9.

\33-
Disable text engine, following chars will be printed without further parsing.

\n
Start a new line. With this character you can e.g. create multi line buttons.

Please note: These formatting codes can be used in all MUI strings, not only in text objects. You can e.g. format the columns of a listview or include images in a cycle gadget's entries.


Show TOC