Text is the most complex of the GKS primitives because there are so many different variations. The text attributes are described below. Note that only the non-geometric attributes may be set in the text bundle table. ( HINT: For FORTRAN programmers, it is possible to use the Internal Write construct to convert numeric variables to character strings for output as text primitives, see section on Page ).
The text font is specified by an integer font number, and fonts are workstation-dependent. Any text font which is not supported on a given workstation is defaulted to 1. This text font is a simple, roman type font produced by stroking out each character using line segments. To find out which fonts are provided by a particular implementation one should consult the relevant reference manual.
The text precision attribute determines how closely the chosen font has to obey the specifications of the other text attributes. The choices for text precision are: string, char and stroke ('GSTRP', 'GCHARP', 'GSTRKP'). In string precision the text string should be placed as close as possible to the position specified by the primitive call. None of the other text attributes need be taken into account except the approximate size specified by character height. Thus, if string precision is specified, the implementation is usually free to make use of hardware characters which can be drawn much faster than generating the fonts in software. If char precision together with a workstation-provided font is chosen, GKS will try a workstation dependent approximation. In stroke precision GKS has to follow precisely the attribute specifications, and always defaults to font 1 if the requested font does not exist. Note that an implementation of GKS may provide stroke precision text on a particular workstation even if the application specified only a lower precision. Both the text font and the text precision are set by the same routine:
CALL GSTXFP(FONT, PREC)
Figure: Text fonts, precisions and up vectors
The character expansion factor, a real number, causes each character to appear 'fatter' or 'thinner' than normal. The default value is 1.0. The height of the character is not affected, nor is the space between the characters.
CALL GSCHXP(CHXP)
The character spacing attribute defines the amount of extra blank space to be inserted between adjacent characters of a text string. This is a real number defined as a fraction of the character height. The default value is 0.0. A positive character spacing spreads the letters out, a negative one makes the letters overlap.
CALL GSCHSP(CHSP)
The char-up vector defines the orientation of the text. The text is written from left to right along a line perpendicular to the char-up vector, which is specified by its X and Y components (two real numbers):
CALL GSCHUP(CHUX, CHUY)The effect of choosing different combinations of text font, text precision and character-up-vector is shown in .
The text string as a whole is positioned relative to the point specified in the GTX primitive call according to the current setting of the text alignment attribute. The call to GSTXAL has two parameters for horizontal and vertical alignment.
CALL GSTXAL(TXALH, TXALV).The horizontal alignment is either normal, left edge, centre, or the right edge of the text string ('GAHNOR', 'GALEFT', 'GACENT', 'GARITE'). The vertical alignment is either normal, top, cap line, half, base line, or bottom (GAVNOR', 'GATOP', 'GACAP', 'GAHALF', 'GABASE', 'GABOTT'). The alignment attribute is illustrated in . The selection of normal for either horizontal or vertical alignment results in GKS choosing the most appropriate value depending on the current Text Path.
Figure: Text alignment
The text path describes the direction in which the text string is written. The possible values are Right, Left, Up and Down ('GRIGHT', 'GLEFT', 'GUP', ' GDOWN'). The default for the text path is perpendicular to the up vector (i.e. 'GRIGHT').
CALL GSTXP(TXP)
The character height is set in World Coordinates by calling GSCHH. Increasing the height automatically causes a corresponding increase in the width of the character.
CALL GSCHH(CHH)
Note that the use of World Coordinates to specify the character height may
cause problems if the normalization transformation chosen has a very large
or very small range in Y. In this case it is possible that when using a
metafile as an output workstation the number of digits required to
specify the character height may be more than the range used to define
real numbers within the metafile. If it would be inconvenient to modify
the range of World Coordinate Y values, then another possible solution to
the problem is to superimpose two viewports, one on top of the other.
All characters may then be drawn on one of the viewports which has been
defined using a more reasonable normalization transformation.