Bounding Boxes of Multiline Strings

DESCRIPTION:

Compute the widths of character columns and the number of rows resulting from breaking strings containing newline characters at the newline characters.

USAGE:

string.bounding.box(s) 

REQUIRED ARGUMENTS:

s
any S-PLUS object (it will be converted to a vector of character strings)

VALUE:

A list with components "columns" and "rows". The ith elements of these components give the dimensions of the smallest box enclosing the ith string in the input after it has been broken up into lines by the "\n" characters in it. That is, "rows" gives the number of lines and "columns" gives the maximum of the number of characters in all the lines from a single string.

NOTE:

This is useful for formatting text written in constant width fonts, as are common in text windows. However most graphics text is written in variable width fonts so the widths in the "columns" component can only approximate the amount of space required to show the string on a plot.

SEE ALSO:

, .

EXAMPLES:

string.bounding.box(c("Two\nLines", "One Line")) 
# gives the following output: 
# $columns: 
# [1] 5 8 
# $rows: 
# [1] 2 1