Mention has already been made of the PLOT routine to print a hardware character on a device. SPROGS also provides a number of character sets made up of vectors. These characters will, of course,respond to expansion and rotation commands.
Unlike other systems, characters are defined as picture files, and can be used in exactly the same way as other files. For example, the letter A is contained in a file called A, and is printed by:
DRAW (ANAME('A'))
After a character has been drawn, the current display position (XPOS, YPOS) is left at the end of the character and the current file number is not reset (that is, the character is defined with FIDF parameter 3.0). A user may redefine any of the basic characters, replacing the body of file A by any orders, and hence replace the character A used in any of the subsequent text handling routines.
To avoid unintentional redefinitions of characters, the user is advised to avoid single character file names for non-character files.
The characters are collected into groups of 64, called fonts. The representative file names refer to the first 64 characters in the SPROGS set (see Appendices). Note that punctuation characters are legal file names. Different fonts will be distinguished by different file numbers, thus:
NUMBR (1.0) DRAW (ANAME ('A' )) NUMBR (2.0) DRAW (ANAME ('A' ))
will output A from fonts 1 and 2. The characters in different fonts may be extensions of previous fonts , or different styles. For example, font 2 is an extension of font 1 including lower case letters, whereas font 3 is a different style of character.
Included with each font are three files which provide suitable control information for laying out the font. File NL gives a newline, file VT gives a backspace, linefeed for vertical text printing, and file BS gives a backspace.
Fonts are initialised by:
GETFNT (XN)
which will set up font number XN.
Thus:
GETFNT (1.0)
will initialise the standard upper case font. Before the font is used, however, the appropriate file number must be set since GETFNT leaves the selected file number as 1.
This routine sets up the appropriate system library on ED channel 11, 12 or 13, and uses GETLIB to read the characters into the file table. However, as mentioned earlier this does not cause the body of the characters to be read in until they are used.
When fonts 1 to 4 are initialised by GETFNT, the three characters @, ↑ and ← are not read into the file table (their places in the library are taken by the three special files mentioned earlier). If these characters are required, they must be read in by:
GETCHA (ANAME('CHAR'),XN)
which will read the character CHAR from font XN.
Thus:
GETCHA (ANAME('@'),4.0)
will retrieve @ from font 4. This routine may be used to read in any character from any font.
Each font will be defined with a basic size suitable to its complexity. It is possible to select suitable sizes by using the EXPAN routine (but see Section 6.7 on scaling of text). Note that, as lineprinter graphical resolution is much worse than SD4020, software characters will appear somewhat strange in small sizes.
To output a large amount of text, the routine:
TEXT (N,'STRING')
is available. This routine normally causes N calls to DRAW, one for each of the N characters in the specified string, together with calls to TEXSW to allow for scaling (see Section 6.7). Normally,all these characters will be taken from the same font, unless shift characters are used (see below). Alternatively, the user can produce his own mixed font by redefining files.
If the user wishes to output text in a vertical column, the routine:
VTEXT (N, 'STRING')
will act in the same way as text, but will DRAW file VT between each character. If he wishes, the user can redefine VT and hence angle text in any way, with the characters remaining upright. (Compare this with using ROTN, when the characters are rotated as well.)
It by In It is possible to specify shift characters which will be interpreted by TEXT,VTEXT as a change in file number, rather than as a DRAW. In this way, characters of different fonts can be mixed.
SHIFTU (XN)
Is a display routine which selects the character whose SPROGS number is XN as the upper shift character. Further use of this character in TEXT,VTEXT will cause the current file number + 1 to be selected. XN less than or equal to 0 will remove any upper shift character. XN may not be a letter, digit, plus sign, minus sign or full stop.
SHIFTD (XM)
similarly, causes the character whose SPROGS number is XM to be taken as select current file number - 1. The same restrictions apply as for SHIFTU. The current file number is not allowed to go below 1. If the same character is chosen for both shifts, only the lower shift is active.
The routine:
NLINES (XN)
will output XN newlines by drawing file NL the specified number of times.
The routine:
NPAGE
will throw to the top of a new page relative to the current region by calling:
ADVFLM UP DRAW (ANAME ('NL'))
Two routines are available to print a number on the current frame.
TYPEN (A,XI,XJ)
will print number A, using the current font and starting at the current position, in a format defined by XI,XJ as follows:
XI = 0.0 E format, field width XJ+7 XJ = 0.0 I format, field width XI+1 XI,XJ not = 0.0 F format, XI places before decimal point, XJ places after. Field width XI+XJ+2.
The format includes a space for positive numbers or a minus sign for negative ones.
VTYPEN (A,XI,XJ)
uses VTEXT instead of TEXT to print the characters, so the number will normally be printed vertically.
The currently available fonts are listed in the Appendices. More will be added later.
Characters in a font are defined on a small rectangular grid, and they can be scaled to the required size by using EXPAN. However, a user wishing to mix text and pictures would find the repeated use of EXPAN tiresome (to cope with the different scales required for the two types). The following display routines have therefore been added:
TEXPAN (EXT,EYT)
selects EXT,EYT as current text expansion factors. However, no expansion will take place unless:
TEXSW (XSW)
is used. If XSW = 2.0, the following scaling takes place for every relative display order that is executed from file.
XPOS' = XPOS + DX*EXT YPOS' = YPOS + DY*EYT
where (XPOS',YPOS') is the new current display position. The display routines affected by this are:
UPDXY UPDX UPDY TODXY TODX TODY
but only when they are executed from a file.
If XSW is not 2.0, no expansion takes place. This is the initial state.
The settings of EXT,EYT and XSW are preserved on entry to a file, and are reset to their previous values on exit.
The routine TEXSW will be called by the high level routines TEXT,VTEXT. Expansion will be switched on before any characters are drawn and switched off at the end of the text string. Users wishing to make use of this scaling when executing other files, or drawing a character file outside TEXT,VTEXT, must call TEXSW themselves.
Two other routines have been provided to assist in choosing the correct scaling factor.
GVCHSZ (DX,DY)
sets DX,DY to the text expansion factors required to make the currently selected font, if DRAWn in the currently selected region, appear the same size as if the base region had been selected and the character DRAWn with the previously selected TEXPAN setting. (In this context, base region refers to the first such region encountered in the region chain.)
Thus:
TEXPAN (0.5,0.5) NUMBR (1.0) GVCHSZ (DX,DY) TEXPAN (DX,DY)
will set the text expansion factors so that subsequent font 1 characters, if the base region is destined for the SD4020, appear half their natural size (see Appendix 7 for natural font sizes: for the SD4020 font 1 characters will occupy 16/1023 of a frame. The above orders will cause characters to appear to occupy 8/1023 of a frame each.).
STCHSZ (DX,DY)
will set the text expansion factors (by calling TEXPAN) so that the current font will appear to be defined on a character grid of DX,DY in the current region units, as opposed to the standard size specified in Appendix 7. This routine DRAWs file VT to ascertain the size of the current font. It is intended for those who know how many characters they wish to fit into the current region.
Example 1.
NUMBR (1.0) TEXPAN (0.5,0.5) SHIFTU (ANAME('[')) SHIFTD (ANAME(']')) TEXT (6,'AB[C]D')
will produce the text string:
ABcD
in characters half the normal size.
Example 2.
If the current region has limits (0,0,10,10), each character in font 1, if unscaled, will more than cover the region by itself.
TEXPAN (EX,EX) with EX = 10*16/1023
w1ll cause the characters to appear in this region as they would in the basic SD4020 region.
Example 3.
The previous example could be done by:
GVCHSZ (DX,DY) TEXPAN (DX,DY)
The user would not need to bother with the actual values of DX and DY.
Example 4.
If a user wishes to fit 30 characters to a line, with current region limits (0,0,10,10), he can use:
STCHSZ (DX,DX) with DX = 10/30