GETGTEXTEXTENT

Graphics Function: Returns the width in pixels that would be required to print a given string of text (including any trailing blanks) with OUTGTEXT using the current font.

Module: USE DFLIB

Syntax

result = GETGTEXTEXTENT (text)

text
(Input) Character*(*). Text to be analyzed.

Results:

The result is of type INTEGER(2). The result is the width of text in pixels if successful; otherwise, -1 (for example, if fonts have not been initialized with INITIALIZEFONTS).

This function is useful for determining the size of text that uses proportionally spaced fonts. You must initialize fonts with INITIALIZEFONTS before calling any font-related function, including GETGTEXTEXTENT.

Compatibility

STANDARD GRAPHICS QUICKWIN GRAPHICS LIB

See Also: GETFONTINFO, OUTGTEXT, SETFONT, INITIALIZEFONTS, GETGTEXTROTATION

Example

! Build as QuickWin or Standard Graphics
USE DFLIB
INTEGER(2) status, pwidth
CHARACTER(80) text
status= INITIALIZEFONTS( )
status= SETFONT('t''Arial''h22w10')
pwidth= GETGTEXTEXTENT('How many pixels wide is this?')
WRITE(*,*) pwidth
END