@@ -369,13 +369,12 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
369369 void MenuItem_static::draw (const uint8_t row, PGM_P const pstr, const uint8_t style/* =SS_DEFAULT*/ , const char * const vstr/* =nullptr*/ ) {
370370
371371 if (mark_as_selected (row, style & SS_INVERT)) {
372-
373372 pixel_len_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
374-
375- const int8_t plen = pstr ? utf8_strlen_P (pstr) : 0 ,
376- vlen = vstr ? utf8_strlen (vstr) : 0 ;
373+
374+ const int plen = pstr ? calculateWidth (pstr) : 0 ,
375+ vlen = vstr ? utf8_strlen (vstr) : 0 ;
377376 if (style & SS_CENTER) {
378- int8_t pad = (LCD_WIDTH - plen - vlen) / 2 ;
377+ int pad = (LCD_PIXEL_WIDTH - plen - vlen * MENU_FONT_WIDTH) / MENU_FONT_WIDTH / 2 ;
379378 while (--pad >= 0 ) n -= lcd_put_wchar (' ' );
380379 }
381380
@@ -400,8 +399,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
400399 if (mark_as_selected (row, sel)) {
401400 const uint8_t vallen = (pgm ? utf8_strlen_P (inStr) : utf8_strlen ((char *)inStr)),
402401 pixelwidth = (pgm ? uxg_GetUtf8StrPixelWidthP (u8g.getU8g (), inStr) : uxg_GetUtf8StrPixelWidth (u8g.getU8g (), (char *)inStr));
402+ const u8g_uint_t prop = USE_WIDE_GLYPH ? 2 : 1 ;
403403
404- pixel_len_t n = lcd_put_u8str_ind_P (pstr, itemIndex, itemString, LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH);
404+ pixel_len_t n = lcd_put_u8str_ind_P (pstr, itemIndex, itemString, LCD_WIDTH - 2 - vallen * prop ) * (MENU_FONT_WIDTH);
405405 if (vallen) {
406406 lcd_put_wchar (' :' );
407407 while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar (' ' );
@@ -414,15 +414,16 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
414414 void MenuEditItemBase::draw_edit_screen (PGM_P const pstr, const char * const value/* =nullptr*/ ) {
415415 ui.encoder_direction_normal ();
416416
417+ const u8g_uint_t prop = USE_WIDE_GLYPH ? 2 : 1 ;
417418 const u8g_uint_t labellen = utf8_strlen_P (pstr), vallen = utf8_strlen (value);
418- bool extra_row = labellen > LCD_WIDTH - 2 - vallen;
419+ bool extra_row = labellen * prop > LCD_WIDTH - 2 - vallen * prop ;
419420
420421 #if ENABLED(USE_BIG_EDIT_FONT)
421422 // Use the menu font if the label won't fit on a single line
422423 constexpr u8g_uint_t lcd_edit_width = (LCD_PIXEL_WIDTH) / (EDIT_FONT_WIDTH);
423424 u8g_uint_t lcd_chr_fit, one_chr_width;
424- if (labellen <= lcd_edit_width - 1 ) {
425- if (labellen + vallen + 1 > lcd_edit_width) extra_row = true ;
425+ if (labellen * prop <= lcd_edit_width - 1 ) {
426+ if (labellen * prop + vallen * prop + 1 > lcd_edit_width) extra_row = true ;
426427 lcd_chr_fit = lcd_edit_width + 1 ;
427428 one_chr_width = EDIT_FONT_WIDTH;
428429 ui.set_font (FONT_EDIT);
@@ -454,7 +455,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
454455 onpage = PAGE_CONTAINS (baseline - (EDIT_FONT_ASCENT - 1 ), baseline);
455456 }
456457 if (onpage) {
457- lcd_put_wchar (((lcd_chr_fit - 1 ) - (vallen + 1 )) * one_chr_width, baseline, ' ' ); // Right-justified, padded, add a leading space
458+ lcd_put_wchar (((lcd_chr_fit - 1 ) - (vallen * prop + 1 )) * one_chr_width, baseline, ' ' ); // Right-justified, padded, add a leading space
458459 lcd_put_u8str (value);
459460 }
460461 }
@@ -478,8 +479,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
478479 void MenuItem_confirm::draw_select_screen (PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/* =nullptr*/ , PGM_P const suff/* =nullptr*/ ) {
479480 ui.draw_select_screen_prompt (pref, string, suff);
480481 draw_boxed_string (1 , LCD_HEIGHT - 1 , no, !yesno);
481- const u8g_uint_t xpos = (LCD_WIDTH) / (USE_WIDE_GLYPH ? 2 : 1 );
482- draw_boxed_string (xpos - (utf8_strlen_P (yes) + 1 ), LCD_HEIGHT - 1 , yes, yesno);
482+ draw_boxed_string (LCD_WIDTH - (utf8_strlen_P (yes) * (USE_WIDE_GLYPH ? 2 : 1 ) + 1 ), LCD_HEIGHT - 1 , yes, yesno);
483483 }
484484
485485 #if ENABLED(SDSUPPORT)
0 commit comments