Next: Links, Previous: Labels, Up: Reference for Common Language Elements [Contents]

### 8.2 Text Formatting

Any text displayed in the chart may contain formatting escapes.34 Each formatting escape begins with the backslash ‘`\`’ character. You can also use the backslash to place special characters into the label. Below is the list of escape sequences available.

`\n`

  Inserts a line break.

`\-`

  Switches to small font.

`\+`

  Switches to normal (large) font.

`\^`

  Switches to superscript.

`\_`

  Switches to subscript.

`\b`

  Toggles bold font.

`\B`

  Sets font to bold.

`\i`

  Toggles italics font.

`\I`

  Sets font to italics.

`\u`

  Toggles font underline.

`\U`

  Sets font to underlined.

`\f(font face name)`

  Changes the font face. Available font face names depend on the operating system you use. (See Fonts.) If you specify no font, just `f()`, the font used at the beginning of the label is restored.

`\l(font language code)`

  Changes the language of the font. On Windows it is ignored. On FontConfig-based systems (Linux, Mac) you can use an RFC3066-style language specifier, typically a 2-letter ISO language code, such as ja for Japanese or zh for Chinese. This code is used to select the font file which includes the characters or the given language. (See Fonts.) If you specify no code, just `l()`, the font used at the beginning of the label is restored.

`\0..\9`

  Inserts the specified number of pixels as line spacing below the current line.

`\c(color definition)`

  Changes the color of the text. Color names or direct rgb definitions can both be used, as described in Specifying Colors. No quotation is needed. You can also omit the color and just use `\c()`, which resets the color back to the one at the beginning of the label.

`\s(style name)`

  Applies the specified style to the text35. Naturally only the `text.*` attributes of the style are applied. You can omit the style name and specify only `\s()`, which resets the entire text format to the one at the beginning of the label36. See Styles for more information on styles.

`\S(shape|height|fillcolor)`

  Inserts a shape into the text as a single character. Shapes can be arbitrary forms described by polygons or bezier curves and are defined using the `defshape` command, see Defining Shapes for more information. This escape allows drawing arbitrary things everywhere, where a label is permitted. Within the escape sequence, you first need to specify the name of the shape, then optionally its height (default is the font size) and optionally its fill color (default is transparent fill). The latter option takes effect only for shapes having a fill section, see Defining Shapes. You can omit the height (`\S(shape||fillcolor)`) or the fill color (`\S(shape|height)`) or both (`\S(shape)`).

`\mu(num)`
`\md(num)`
`\ml(num)`
`\mr(num)`
`\mi(num)`

  Change the margin of the text or the inter-line spacing. The second character stands for up, down, left, right and internal, respectively. ‘`num`’ can be any nonnegative integer and is interpreded in pixels. Intra-line spacing comes in addition to the line-specific spacing inserted by `\0..\9`. Defaults are zero. You can also omit the number, which restores that particular value to the one in effect at the beginning of the label, such as `\mu()`. Note that for signalling charts, Msc-generator always adds enough left and right margins to arrow labels to avoid overlapping the label with the arrowhead. Thus if you specify less margin, it may not show as you expect.

`\mn(num)`
`\ms(num)`

  Changes the size of the normal or small font. This applies only to the label, where used, not globally for the entire chart. Defaults are `\mn(16)\ms(10)`. You can also omit the number, which restores that particular value to the one at the beginning of the label.

`\pl \pc \pr`

  Changes the identation to left, centered or right. Applying at the beginning of a line (t.i., before any literal character) will apply new identation to that line and all following lines within the label. Applying after the beginning of a line will only impact subsequent lines.

`\{ \[ \" \; \# \} \]`

  These produce a literal ‘`{`’, ‘`[`’, ‘`"`’, ‘`;`’, ‘`#`’, ‘`}`’ or ‘`]`’, respectively, since these are characters with special meaning and would, otherwise signal the end of a label. The last two can actually be used without the backslash, but result in a warning.

`\$xxxx`

  This escape can be used to insert any unicode character into a label, via its codepoint. Specify the codepoint in hexadecimal using exactly four hex digits. E.g., `\$00A9` will result in the copyright symbol. See more on international characters in International Text Support.

`\|`

  This escape is a non-formatting escape that generates no output. It can be used at the beginning of a label to delimit those formatting escapes that are included in the default formatting restored by the ‘`\s()`’ escape and used to format the label number, from those which are just to be applied at the beginning of the label.

`\N`

  This escape marks the position of the label number within the label. If omitted the number is prepended to the beginning of the label (after the initial formatting escapes). If no number is specified for the label, this escape has no effect. You can specify ‘`\N`’ multiple times, with each occurrence being replaced by the number. Note that if you omit ‘`\N`’, the number inserted at the beginning of the label is augmented by the value of the `numbering.pre` and `numbering.post` options, whereas with the ‘`\N`’ option, those are not used.

`\r(refname)`

  This escape inserts the number of the referenced element. Use the `refname` attribute to name elements. Similar to the ‘`\N`’ escape, the value of the `numbering.pre` and `numbering.post` options are ignored. When no name is given (that is ‘`\r()`’) the escape is equivalent to ‘`\N`’.

`\L(link target)`
`\L()`

  This escape shall be used in pairs to assign a hyperlink to the text in between the two. The target of the link shall be specified in the first escape, whereas the second shall be empty. For example: `a->b: A \L(http://abc.com)link\L() to abc.com.;` The link target cannot contain closing parenthesis. If it contains opening square brackets (`[`), opening curly braces (`{`), semicolons or hash marks, which normally terminates colon labels, use quotation marks around the label, such as `a->b: "A \L(http://abc.com/#x)link\L() to abc.com/\#x.;` Note that tag labels of signalling chart boxes can also contain links. See more in Links below.

`\*`

  In Block Diagrams, adding this to the label of a block, will insert the name of the block there. Using this as a default label (e.g., via `use label="\*";`) makes the label default to the name of the block.

Font size commands (including superscript or subscript) last until the next font size formatting command. For example in order to specify a subscript index, use `label="A\_i\+ value"`.

Any unrecognized escape characters in a label are removed with a warning. Unrecognized escapes and plain text in `text.format` attributes is ignored with a warning.

Note that the `text.*` chart options can be used to set the default text formatting for signalling charts and block diagrams. See Text Formatting Attributes for details.

#### Footnotes

##### (34)

For graphs only labels specified via the double-colon notation interpret escape sequences this way. If you assign a label via the `label=` attribute, the escape sequences will be interpreted as graphviz escape sequences, see http://www.graphviz.org/doc/info/attrs.html#k:escString.

##### (35)

Note that the `\s` formatting escape was used to switch to small font in 1.x versions of Msc-generator (since 2.0 `\-` is used for that). In order to work with old format charts, if the style name is not recognized, Msc-generator will give a warning but fall back to using small font.

##### (36)

Any formatting escapes strictly at the beginning of a label (up to the first non-formatting escape or literal character) are included in the text format, so if you start a label with ‘`\b`’ then ‘`\s()`’ will restore a bold font. To prevent this use the ‘`\|`’ escape to create an invisible non-formatting character.

Next: Links, Previous: Labels, Up: Reference for Common Language Elements [Contents]