The manner in which the text is plotted is controlled by a set of attributes, the most important of which are size, orientation and alignment. In addition, control over precision, font, aspect ratio and spacing is possible.
The size is specified by means of the routine SGS_SHTX:
The argument HT is the height of the character box, in world coordinates. The size, shape and orientation of characters are defined in world coordinates and are mapped onto the display surface in the same way as lines and markers. Therefore, if the world coordinates are altered without making a corresponding change to the character height the character size on the display surface (in mm) will change.
The orientation is specified by means of the routine SGS_SUPTX:
where XU,YU is a vector specifying the ‘up’ direction. The standard orientation is (0.0,1.0); for text on its side reading upwards an up vector of (-1.0,0.0) could be used; and so on. Only the direction of the vector, not its magnitude, is significant. Remember that this vector is a vector in world coordinates and that if plotting scale is different in X and Y and it is not parallel to either axis, its direction on the display surface will not be the same. Furthermore the character boxes will be transformed from rectangles into parallelograms. There is some advice on plotting text in non-uniform coordinate systems at the end of this section.
The disposition of the plotted string with respect to the reference x,y specified in the SGS_BTEXT call may be controlled using the routine SGS_STXJ:
TXJ is a character string of length 2. The first character of TXJ is B, C, or T, and specifies whether the reference position is to lie on the bottom, centre, or top horizontal of the string. The second character is L, C, or R, and specifies whether the reference position is to lie on the left, centre, or right vertical of the string. Thus a TXJ of ‘BL’ (the default) will cause all strings to be plotted with the given X,Y at the bottom left corner. If ‘CC’ is specified, all strings will be plotted centred on the given positions. (Notes: (1) The SGS_STXJ routine may be called at any time before the string is actually plotted and applies to all strings from then on. (2) The directions bottom, left, etc., refer to the string seen in its conventional orientation.)
The routine SGS_SPREC allows the text precision to be specified:
A precision value of NPR=2 (the default) indicates that no avoidable discrepancy between the characters as defined by the font and as they appear on the display device is tolerable; in effect, software generated characters will be plotted which look the same on all devices. A precision value of 0 allows the use of hardware characters, which will be faster but may compromise appearance especially if more than one device is used.
Different fonts may be selected by means of the routine SGS_SFONT:
where NF is the font number. The default font (number 1) is ordinary Roman letters and Arabic numbers. The GKS User Guide lists the available fonts.
Control of the aspect ratio of the character box is available via the routine SGS_SARTX:
AR is the aspect ratio (width/height). Again the aspect ratio is in world coordinates and will need to be modified if a non-uniform coordinate system is being used.
The routine SGS_SSPTX allows the spacing between characters to be changed:
SP is the distance between one character box and the next as a fraction of the width of the box. The default spacing is 0 which gives no extra space between characters and results in the text being of normal appearance. The spacing can be negative, which results in the characters overlapping.
The aspect ratio and spacing are defined for a ‘nominal’ standard character. The actual values may differ from those set for proportional fonts (the default font is proportional) and for fonts of unusual design. Do not rely on the spacing, orientation and aspect ratio to define the exact length of a text string. The GKS routine GQTXX (inquire text extent) should be used.
The routine SGS_ITXA allows all the above text attributes to be inquired:
If different plotting scales are in use in X and Y, plotting text requires considerable care. Not only must an appropriate height be used but the aspect ratio must also be adjusted and if the direction of the up vector is changed both will need to be altered to maintain the same character size. Futhermore text of normal appearance cannot be plotted with the up vector other than parallel with one of the axes. It is therefore recommended that you use a uniform coordinate system for plotting text and the SGS zone facility provides a convenient way of doing this. A new zone, covering the same area as the current one, can be created by:
The new zone will have a uniform coordinate system (c.f. section 3.1) and is therefore suitable for plotting text. If the text has to be plotted at a particular position X, Y in world coordinates (for example, to label tick marks on an axis) the corresponding position XT, YT in new zone can be obtained by:
where IZ is the zone ID of the original zone.