Text Formatting Codes

From Derivative
Jump to navigation Jump to search

This page outlines formatting codes that can be used inside the text in the Text COMP or Geo Text COMP to apply formatting such as colors, underlines, strikeouts or subscript to portions of the text. It is based on the Slug Library.

To use formatting codes, turn on the 'Enable Formatting Codes' parameter in the component.

The codes are written into the text, but are processed by the component and do not display in the final output. Code sections begin with a curly brace and hashtag {# and end with a closing curly brace }. Codes are written like functions with the name first followed by arguments inside brackets e.g. color(r, g, b) or strike(true). Multiple codes can be written in one section using a semicolon ; to separate them e.g. {#color(255,0,0);script(2)}.

When editing in the Text COMP, the formatting codes will be displayed in raw format while editing and then processed as codes when editing is complete. For multiline text in the Text COMP, formatting only applies to the current paragraph (as marked by a new line character) and resets to the default for the next paragraph. Changes to the font size or line spacing only affect wrapped lines after the line they appear on.

Examples

This word is {#color(255,0,0)}red
You can also {#under(true)}underline{#reset()} or {#strike(true)}strikeout{#reset()} individual words.

Codes

stretch(value) - Set the text stretch to value, where value is a floating-point number. 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.

skew(value) - Set the text skew to value, where value is a floating-point number. Positive values skew to the right, and negative values skew to the left.

scale(x, y) - Set the text scale to (x, y), where x and y are floating-point numbers. The y component may be omitted, in which case it is set equal to the x component. Ignored if either x or y is not greater than zero.

under(value) - Set the underline decoration state to value, where value is either true or false. Ignored if the font does not contain underline information.

strike(value) - Set the strikethrough decoration state to value, where value is either true or false. Ignored if the font does not contain strikethrough information.

script(value) - Set the transform-based script state to value, where value is an integer in the range [−3, 3]. If value is 0, then the text scale and text offset states are set to the identity transform. If value is positive, then the superscript scale and offset are applied value times. If value is negative, then the subscript scale and offset are applied value times. Ignored if value is out of range or the font does not contain transform-based script information.

color(red,green,blue) - Set the primary text color to (red, green, blue, 255), where each component is an integer in the range [0, 255]. The red, green, and blue components are specified in the sRGB color space. Ignored if any component is out of range.

color(red,green,blue,alpha) - Same as above, but also sets the alpha value.

color2(red,green,blue) - Set the secondary text color to (red, green, blue, 255) using the same format as the primary color. The secondary text color is used only when gradients are enabled.

color2(red,green,blue,alpha) - Same as above, but also sets the alpha value.

grad(value) - Set the gradient state to value, where value is either true or false.

reset() - Reset all formatting states to their initial values.