- Interval ydims;
- Real w=0.0;
-
- for (int i = 0; i < text.length (); i++)
- {
-
- switch (text[i])
- {
- case '\\':
- // accent marks use width of base letter
- if (i +1 < text.length ())
- {
- if (text[i+1]=='\'' || text[i+1]=='`' || text[i+1]=='"' ||
- text[i+1]=='^')
- {
- i++;
- break;
- }
- // for string width \\ is a \ and \_ is a _.
- if (text[i+1]=='\\' || text[i+1]=='_')
- {
- break;
- }
- }
-
- for (i++; (i < text.length ()) && !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_ascii_char ((unsigned char)text[i]);
-
- // Ugh, use the width of 'x' for unknown characters
- if (b[X_AXIS].length () == 0)
- b = get_ascii_char ((unsigned char)'x');
-
- w += b[X_AXIS].length ();
- ydims.unite (b[Y_AXIS]);
- break;
- }
- }
- if (ydims.is_empty ())
- ydims = Interval (0,0);
-
- return Box (Interval (0, w), ydims);