KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Text alignment and the SVG_New_Text command
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: May 12, 2011

Text allignment when using the SVG_New_textArea is very much like text alignment in any 4D form object. It has a left edge and a right edge. So Align left starts the text at the left edge of the defined rectangle, Align right ends the text at the right edge of the defined rectangle, and center centers the text in the defined rectangle.

However, the 4D SVG command SVG_New_Text does not have a defined rectangle, it simply has attributes for "x" and "y". So how does it handle text alignment? Look at the image below:



Since there are no rectangles, no left edge, no right edge, and no center the SVG_New_text command does all of its text drawing based on the "x" attribute.

The image was created using the code below. Notice that the third argument, the "x" attribute, is the same in all three calls to SVG_New_text. Only the fourth argument, the "y" attribute, and the last arguments, "align" attribute, have been changed.

SVG_New_line ($SVG_T;200;0;200;200;"black";0.5)
SVG_New_text ($SVG_T;"Align Left";200;20;"Lucida Grande,verdana";36;Plain;Align left)
SVG_New_text ($SVG_T;"Center";200;60;"Lucida Grande,verdana";36;Plain;Center)
SVG_New_text ($SVG_T;"Align Right";200;100;"Lucida Grande,verdana";36;Plain;Align right)