From 7670ffe6babb473757d5f7a35a1c0650db24c332 Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Tue, 21 May 2024 18:06:33 +0200 Subject: [PATCH] Fix issues with new font rendering in libdragon --- src/menu/components/common.c | 9 ++++++--- src/menu/components/constants.h | 6 ++++-- src/menu/components/context_menu.c | 1 + src/menu/components/file_list.c | 8 +++++--- src/menu/views/load_rom.c | 10 ++++------ 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/menu/components/common.c b/src/menu/components/common.c index 6bf708f8..d0fce75f 100644 --- a/src/menu/components/common.c +++ b/src/menu/components/common.c @@ -118,7 +118,8 @@ void component_messagebox_draw (char *fmt, ...) { .height = VISIBLE_AREA_HEIGHT, .align = ALIGN_CENTER, .valign = VALIGN_CENTER, - .wrap = WRAP_WORD + .wrap = WRAP_WORD, + .line_spacing = TEXT_LINE_SPACING_ADJUST, }, FNT_DEFAULT, formatted, ¶graph_nbytes); if (formatted != buffer) { @@ -151,10 +152,11 @@ void component_main_text_draw (rdpq_align_t align, rdpq_valign_t valign, char *f .align = align, .valign = valign, .wrap = WRAP_ELLIPSES, + .line_spacing = TEXT_LINE_SPACING_ADJUST, }, FNT_DEFAULT, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, - VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL, + VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL, formatted, nbytes ); @@ -180,10 +182,11 @@ void component_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t valign, .align = align, .valign = valign, .wrap = WRAP_ELLIPSES, + .line_spacing = TEXT_LINE_SPACING_ADJUST, }, FNT_DEFAULT, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, - LAYOUT_ACTIONS_SEPARATOR_Y + BORDER_THICKNESS + TEXT_MARGIN_VERTICAL, + LAYOUT_ACTIONS_SEPARATOR_Y + BORDER_THICKNESS + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL, formatted, nbytes ); diff --git a/src/menu/components/constants.h b/src/menu/components/constants.h index f3eb3e39..e4d3eb51 100644 --- a/src/menu/components/constants.h +++ b/src/menu/components/constants.h @@ -65,7 +65,9 @@ #define MESSAGEBOX_MARGIN (32) #define TEXT_MARGIN_HORIZONTAL (10) -#define TEXT_MARGIN_VERTICAL (7) +#define TEXT_MARGIN_VERTICAL (6) +#define TEXT_OFFSET_VERTICAL (1) +#define TEXT_LINE_SPACING_ADJUST (0) /** @brief The boxart picture width. */ #define BOXART_WIDTH (158) @@ -86,7 +88,7 @@ #define LIST_SCROLLBAR_Y (VISIBLE_AREA_Y0) /** @brief The maximum amount of file list entries. */ -#define LIST_ENTRIES (20) +#define LIST_ENTRIES (19) /** @brief The maximum width available for a file list entry. */ #define FILE_LIST_MAX_WIDTH (480) #define FILE_LIST_HIGHLIGHT_WIDTH (VISIBLE_AREA_X1 - VISIBLE_AREA_X0 - LIST_SCROLLBAR_WIDTH) diff --git a/src/menu/components/context_menu.c b/src/menu/components/context_menu.c index f2e32c42..ff6db4db 100644 --- a/src/menu/components/context_menu.c +++ b/src/menu/components/context_menu.c @@ -81,6 +81,7 @@ void component_context_menu_draw (component_context_menu_t *cm) { .height = VISIBLE_AREA_HEIGHT, .align = ALIGN_CENTER, .valign = VALIGN_CENTER, + .line_spacing = TEXT_LINE_SPACING_ADJUST, }, FNT_DEFAULT, NULL diff --git a/src/menu/components/file_list.c b/src/menu/components/file_list.c index b00ef329..7a9835ce 100644 --- a/src/menu/components/file_list.c +++ b/src/menu/components/file_list.c @@ -71,6 +71,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected) { .width = FILE_LIST_MAX_WIDTH - (TEXT_MARGIN_HORIZONTAL * 2), .height = LAYOUT_ACTIONS_SEPARATOR_Y - VISIBLE_AREA_Y0 - (TEXT_MARGIN_VERTICAL * 2), .wrap = WRAP_ELLIPSES, + .line_spacing = TEXT_LINE_SPACING_ADJUST, }, FNT_DEFAULT, file_list_layout @@ -114,7 +115,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected) { layout = rdpq_paragraph_builder_end(); int highlight_height = (layout->bbox.y1 - layout->bbox.y0) / layout->nlines; - int highlight_y = VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL + ((selected - starting_position) * highlight_height); + int highlight_y = VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL + ((selected - starting_position) * highlight_height); component_box_draw( FILE_LIST_HIGHLIGHT_X, @@ -127,7 +128,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected) { rdpq_paragraph_render( layout, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, - VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL + VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL ); rdpq_paragraph_free(layout); @@ -138,6 +139,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected) { .height = LAYOUT_ACTIONS_SEPARATOR_Y - VISIBLE_AREA_Y0 - (TEXT_MARGIN_VERTICAL * 2), .align = ALIGN_RIGHT, .wrap = WRAP_ELLIPSES, + .line_spacing = TEXT_LINE_SPACING_ADJUST, }, FNT_DEFAULT, NULL @@ -164,7 +166,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected) { rdpq_paragraph_render( layout, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, - VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL + VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL ); rdpq_paragraph_free(layout); diff --git a/src/menu/views/load_rom.c b/src/menu/views/load_rom.c index 1d4f41be..e6d8e531 100644 --- a/src/menu/views/load_rom.c +++ b/src/menu/views/load_rom.c @@ -236,12 +236,10 @@ static void draw (menu_t *menu, surface_t *d) { " Save type: %s\n" " TV type: %s\n" " Expansion PAK: %s\n" - "\n" - " Extra information:\n" - " CIC: %s\n" - " Boot address: 0x%08lX\n" - " SDK version: %.1f%c\n" - " Clock Rate: %.2fMHz\n", + " CIC: %s\n" + " Boot address: 0x%08lX\n" + " SDK version: %.1f%c\n" + " Clock Rate: %.2fMHz\n", format_rom_endianness(menu->load.rom_info.endianness), menu->load.rom_info.title, menu->load.rom_info.game_code[0], menu->load.rom_info.game_code[1], menu->load.rom_info.game_code[2], menu->load.rom_info.game_code[3],