Fix issues with new font rendering in libdragon

This commit is contained in:
Mateusz Faderewski 2024-05-21 18:06:33 +02:00
parent 91f2e02d34
commit 7670ffe6ba
5 changed files with 20 additions and 14 deletions

View File

@ -118,7 +118,8 @@ void component_messagebox_draw (char *fmt, ...) {
.height = VISIBLE_AREA_HEIGHT, .height = VISIBLE_AREA_HEIGHT,
.align = ALIGN_CENTER, .align = ALIGN_CENTER,
.valign = VALIGN_CENTER, .valign = VALIGN_CENTER,
.wrap = WRAP_WORD .wrap = WRAP_WORD,
.line_spacing = TEXT_LINE_SPACING_ADJUST,
}, FNT_DEFAULT, formatted, &paragraph_nbytes); }, FNT_DEFAULT, formatted, &paragraph_nbytes);
if (formatted != buffer) { if (formatted != buffer) {
@ -151,10 +152,11 @@ void component_main_text_draw (rdpq_align_t align, rdpq_valign_t valign, char *f
.align = align, .align = align,
.valign = valign, .valign = valign,
.wrap = WRAP_ELLIPSES, .wrap = WRAP_ELLIPSES,
.line_spacing = TEXT_LINE_SPACING_ADJUST,
}, },
FNT_DEFAULT, FNT_DEFAULT,
VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL,
VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL, VISIBLE_AREA_Y0 + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL,
formatted, formatted,
nbytes nbytes
); );
@ -180,10 +182,11 @@ void component_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t valign,
.align = align, .align = align,
.valign = valign, .valign = valign,
.wrap = WRAP_ELLIPSES, .wrap = WRAP_ELLIPSES,
.line_spacing = TEXT_LINE_SPACING_ADJUST,
}, },
FNT_DEFAULT, FNT_DEFAULT,
VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, 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, formatted,
nbytes nbytes
); );

View File

@ -65,7 +65,9 @@
#define MESSAGEBOX_MARGIN (32) #define MESSAGEBOX_MARGIN (32)
#define TEXT_MARGIN_HORIZONTAL (10) #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. */ /** @brief The boxart picture width. */
#define BOXART_WIDTH (158) #define BOXART_WIDTH (158)
@ -86,7 +88,7 @@
#define LIST_SCROLLBAR_Y (VISIBLE_AREA_Y0) #define LIST_SCROLLBAR_Y (VISIBLE_AREA_Y0)
/** @brief The maximum amount of file list entries. */ /** @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. */ /** @brief The maximum width available for a file list entry. */
#define FILE_LIST_MAX_WIDTH (480) #define FILE_LIST_MAX_WIDTH (480)
#define FILE_LIST_HIGHLIGHT_WIDTH (VISIBLE_AREA_X1 - VISIBLE_AREA_X0 - LIST_SCROLLBAR_WIDTH) #define FILE_LIST_HIGHLIGHT_WIDTH (VISIBLE_AREA_X1 - VISIBLE_AREA_X0 - LIST_SCROLLBAR_WIDTH)

View File

@ -81,6 +81,7 @@ void component_context_menu_draw (component_context_menu_t *cm) {
.height = VISIBLE_AREA_HEIGHT, .height = VISIBLE_AREA_HEIGHT,
.align = ALIGN_CENTER, .align = ALIGN_CENTER,
.valign = VALIGN_CENTER, .valign = VALIGN_CENTER,
.line_spacing = TEXT_LINE_SPACING_ADJUST,
}, },
FNT_DEFAULT, FNT_DEFAULT,
NULL NULL

View File

@ -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), .width = FILE_LIST_MAX_WIDTH - (TEXT_MARGIN_HORIZONTAL * 2),
.height = LAYOUT_ACTIONS_SEPARATOR_Y - VISIBLE_AREA_Y0 - (TEXT_MARGIN_VERTICAL * 2), .height = LAYOUT_ACTIONS_SEPARATOR_Y - VISIBLE_AREA_Y0 - (TEXT_MARGIN_VERTICAL * 2),
.wrap = WRAP_ELLIPSES, .wrap = WRAP_ELLIPSES,
.line_spacing = TEXT_LINE_SPACING_ADJUST,
}, },
FNT_DEFAULT, FNT_DEFAULT,
file_list_layout file_list_layout
@ -114,7 +115,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected) {
layout = rdpq_paragraph_builder_end(); layout = rdpq_paragraph_builder_end();
int highlight_height = (layout->bbox.y1 - layout->bbox.y0) / layout->nlines; 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( component_box_draw(
FILE_LIST_HIGHLIGHT_X, FILE_LIST_HIGHLIGHT_X,
@ -127,7 +128,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected) {
rdpq_paragraph_render( rdpq_paragraph_render(
layout, layout,
VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, 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); 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), .height = LAYOUT_ACTIONS_SEPARATOR_Y - VISIBLE_AREA_Y0 - (TEXT_MARGIN_VERTICAL * 2),
.align = ALIGN_RIGHT, .align = ALIGN_RIGHT,
.wrap = WRAP_ELLIPSES, .wrap = WRAP_ELLIPSES,
.line_spacing = TEXT_LINE_SPACING_ADJUST,
}, },
FNT_DEFAULT, FNT_DEFAULT,
NULL NULL
@ -164,7 +166,7 @@ void component_file_list_draw (entry_t *list, int entries, int selected) {
rdpq_paragraph_render( rdpq_paragraph_render(
layout, layout,
VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, 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); rdpq_paragraph_free(layout);

View File

@ -236,12 +236,10 @@ static void draw (menu_t *menu, surface_t *d) {
" Save type: %s\n" " Save type: %s\n"
" TV type: %s\n" " TV type: %s\n"
" Expansion PAK: %s\n" " Expansion PAK: %s\n"
"\n" " CIC: %s\n"
" Extra information:\n" " Boot address: 0x%08lX\n"
" CIC: %s\n" " SDK version: %.1f%c\n"
" Boot address: 0x%08lX\n" " Clock Rate: %.2fMHz\n",
" SDK version: %.1f%c\n"
" Clock Rate: %.2fMHz\n",
format_rom_endianness(menu->load.rom_info.endianness), format_rom_endianness(menu->load.rom_info.endianness),
menu->load.rom_info.title, 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], 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],