+ x += 1.0/pix_x * r_textshadow.value;
+ y += 1.0/pix_y * r_textshadow.value;
+ }
+ if (!fontmap || (ch <= 0xFF && fontmap->glyphs[ch].image) || (ch >= 0xE000 && ch <= 0xE0FF))
+ {
+ if (ch >= 0xE000)
+ ch -= 0xE000;
+ if (ch > 0xFF)
+ goto out;
+ if (fontmap)
+ 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
+ if (r_nearest_conchars.integer)
+ {
+ s = (ch & 15)*0.0625f;
+ t = (ch >> 4)*0.0625f;
+ u = 0.0625f * thisw;
+ v = 0.0625f;
+ }
+ else
+ {
+ 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);
+ }
+ surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, fnt->pic->name, flags, TEXF_ALPHA | TEXF_CLAMP, MATERIALFLAG_VERTEXCOLOR), true);
+ e0 = Mod_Mesh_IndexForVertex(mod, surf, x , y , 10, 0, 0, -1, s , t , 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
+ e1 = Mod_Mesh_IndexForVertex(mod, surf, x+dw*thisw, y , 10, 0, 0, -1, s+u, t , 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
+ e2 = Mod_Mesh_IndexForVertex(mod, surf, x+dw*thisw, y+dh, 10, 0, 0, -1, s+u, t+v, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
+ e3 = Mod_Mesh_IndexForVertex(mod, surf, x , y+dh, 10, 0, 0, -1, s , t+v, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
+ Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
+ Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
+ x += width_of[ch] * dw;
+ } else {
+ if (!map || map == ft2_oldstyle_map || ch < map->start || ch >= map->start + FONT_CHARS_PER_MAP)
+ {
+ // 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;
+ }
+ }
+ }
+
+ mapch = ch - map->start;
+ thisw = map->glyphs[mapch].advance_x;
+
+ //x += ftbase_x;
+ y += ftbase_y;
+ if (prevch && Font_GetKerningForMap(ft2, map_index, w, h, prevch, ch, &kx, &ky))
+ {
+ x += kx * dw;
+ y += ky * dh;
+ }
+ else
+ kx = ky = 0;
+ surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, map->pic->name, flags, TEXF_ALPHA | TEXF_CLAMP, MATERIALFLAG_VERTEXCOLOR), true);
+ e0 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmin, y + dh * map->glyphs[mapch].vymin, 10, 0, 0, -1, map->glyphs[mapch].txmin, map->glyphs[mapch].tymin, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
+ e1 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmax, y + dh * map->glyphs[mapch].vymin, 10, 0, 0, -1, map->glyphs[mapch].txmax, map->glyphs[mapch].tymin, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
+ e2 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmax, y + dh * map->glyphs[mapch].vymax, 10, 0, 0, -1, map->glyphs[mapch].txmax, map->glyphs[mapch].tymax, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
+ e3 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmin, y + dh * map->glyphs[mapch].vymax, 10, 0, 0, -1, map->glyphs[mapch].txmin, map->glyphs[mapch].tymax, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
+ Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
+ Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
+ //x -= ftbase_x;
+ y -= ftbase_y;
+
+ x += thisw * dw;
+
+ //prevmap = map;
+ prevch = ch;
+ }
+out:
+ if (shadow)
+ {
+ x -= 1.0/pix_x * r_textshadow.value;
+ y -= 1.0/pix_y * r_textshadow.value;