textsize()

Function group Execute on client Platform(s)
Font handling NO Windows,Linux

Syntax

textsize(string,fontname,pointsize,style,'width','depth')

Description

Returns the width and depth in pixels of the specified text or string.

Note that textsize() is deprecated. Use FontOps.$reptextheight(), FontOps.$reptextwidth(), FontOps.$wintextheight() or FontOps.$wintextwidth() instead.

The string parameter can be a literal string or character variable with a maximum length of 255; fontname is the name of the font; pointsize the point size of the font; style is represented by an integer, that is, 0 = Normal, 1 = Bold, 2 = Italic, 4 = Underline (or a combination of these: 3 would be bold-italic, for example). The width and depth parameters hold the returned values in pixels. The width and depthparameters are integer variables to hold the width and depth values returned; these must be in quotes. The function also returns a value of 0 to indicate the font does not exist or an error occurred, otherwise 1 is returned indicating the text was found.

Example

Calculate lFontStyle as 6 ;; Italic Underline
Calculate lFontName as "Arial"
Calculate lFontSize as 16
If textsize(lString,lFontName,lFontSize,lFontStyle,'lWidth','lDepth')<>0
  ; do something depending on lWidth and lDepth
Else
  ; font didn't exist or error occurred
End If