Text Formatting

From Tombstone Engine Wiki
Jump to: navigation, search

Strings displayed by text widgets may contain embedded formatting directives in Tombstone Engine version 2.1 and later. A list of formatting directives begins with the two-character sequence {# and ends with the closing brace }. Each directive has the form directive(params), where params can be empty or consist of one or more parameters that apply to the directive. The following table lists the formatting directives recognized by the text widget.

Directive

Description

size(value)

Set the font size to value in pixels, where value is a floating-point number. This directive is ignored if value is not greater than zero.

scale(value)

Set the text scale to value, where value is a floating-point number. This directive is ignored if value is not greater than zero.

track(value)

Set the text tracking to value in em units, where value is a floating-point number.

kern(value)

Set the kerning state to value, where value is either true or false.

color(red,green,blue,alpha)

Set the text color to (red, green, blue, alpha), where each component is an integer in the range [0, 255]. The alpha component may be omitted, in which case it is 255. This directive is ignored if any component is out of range.

sub(value)

Set the subscript mode to value, where value is either true or false. This directive always sets the superscript mode to $false$.

super(value)

Set the superscript mode to value, where value is either true or false. This directive always sets the subscript mode to $false$.

subscale(value)

Set the subscript scale to value, where value is a floating-point number. This multiplies the scale of normal text when subscript mode is on. This directive is ignored if value is not greater than zero. The default value is 0.75.

subshift(value)

Set the subscript shift to value in em units, where value is a floating-point number. This shifts the text when subscript mode is on relative to the em size of normal text. Positive values are downward, and negative values are upward. The default value is 0.25.

superscale(value)

Set the superscript scale to value, where value is a floating-point number. This multiplies the scale of normal text when superscript mode is on. This directive is ignored if value is not greater than zero. The default value is 0.75.

supershift(value)

Set the superscript shift to value in em units, where value is a floating-point number. This shifts the text when superscript mode is on relative to the em size of normal text. Positive values are downward, and negative values are upward. The default value is −0.5.

reset()

Reset all formatting state to the initial values given by the text widget. This directive always turns subscript and superscript modes off and resets their parameters to the default values.

Examples

The formula for water would be displayed using the following string.

H{#sub(true)}2{#sub(false)}O

Words can be displayed in different colors with the following string.

{#color(255,0,0)}RED {#color(0,255,0)}GREEN {#color(0,0,255)}BLUE

Text can be displayed at different sizes and with different tracking with the following string.

Normal size {#size(30);track(0.2)} Big and wide

See Also