Handle properly japanese for custom hud font

- Fix buffer overflow
- Use texture_font_jp as placeholder since there is no jp version of the
  custom hud fonts
This commit is contained in:
PeachyPeachSM64 2026-05-30 20:00:48 +02:00
parent a06bd34d40
commit 31c46844a0

View file

@ -208,11 +208,18 @@ static void djui_font_custom_hud_render_char(const char* c) {
u32 index = djui_unicode_get_sprite_index(c);
u32 tx = index % 16;
u32 ty = index / 16;
extern ALIGNED8 const Texture texture_font_hud[];
djui_gfx_render_texture_tile_font(texture_font_hud, 512, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 32, ty * 32, 32, 32);
if (index & 0x010000) {
index &= ~0x010000;
u32 tx = index % 64;
u32 ty = index / 64;
extern ALIGNED8 const Texture texture_font_jp[];
djui_gfx_render_texture_tile_font(texture_font_jp, 512, 1024, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16);
} else {
u32 tx = index % 16;
u32 ty = index / 16;
extern ALIGNED8 const Texture texture_font_hud[];
djui_gfx_render_texture_tile_font(texture_font_hud, 512, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 32, ty * 32, 32, 32);
}
}
static void djui_font_custom_hud_recolor_render_char(const char* c) {
@ -221,19 +228,24 @@ static void djui_font_custom_hud_recolor_render_char(const char* c) {
u32 index = djui_unicode_get_sprite_index(c);
u32 tx = index % 16;
u32 ty = index / 16;
extern ALIGNED8 const Texture texture_font_hud_recolor[];
djui_gfx_render_texture_tile_font(texture_font_hud_recolor, 512, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 32, ty * 32, 32, 32);
if (index & 0x010000) {
index &= ~0x010000;
u32 tx = index % 64;
u32 ty = index / 64;
extern ALIGNED8 const Texture texture_font_jp[];
djui_gfx_render_texture_tile_font(texture_font_jp, 512, 1024, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16);
} else {
u32 tx = index % 16;
u32 ty = index / 16;
extern ALIGNED8 const Texture texture_font_hud_recolor[];
djui_gfx_render_texture_tile_font(texture_font_hud_recolor, 512, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 32, ty * 32, 32, 32);
}
}
static f32 djui_font_custom_hud_char_width(const char* text) {
char c = *text;
if (c == ' ') { return 0.3750f; }
c = djui_unicode_get_base_char(text);
static f32 djui_font_custom_hud_char_width(const char* c) {
if (*c == ' ') { return 0.3750f; }
extern const f32 font_hud_widths[];
return font_hud_widths[(u8)c - '!'];
return djui_unicode_get_sprite_width(c, font_hud_widths, 32.0f);
}
static const struct DjuiFont sDjuiFontCustomHud = {