Stylesheet Development with PTC ALD > Adding PTC ALD Code to Stylesheet Source > Samples > PTC ALD Properties > Set PTC ALD Text Properties > Character Properties
  
Character Properties
Rotate, Flip, and Mirror
The sample listed here describes how to rotate characters in a piece of inline text.
Inline text is tagged as emphasis in Arbortext-path/samples/APP/TextProperties/textProperties.xml. Each piece of inline text in the paragraphs in the Rotation, flip, and mirror section has a role attribute set. The attribute can have a value of rotate 1, rotate 2, rotate 3, flip, or mirror. Each value references a different property set, which each contain PTC ALD source code edits that rotate the characters in the text in a particular way.
Property sets rotate 1, rotate 2, rotate 3 — rotate the characters in the text by 90, 180, or 270 degrees, respectively.
Use the rotate property of the fStyle object that provides text styling for the current element. Give it a value of 1, 2, or 3 to provide the required number of degrees. The values each correspond to a constant in the CharacterRotation group for fStyle.
For example:
style.rotate= 2;
Use this phrase to add a rotation of 180 degrees. A value of 2 corresponds to fStyle.ROTATE_180.
Property set flip — flip the characters vertically within their outline
Use the flip property of the fStyle object that provides text styling for the current element. Give it a value of true to invoke a flip action:
style.flip= true;
Property set mirror — mirror the characters horizontally
Use the mirror property of the fStyle object that provides text styling for the current element. Give it a value of true to invoke a mirror action:
style.mirror= true;
Vertical Alignment
The sample listed here describes how to position characters in a piece of inline text vertically on their line.
Inline text is tagged as emphasis in Arbortext-path/samples/APP/TextProperties/textProperties.xml. The first pieces of inline text in the paragraphs in the Vertical position section have a role attribute set. The attribute can have a value of vertical 1, vertical 2, vertical 3, or vertical 4. Each value references a different property set, which each contain PTC ALD source code edits that rotate the characters in the text in a particular way.
Property set vertical 1 — center the characters on the line
Use the verticalFormat property of the fStyle object that provides text styling for the current element. Give it a value to align characters vertically on their line in a certain way. The values of verticalFormat each correspond to a constant in the CharacterVerticalFormat group for fStyle.
For example:
style.verticalFormat = 1;
Use this phrase to center characters vertically. A value of 1 corresponds to fStyle.VERTICALFORMAT_CENTER.
Property set vertical 2 — top align the characters on the line
Use the verticalFormat property of the current fStyle object . Give it a value of 2 to top align the characters on their line:
style.verticalFormat = 2;
Property set vertical 3 — align the characters at the bottom of the line
Use the verticalFormat property of the current fStyle object. Give it a value of 3 to align the bottom part of each character at the lowest point of the line:
style.verticalFormat = 3;
Property set vertical 4 — align the bottom part of each character on the current baseline
Use the verticalFormat property of the current fStyle object . Give it a value of 4 to center the characters on their line:
style.verticalFormat = 4;
Vertical Offset
The samples listed here describes how to set vertical offset for text characters.
Inline text is tagged as emphasis in Arbortext-path/samples/APP/TextProperties/textProperties.xml. The later pieces of inline text in the paragraphs in the Vertical position section have a role attribute set. The attribute can have a value of up 1, up 2, up 3, up 4, down 1, down 2, down 3, or down 4. Each value references a different property set, which each contain PTC ALD source code edits that offset the characters in the text from the baseline by a specified amount.
Property sets up 1, up 2, up 3, up 4, and up 5— each move the text vertically upwards from its baseline by a specified amount.
Use the baselineShift property of the fStyle object that provides text styling for the current element. This property references an fLength datatype object. Provide the required length as a negative measure to move the text up from the baseline.
For example:
style.baselineShift = "-6pt";
This phrase will offset the text 6pt above the baseline.
Property sets down 1, down 2, down 3, down 4, and down 5— each move the text vertically downwards from its baseline by a specified amount.
Use the baselineShift property of the current fStyle object, as described above. Provide the required length as a positive measure to move the text down from the baseline.
For example:
style.baselineShift = "10pt";
This phrase will offset the text 10pt below the baseline.
Character Width
The samples listed here describes how to control the width of text characters.
Inline text is tagged as emphasis in Arbortext-path/samples/APP/TextProperties/textProperties.xml. The inline text in the paragraphs in the Character width section have a role attribute set. The attribute can have a value of width 1, width 2, width 3, or width 4. Each value references a different property set, which each contain PTC ALD source code edits that provide settings for the width of text characters in inline text.
Some interesting options are included:
Specify fixed width for all characters
style.fixedWidth = true;
Use the fixedWidth property of the fStyle object that provides text styling for the current element. Give it a value of true to activate the property and specify that the width of all characters is fixed to a specified measure.
Note that if you set this property to true, you must also provide a value for the characterWidth property for the style, to provide the required measure.
Refer to property set width 1.
Set character width to a specific value
style.characterWidth = "3mm";
Use the characterWidth property of the current fStyle object, as described above. The property references an fLength datatype object. Include a measure plus measurement unit to provide an explicit width to which character width should be fixed.
Refer to property set width 1.
Set character width to the width of a selected character
style.characterWidth = new fLength( '#"m"' ).makeAbsolute();
The first part of the phrase style.characterWidth specifies that you want to set the value of the characterWidth property of the current fStyle object, as described above.
The second part = new fLength( '#"m"' ).makeAbsolute(); uses the fLength() method of the fLength object to create a new fLength object that defines the width. The '#"m"' statement specifies that the measure to be used is the current measure for the character m. The makeAbsolute() method for the fLength object is also included to reference the extracted length as an absolute value.
Refer to property set width 4.
Align characters inside their own box
style.widthFormat = fStyle.WIDTHFORMAT_CENTER;
The first part of the phrase style.widthFormat specifies that you want to set the value of the widthFormat property of the current fStyle object, as described above.
The second part = fStyle.WIDTHFORMAT_CENTER calls the WIDTHFORMAT_CENTER constant of the fStyle object to center the characters in its character box.
Note that WIDTHFORMAT_CENTER is described in the CharacterWidthFormat group of constants for an fStyle object.
Refer to property set width 4.