-# endif /* DO_SUBSCRIPTS */
- else
- {
- /* For a small font, the texture is divided into 16x16 rectangles
- whose size are the max_bounds charcell of the font. Within each
- rectangle, the individual characters' charcells sit in the upper
- left.
-
- For a larger font, the texture will itself be subdivided, to
- keep the texture sizes small (in that case we deal with, e.g.,
- 4 grids of 8x8 characters instead of 1 grid of 16x16.)
-
- Within each texture:
-
- [A]----------------------------
- | | | | |
- | l | w | | r |
- | b | i | | b |
- | e | d | | e |
- | a | t | | a |
- | r | h | | r |
- | i | | | i |
- | n | | | n |
- | g | | | g |
- | | | | |
- |----[B]----------|---| |
- | | ascent | | |
- | | | | |
- | | | | |
- |--------------------[C] |
- | descent |
- | | cell_width,
- ------------------------------ cell_height
-
- We want to make a quad from point A to point C.
- We want to position that quad so that point B lies at x,y.
- */
- int lbearing = (f->per_char && c >= f->min_char_or_byte2
- ? f->per_char[c - f->min_char_or_byte2].lbearing
- : f->min_bounds.lbearing);
- int rbearing = (f->per_char && c >= f->min_char_or_byte2
- ? f->per_char[c - f->min_char_or_byte2].rbearing
- : f->max_bounds.rbearing);
- int ascent = (f->per_char && c >= f->min_char_or_byte2
- ? f->per_char[c - f->min_char_or_byte2].ascent
- : f->max_bounds.ascent);
- int descent = (f->per_char && c >= f->min_char_or_byte2
- ? f->per_char[c - f->min_char_or_byte2].descent
- : f->max_bounds.descent);
- int cwidth = (f->per_char && c >= f->min_char_or_byte2
- ? f->per_char[c - f->min_char_or_byte2].width
- : f->max_bounds.width);
-
- unsigned char cc = c % (256 / data->ntextures);
-
- int gs = (16 / data->grid_mag); /* grid size */
-
- int ax = ((int) cc % gs) * data->cell_width; /* point A */
- int ay = ((int) cc / gs) * data->cell_height;
-
- int bx = ax - lbearing; /* point B */
- int by = ay + ascent;
-
- int cx = bx + rbearing; /* point C */
- int cy = by + descent;
-
- GLfloat tax = (GLfloat) ax / data->tex_width; /* tex coords of A */
- GLfloat tay = (GLfloat) ay / data->tex_height;
-
- GLfloat tcx = (GLfloat) cx / data->tex_width; /* tex coords of C */
- GLfloat tcy = (GLfloat) cy / data->tex_height;
-
- GLfloat qx0 = x + lbearing; /* quad top left */
- GLfloat qy0 = y + ascent;
- GLfloat qx1 = qx0 + rbearing - lbearing; /* quad bot right */
- GLfloat qy1 = qy0 - (ascent + descent);
-
- if (cwidth > 0 && c != ' ')
- {
- int which = c / (256 / data->ntextures);
- if (which >= data->ntextures) abort();
- glBindTexture (GL_TEXTURE_2D, data->texid[which]);
-
- glBegin (GL_QUADS);
- glTexCoord2f (tax, tay); glVertex3f (qx0, qy0, 0);
- glTexCoord2f (tcx, tay); glVertex3f (qx1, qy0, 0);
- glTexCoord2f (tcx, tcy); glVertex3f (qx1, qy1, 0);
- glTexCoord2f (tax, tcy); glVertex3f (qx0, qy1, 0);
- glEnd();
-#if 0
- glDisable(GL_TEXTURE_2D);
- glBegin (GL_LINE_LOOP);
- glTexCoord2f (tax, tay); glVertex3f (qx0, qy0, 0);
- glTexCoord2f (tcx, tay); glVertex3f (qx1, qy0, 0);
- glTexCoord2f (tcx, tcy); glVertex3f (qx1, qy1, 0);
- glTexCoord2f (tax, tcy); glVertex3f (qx0, qy1, 0);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-#endif
- }