+ if (fontmap)
+ {
+ if (map != ft2_oldstyle_map)
+ {
+ if (batchcount)
+ {
+ // switching from freetype to non-freetype rendering
+ R_Mesh_PrepareVertices_Generic_Arrays(batchcount * 4, vertex3f, color4f, texcoord2f);
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, NULL, 0, quadelement3s, NULL, 0);
+ batchcount = 0;
+ ac = color4f;
+ at = texcoord2f;
+ av = vertex3f;
+ }
+ R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1);
+ map = ft2_oldstyle_map;
+ }
+ }
+ prevch = 0;
+ //num = (unsigned char) text[i];
+ //thisw = fnt->width_of[num];
+ thisw = fnt->width_of[ch];
+ // FIXME make these smaller to just include the occupied part of the character for slightly faster rendering
+ s = (ch & 15)*0.0625f + (0.5f / tw);
+ t = (ch >> 4)*0.0625f + (0.5f / th);
+ u = 0.0625f * thisw - (1.0f / tw);
+ v = 0.0625f - (1.0f / th);
+ ac[ 0] = color[0];ac[ 1] = color[1];ac[ 2] = color[2];ac[ 3] = color[3];
+ ac[ 4] = color[0];ac[ 5] = color[1];ac[ 6] = color[2];ac[ 7] = color[3];
+ ac[ 8] = color[0];ac[ 9] = color[1];ac[10] = color[2];ac[11] = color[3];
+ ac[12] = color[0];ac[13] = color[1];ac[14] = color[2];ac[15] = color[3];
+ at[ 0] = s ; at[ 1] = t ;
+ at[ 2] = s+u ; at[ 3] = t ;
+ at[ 4] = s+u ; at[ 5] = t+v ;
+ at[ 6] = s ; at[ 7] = t+v ;
+ av[ 0] = x ; av[ 1] = y ; av[ 2] = 10;
+ av[ 3] = x+dw*thisw ; av[ 4] = y ; av[ 5] = 10;
+ av[ 6] = x+dw*thisw ; av[ 7] = y+dh ; av[ 8] = 10;
+ av[ 9] = x ; av[10] = y+dh ; av[11] = 10;
+ ac += 16;
+ at += 8;
+ av += 12;
+ batchcount++;
+ if (batchcount >= QUADELEMENTS_MAXQUADS)
+ {
+ R_Mesh_PrepareVertices_Generic_Arrays(batchcount * 4, vertex3f, color4f, texcoord2f);
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, NULL, 0, quadelement3s, NULL, 0);
+ batchcount = 0;
+ ac = color4f;
+ at = texcoord2f;
+ av = vertex3f;
+ }
+ x += width_of[ch] * dw;
+ } else {
+ if (!map || map == ft2_oldstyle_map || ch < map->start || ch >= map->start + FONT_CHARS_PER_MAP)
+ {
+ // new charmap - need to render
+ if (batchcount)
+ {
+ // we need a different character map, render what we currently have:
+ R_Mesh_PrepareVertices_Generic_Arrays(batchcount * 4, vertex3f, color4f, texcoord2f);
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, NULL, 0, quadelement3s, NULL, 0);
+ batchcount = 0;
+ ac = color4f;
+ at = texcoord2f;
+ av = vertex3f;
+ }
+ // find the new map
+ map = FontMap_FindForChar(fontmap, ch);
+ if (!map)
+ {
+ if (!Font_LoadMapForIndex(ft2, map_index, ch, &map))
+ {
+ shadow = -1;
+ break;
+ }
+ if (!map)
+ {
+ // this shouldn't happen
+ shadow = -1;
+ break;
+ }
+ }
+ R_SetupShader_Generic(map->texture, NULL, GL_MODULATE, 1);