<<prev file | next file >>    view single page | view frames    summary: fields | routine    details: routine

ToBeReviewed/STRING/

str_size.pro

The purpose of this function is to return the proper character size to make a specified string a specifed width in a window. The width is specified in normalized coordinates. The function is extremely useful for sizing strings and labels in resizeable graphics windows.

topSTR_SIZE Graphics Programs, Widgets.

result = STR_SIZE(string[, targetWidth], INITSIZE=INITSIZE, STEP=STEP)

Return value

thisCharSize. This is the size the specified string should be set to if you want to produce output of the specified target width. The value is in standard character size units where 1.0 is the standard character size.

Parameters

string        in required

This is the string that you want to make a specifed target size or width.

targetWidth        in optional

This is the target width of the string in normalized coordinates in the current graphics window. The character size of the string (returned as thisCharSize) will be calculated to get the string width as close as possible to the target width. The default is 0.25.

Keywords

INITSIZE       

This is the initial size of the string. Default is 1.0.

STEP       

This is the amount the string size will change in each step of the interative process of calculating the string size. The default value is 0.05.

Examples

To make the string "Happy Holidays" take up 30% of the width of the current graphics window, type this: XYOUTS, 0.5, 0.5, ALIGN=0.5, "Happy Holidays", $ CHARSIZE=STR_SIZE("Happy Holidays", 0.3)

Version history

Version

$Id: str_size.pro 134 2006-07-07 10:19:08Z navarro $

History

Written by: David Fanning, 17 DEC 96. Added a scaling factor to take into account the aspect ratio of the window in determing the character size. 28 Oct 97. DWF
Produced by IDLdoc 2.0.