-Box
-Font_metric::text_dimension (String text) const
-{
- Interval ydims;
- Real w=0.0;
-
- for (int i = 0; i < text.length_i (); i++)
- {
-
- switch (text[i])
- {
- case '\\':
- for (i++; (i < text.length_i ()) && !isspace(text[i])
- && text[i]!='{' && text[i]!='}'; i++)
- ;
- // ugh.
- i--; // Compensate for the increment in the outer loop!
- break;
- case '{': // Skip '{' and '}'
- case '}':
- break;
-
- default:
- Box b = get_char ((unsigned char)text[i],false);
-
- // Ugh, use the width of 'x' for unknown characters
- if (b[X_AXIS].length () == 0)
- b = get_char ((unsigned char)'x',false);
-
- w += b[X_AXIS].length ();
- ydims.unite (b[Y_AXIS]);
- break;
- }
- }
- if (ydims.empty_b ())
- ydims = Interval (0,0);