-static int
-string_width (XFontStruct *f, const char *c)
-{
- int w = 0;
- while (*c)
- {
- int cc = *((unsigned char *) c);
- w += (f->per_char
- ? f->per_char[cc-f->min_char_or_byte2].rbearing
- : f->min_bounds.rbearing);
- c++;
- }
- return w;
-}
-
-static void
-print_title_string (ModeInfo *mi, const char *string,
- GLfloat x, GLfloat y,
- XFontStruct *font, int font_dlist)
-{
- GLfloat line_height = font->ascent + font->descent;
- GLfloat sub_shift = (line_height * 0.3);
- int cw = string_width (font, "m");
- int tabs = cw * 7;
-
- y -= line_height;
-
- glPushAttrib (GL_TRANSFORM_BIT | /* for matrix contents */
- GL_ENABLE_BIT); /* for various glDisable calls */
- glDisable (GL_LIGHTING);
- glDisable (GL_DEPTH_TEST);
- {
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- {
- glLoadIdentity();
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- {
- int i;
- int x2 = x;
- Bool sub_p = False;
- glLoadIdentity();
-
- gluOrtho2D (0, mi->xgwa.width, 0, mi->xgwa.height);
-
- glColor3f (0.8, 0.8, 0);
-
- glRasterPos2f (x, y);
- for (i = 0; i < strlen(string); i++)
- {
- char c = string[i];
- if (c == '\n')
- {
- glRasterPos2f (x, (y -= line_height));
- x2 = x;
- }
- else if (c == '\t')
- {
- x2 -= x;
- x2 = ((x2 + tabs) / tabs) * tabs; /* tab to tab stop */
- x2 += x;
- glRasterPos2f (x2, y);
- }
- else if (c == '[' && (isdigit (string[i+1])))
- {
- sub_p = True;
- glRasterPos2f (x2, (y -= sub_shift));
- }
- else if (c == ']' && sub_p)
- {
- sub_p = False;
- glRasterPos2f (x2, (y += sub_shift));
- }
- else
- {
- glCallList (font_dlist + (int)(c));
- x2 += (font->per_char
- ? font->per_char[c - font->min_char_or_byte2].width
- : font->min_bounds.width);
- }
- }
- }
- glPopMatrix();
- }
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- }
- glPopAttrib();
-
- glMatrixMode(GL_MODELVIEW);
-}
-