The W$TEXTSIZE routine allows you to measure the height and width of a string of text in a particular font.
CALL "W$TEXTSIZE" USING TEXT-STRING, TEXTSIZE-DATA
TEXT-STRING PIC X(n) | Contains the string to be measured |
TEXTSIZE-DATA PIC X(n) | The TEXTSIZE-DATA data item is found in the COPY file
acugui.def. It is defined as follows:
01 TEXTSIZE-DATA. 03 TEXTSIZE-FONT HANDLE OF FONT. 03 TEXTSIZE-WINDOW HANDLE OF WINDOW. 03 TEXTSIZE-SIZE-X PIC 9(7)V99 COMP-4. 03 TEXTSIZE-CELLS-X PIC 9(7)V99 COMP-4. 03 TEXTSIZE-BASE-X PIC 9(9) COMP-4. 03 TEXTSIZE-SIZE-Y PIC 99V99 COMP-4. 03 TEXTSIZE-CELLS-Y PIC 99V99 COMP-4. 03 TEXTSIZE-BASE-Y PIC 9(4) COMP-4. 03 TEXTSIZE-FLAGS PIC X COMP-X. 88 TEXTSIZE-STRIP-SPACES VALUE 1, FALSE ZERO. |
The W$TEXTSIZE routine measures the average height and width of TEXT-STRING according to the parameters found in TEXTSIZE-DATA and returns the results in TEXTSIZE-DATA. The measurement is returned using a variety of units.
The data elements in TEXTSIZE-DATA are used as follows:
TEXTSIZE-FONT (HANDLE OF FONT) | This item holds the handle of the font that you want the runtime to measure. If the value is NULL, DEFAULT-FONT is used. TEXTSIZE-FONT is initialized to NULL in acugui.def. |
TEXTSIZE-WINDOW (HANDLE OF WINDOW) | This item holds the handle of the window that you want to use when measuring the number of window cells the text occupies (see TEXTSIZE-CELLS-X and TEXTSIZE-CELLS-Y below). If this value is NULL, the current window is used. If there is no current window, the cells\ measurement is returned with the value zero. TEXTSIZE-WINDOW is initialized to NULL in acugui.def. |
TEXTSIZE-FLAGS (PIC X COMP-X) | If TEXTSIZE-STRIP-SPACES is true, W$TEXTSIZE does not include any trailing spaces in the measurement of TEXTSTRING. Otherwise, trailing spaces are included in the measurement. TEXTSIZE-FLAGS is initialized to NULL in acugui.def. |
TEXTSIZE-SIZE-X (PIC 9(7)V99 COMP-4) | Returns the width of the text in label size units. This is the SIZE value required for a label to exactly contain the text. It is computed by dividing the length of the text by the size of the font's 0 character. For fixed-pitch fonts, the value returned is the same as the number of characters in TEXT-STRING. |
TEXTSIZE-SIZE-Y (PIC 99V99 COMP-4) | Returns the height of the text in label size units. This is the LINES value required for a label to exactly contain the text. By definition, this value is always 1. |
TEXTSIZE-CELLS-X (PIC 9(7)V99 COMP-4) | Returns the width of the text in window cells. It is computed by dividing the width of the text by the width of a window cell. |
TEXTSIZE-CELLS-Y (PIC 99V99 COMP-4) | Returns the height of the text in window cells. It is computed by dividing the height of the text by the height of a window cell. |
TEXTSIZE-BASE-X (PIC 9(9) COMP-4) | Returns the width of the text in base units. On a graphical system, a base unit is a pixel. On a character-based system, a base unit is a character cell. |
TEXTSIZE-BASE-Y (PIC 9(4) COMP-4) | Returns the height of the text in base units. On a graphical system, a base unit is a pixel. On a character-based system, a base unit is a character cell. |