mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 11:28:15 +00:00
Added a font glyph for missing characters
This commit is contained in:
@@ -35,6 +35,8 @@
|
|||||||
;
|
;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define NUM_FONT_GLYPHS 257
|
||||||
|
|
||||||
static unsigned char SDLTest_FontData[] = {
|
static unsigned char SDLTest_FontData[] = {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3110,14 +3112,26 @@ static unsigned char SDLTest_FontData[] = {
|
|||||||
0x30, /* 00001100 */
|
0x30, /* 00001100 */
|
||||||
0x1f, /* 11111000 */
|
0x1f, /* 11111000 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 256 0x100 - missing character
|
||||||
|
*/
|
||||||
|
0x55, /* 01010101 */
|
||||||
|
0xAA, /* 10101010 */
|
||||||
|
0x55, /* 01010101 */
|
||||||
|
0xAA, /* 10101010 */
|
||||||
|
0x55, /* 01010101 */
|
||||||
|
0xAA, /* 10101010 */
|
||||||
|
0x55, /* 01010101 */
|
||||||
|
0xAA, /* 10101010 */
|
||||||
};
|
};
|
||||||
|
SDL_COMPILE_TIME_ASSERT(SDLTest_FontDataSize, SDL_arraysize(SDLTest_FontData) == NUM_FONT_GLYPHS * 8);
|
||||||
|
|
||||||
/* ---- Character */
|
/* ---- Character */
|
||||||
|
|
||||||
struct SDLTest_CharTextureCache
|
struct SDLTest_CharTextureCache
|
||||||
{
|
{
|
||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
SDL_Texture *charTextureCache[256];
|
SDL_Texture *charTextureCache[NUM_FONT_GLYPHS];
|
||||||
struct SDLTest_CharTextureCache *next;
|
struct SDLTest_CharTextureCache *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3163,6 +3177,9 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c)
|
|||||||
|
|
||||||
/* Character index in cache */
|
/* Character index in cache */
|
||||||
ci = c;
|
ci = c;
|
||||||
|
if (ci >= NUM_FONT_GLYPHS) {
|
||||||
|
ci = (NUM_FONT_GLYPHS - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Search for this renderer's cache */
|
/* Search for this renderer's cache */
|
||||||
for (cache = SDLTest_CharTextureCacheList; cache; cache = cache->next) {
|
for (cache = SDLTest_CharTextureCacheList; cache; cache = cache->next) {
|
||||||
@@ -3342,9 +3359,7 @@ int SDLTest_DrawString(SDL_Renderer *renderer, float x, float y, const char *s)
|
|||||||
while (len > 0 && !result) {
|
while (len > 0 && !result) {
|
||||||
int advance = 0;
|
int advance = 0;
|
||||||
Uint32 ch = UTF8_getch(s, len, &advance);
|
Uint32 ch = UTF8_getch(s, len, &advance);
|
||||||
if (ch < 256) {
|
result |= SDLTest_DrawCharacter(renderer, curx, cury, ch);
|
||||||
result |= SDLTest_DrawCharacter(renderer, curx, cury, ch);
|
|
||||||
}
|
|
||||||
curx += charWidth;
|
curx += charWidth;
|
||||||
s += advance;
|
s += advance;
|
||||||
len -= advance;
|
len -= advance;
|
||||||
|
Reference in New Issue
Block a user