public static Real GetCaptionWidth( String caption, TextArea area )
{
Font font = (Font)FontManager.Instance.GetByName( area.FontName );
String current = caption;
Real lineWidth = 0;
for ( int i = 0; i < current.Length; i++ )
{
// be sure to provide a line width in the text area
if ( current[ i ] == ' ' )
{
if ( area.SpaceWidth != 0 )
lineWidth += area.SpaceWidth;
else
lineWidth += font.GetGlyphAspectRatio( ' ' ) * area.CharHeight;
}
else if ( current[ i ] == '\n' )
break;
// use glyph information to calculate line width
else
lineWidth += font.GetGlyphAspectRatio( current[ i ] ) * area.CharHeight;
}
return lineWidth;
}