Fix saving/loading glyph 255 in RegisterFont

The glyph for character 255 (lower case y with two dots above it) was
rendered, but it's glyph information was not stored in fontInfo_t and
not saved into .dat file (including the ones in Team Arena).

Attempting to load it from existing .dat font files is fine because
shader name is "" and gets 0 handle. The handle was already 0 anyway.
This commit is contained in:
Zack Middleton 2014-12-01 20:23:22 -06:00
parent 8c7fedb1fe
commit 08ddb99732

View file

@ -397,7 +397,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
// Com_Memcpy(font, faceData, sizeof(fontInfo_t)); // Com_Memcpy(font, faceData, sizeof(fontInfo_t));
Q_strncpyz(font->name, name, sizeof(font->name)); Q_strncpyz(font->name, name, sizeof(font->name));
for (i = GLYPH_START; i < GLYPH_END; i++) { for (i = GLYPH_START; i <= GLYPH_END; i++) {
font->glyphs[i].glyph = RE_RegisterShaderNoMip(font->glyphs[i].shaderName); font->glyphs[i].glyph = RE_RegisterShaderNoMip(font->glyphs[i].shaderName);
} }
Com_Memcpy(&registeredFont[registeredFontCount++], font, sizeof(fontInfo_t)); Com_Memcpy(&registeredFont[registeredFontCount++], font, sizeof(fontInfo_t));
@ -445,7 +445,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
maxHeight = 0; maxHeight = 0;
for (i = GLYPH_START; i < GLYPH_END; i++) { for (i = GLYPH_START; i <= GLYPH_END; i++) {
RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qtrue); RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qtrue);
} }
@ -455,11 +455,16 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
lastStart = i; lastStart = i;
imageNumber = 0; imageNumber = 0;
while ( i <= GLYPH_END ) { while ( i <= GLYPH_END + 1 ) {
glyph = RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qfalse); if ( i == GLYPH_END + 1 ) {
// upload/save current image buffer
xOut = yOut = -1;
} else {
glyph = RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qfalse);
}
if (xOut == -1 || yOut == -1 || i == GLYPH_END) { if (xOut == -1 || yOut == -1) {
// ran out of room // ran out of room
// we need to create an image from the bitmap, set all the handles in the glyphs to this point // we need to create an image from the bitmap, set all the handles in the glyphs to this point
// //
@ -504,7 +509,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
xOut = 0; xOut = 0;
yOut = 0; yOut = 0;
ri.Free(imageBuff); ri.Free(imageBuff);
if(i == GLYPH_END) if ( i == GLYPH_END + 1 )
i++; i++;
} else { } else {
Com_Memcpy(&font->glyphs[i], glyph, sizeof(glyphInfo_t)); Com_Memcpy(&font->glyphs[i], glyph, sizeof(glyphInfo_t));