Text Mapping Node
- Last UpdatedMar 24, 2025
- 3 minute read
Text mapping exchanges specific characters or strings in text items. For example, adjust them to different mapping of character in fonts, exchange special characters not handled properly by a specific browser or even switch the language.
'text' attributes:
-
regEx: If set to true, then values for "from" and "font" should be specified in Regular Expression format.
-
font: The input font of the character or string to be changed. This can be used to select only the string values that are defined in a specific input font. If the font name is specified in RegEx format, then specifying a value ".*" will affect all graphical text labels with any font. If "regEx" is set to "false", specify "*" character to cover text items of any font.
-
from: The input character or string to change.
-
to: Replacement character or string to be used in the output SVG.
Note: In "from" and "to" values, the character can be specified in Unicode format as below: "&#<code>; "
Example code: "±"
The output SVG would replace the input character with the plus-or-minus sign "±".
In the <texts> node, the following mappings are processed:
-
Characters in the ANSI_SYMBOLS font will be searched for the character '1' which will be replaced with the unicode character ="#177", used to represent the ' ± ' sign.
-
The "%" characters in any font or with no font will be converted to "^".
-
All instances of the string "colour" in any font will be converted to "colour".
Multiple text mappings are applied in order to each text item that matches the mapping, even when that text has been updated by a previous mapping. For example, if an input text is "1024 colours", then the above mapping would result in an output text "1 kilo colours" as the third text mapping matches to "colour" and changes the text to "1024 colours", the fourth mapping then changes that to "0x400 colours" and the fifth mapping changes that to "1 kilo colours".
Note: To properly map SHX fonts, you need to include the 'shx' extension in the font name. If an extension is not provided, the Gateway assumes it is a TTF font. Mapping SHX to SHX or SHX to TTF is allowed. TTF to SHX mapping is not supported.
Examples:
<font from="simplex.shx" to="complex.shx"/> (SHX to SHX mapping)
<font from="simplex.shx" to="Arial"/> (SHX to TTF mapping)
Use regular expression, for example:
<font from=".*.shx" to="Times New Roman" regEx="true" />
Text mapping is not applied to the text if it is using SHX font because it is vectorized directly to graphics and cannot be modified in this form. To use Text mappings on SHX fonts, ensure they are first mapped to a TTF font.
Be sure that the Gateway has access to all required SHX fonts defined in the drawing and in the configuration, noting that if SHX to SHX font mapping is used then only the target SHX font is required. They must exist in one of the Font and Support Folders, see Extract Settings for more details regarding setting the locations of fonts.
Mapping of SHX fonts does not support 'sizeFactor', 'italic' nor 'bold'.