mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
Add UTF-8 support to RGUI. Others still assume ISO-8859-1, they'll have to be fixed one by one before we enable UTF-8 globally.
This commit is contained in:
parent
64ba6e076b
commit
889a4f4955
@ -444,6 +444,10 @@ ifeq ($(HAVE_MENU_COMMON), 1)
|
|||||||
menu/drivers/null.o
|
menu/drivers/null.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(UTF8), 1)
|
||||||
|
DEFINES += -DHAVE_UTF8
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_STB_FONT), 1)
|
ifeq ($(HAVE_STB_FONT), 1)
|
||||||
OBJ += gfx/drivers_font_renderer/stb.o
|
OBJ += gfx/drivers_font_renderer/stb.o
|
||||||
endif
|
endif
|
||||||
|
@ -150,6 +150,33 @@ static void color_rect(menu_handle_t *menu,
|
|||||||
frame_buf->data[j * (frame_buf->pitch >> 1) + i] = color;
|
frame_buf->data[j * (frame_buf->pitch >> 1) + i] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t string_walkbyte(const char **string)
|
||||||
|
{
|
||||||
|
return *((*string)++);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_UTF8
|
||||||
|
/* Does not validate the input, returns garbage if it's not UTF-8. */
|
||||||
|
static uint32_t string_walk(const char **string)
|
||||||
|
{
|
||||||
|
uint8_t first = string_walkbyte(string);
|
||||||
|
uint32_t ret;
|
||||||
|
|
||||||
|
if (first<128) return first;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
ret = (ret<<6) | (string_walkbyte(string)&0x3F);
|
||||||
|
if (first >= 0xE0) ret = (ret<<6) | (string_walkbyte(string)&0x3F);
|
||||||
|
if (first >= 0xF0) ret = (ret<<6) | (string_walkbyte(string)&0x3F);
|
||||||
|
|
||||||
|
if (first >= 0xF0) return ret | (first&31)<<18;
|
||||||
|
if (first >= 0xE0) return ret | (first&15)<<12;
|
||||||
|
return ret | (first&7)<<6;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define string_walk string_walkbyte
|
||||||
|
#endif
|
||||||
|
|
||||||
static void blit_line(menu_handle_t *menu, int x, int y,
|
static void blit_line(menu_handle_t *menu, int x, int y,
|
||||||
const char *message, uint16_t color)
|
const char *message, uint16_t color)
|
||||||
{
|
{
|
||||||
@ -159,14 +186,15 @@ static void blit_line(menu_handle_t *menu, int x, int y,
|
|||||||
|
|
||||||
while (*message)
|
while (*message)
|
||||||
{
|
{
|
||||||
|
uint32_t symbol = string_walk(&message);
|
||||||
|
|
||||||
for (j = 0; j < FONT_HEIGHT; j++)
|
for (j = 0; j < FONT_HEIGHT; j++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < FONT_WIDTH; i++)
|
for (i = 0; i < FONT_WIDTH; i++)
|
||||||
{
|
{
|
||||||
uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7);
|
uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7);
|
||||||
int offset = (i + j * FONT_WIDTH) >> 3;
|
int offset = (i + j * FONT_WIDTH) >> 3;
|
||||||
bool col = (disp->font.framebuf[FONT_OFFSET
|
bool col = (disp->font.framebuf[FONT_OFFSET(symbol) + offset] & rem);
|
||||||
((unsigned char)*message) + offset] & rem);
|
|
||||||
|
|
||||||
if (!col)
|
if (!col)
|
||||||
continue;
|
continue;
|
||||||
@ -177,7 +205,6 @@ static void blit_line(menu_handle_t *menu, int x, int y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
x += FONT_WIDTH_STRIDE;
|
x += FONT_WIDTH_STRIDE;
|
||||||
message++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user