Browse Source

Use font ascent and descent for line positioning (#12224)

N95JPL 6 years ago
parent
commit
b780b69c62

+ 1
- 1
Marlin/src/lcd/dogm/dogm_Statusscreen.h View File

@@ -1094,7 +1094,7 @@
1094 1094
   #define STATUS_SCREEN_BED_TEXT_X 81
1095 1095
 #endif
1096 1096
 #ifndef STATUS_SCREEN_FAN_TEXT_X
1097
-  #define STATUS_SCREEN_FAN_TEXT_X 104
1097
+  #define STATUS_SCREEN_FAN_TEXT_X 103
1098 1098
 #endif
1099 1099
 #ifndef STATUS_SCREEN_FAN_TEXT_Y
1100 1100
   #define STATUS_SCREEN_FAN_TEXT_Y (FAN_ANIM_FRAMES > 2 ? 28 : 27)

+ 18
- 17
Marlin/src/lcd/dogm/status_screen_DOGM.cpp View File

@@ -45,7 +45,7 @@
45 45
 
46 46
 FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t x, const uint8_t y) {
47 47
   const char * const str = itostr3(temp);
48
-  lcd_moveto(x - (str[0] != ' ' ? 0 : str[1] != ' ' ? 1 : 2) * DOG_CHAR_WIDTH / 2, y);
48
+  lcd_moveto(x - (str[0] != ' ' ? 0 : str[1] != ' ' ? 1 : 2) * MENU_FONT_WIDTH / 2, y);
49 49
   lcd_put_u8str(str);
50 50
   lcd_put_u8str_P(PSTR(LCD_STR_DEGREE " "));
51 51
 }
@@ -178,7 +178,7 @@ FORCE_INLINE void lcd_implementation_status_message(const bool blink) {
178 178
           lcd_put_wchar('.');
179 179
           if (--chars) {
180 180
             // Print a second copy of the message
181
-            lcd_put_u8str_max(lcd_status_message, LCD_PIXEL_WIDTH - ((rlen+2) * DOG_CHAR_WIDTH));
181
+            lcd_put_u8str_max(lcd_status_message, LCD_PIXEL_WIDTH - ((rlen+2) * MENU_FONT_WIDTH));
182 182
           }
183 183
         }
184 184
       }
@@ -356,9 +356,9 @@ void lcd_impl_status_screen_0() {
356 356
     //
357 357
 
358 358
     #if DISABLED(DOGM_SD_PERCENT)
359
-      #define SD_DURATION_X (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH / 2) - len * (DOG_CHAR_WIDTH / 2))
359
+      #define SD_DURATION_X (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH / 2) - len * (MENU_FONT_WIDTH / 2))
360 360
     #else
361
-      #define SD_DURATION_X (LCD_PIXEL_WIDTH - len * DOG_CHAR_WIDTH)
361
+      #define SD_DURATION_X (LCD_PIXEL_WIDTH - len * MENU_FONT_WIDTH)
362 362
     #endif
363 363
 
364 364
     if (PAGE_CONTAINS(41, 48)) {
@@ -376,7 +376,7 @@ void lcd_impl_status_screen_0() {
376 376
   // XYZ Coordinates
377 377
   //
378 378
 
379
-  #define XYZ_BASELINE (30 + INFO_FONT_HEIGHT)
379
+  #define XYZ_BASELINE (30 + INFO_FONT_ASCENT)
380 380
 
381 381
   #define X_LABEL_POS  3
382 382
   #define X_VALUE_POS 11
@@ -384,10 +384,10 @@ void lcd_impl_status_screen_0() {
384 384
 
385 385
   #if ENABLED(XYZ_HOLLOW_FRAME)
386 386
     #define XYZ_FRAME_TOP 29
387
-    #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
387
+    #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 3
388 388
   #else
389 389
     #define XYZ_FRAME_TOP 30
390
-    #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 1
390
+    #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 1
391 391
   #endif
392 392
 
393 393
   static char xstring[5], ystring[5], zstring[8];
@@ -419,7 +419,7 @@ void lcd_impl_status_screen_0() {
419 419
       u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT);   // 8: 30-39  7: 30-37
420 420
     #endif
421 421
 
422
-    if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_HEIGHT - 1), XYZ_BASELINE)) {
422
+    if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_ASCENT - 1), XYZ_BASELINE)) {
423 423
 
424 424
       #if DISABLED(XYZ_HOLLOW_FRAME)
425 425
         u8g.setColorIndex(0); // white on black
@@ -449,14 +449,15 @@ void lcd_impl_status_screen_0() {
449 449
   //
450 450
   // Feedrate
451 451
   //
452
+  #define EXTRAS_BASELINE 50
452 453
 
453
-  if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) {
454
+  if (PAGE_CONTAINS(EXTRAS_BASELINE - (INFO_FONT_HEIGHT - 1), EXTRAS_BASELINE)) {
454 455
     lcd_setFont(FONT_MENU);
455
-    lcd_moveto(3, 50);
456
+    lcd_moveto(3, EXTRAS_BASELINE);
456 457
     lcd_put_wchar(LCD_STR_FEEDRATE[0]);
457 458
 
458 459
     lcd_setFont(FONT_STATUSMENU);
459
-    lcd_moveto(12, 50);
460
+    lcd_moveto(12, EXTRAS_BASELINE);
460 461
     lcd_put_u8str(itostr3(feedrate_percentage));
461 462
     lcd_put_wchar('%');
462 463
 
@@ -464,15 +465,15 @@ void lcd_impl_status_screen_0() {
464 465
     // Filament sensor display if SD is disabled
465 466
     //
466 467
     #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
467
-      lcd_moveto(56, 50);
468
+      lcd_moveto(56, EXTRAS_BASELINE);
468 469
       lcd_put_u8str(wstring);
469
-      lcd_moveto(102, 50);
470
+      lcd_moveto(102, EXTRAS_BASELINE);
470 471
       lcd_put_u8str(mstring);
471 472
       lcd_put_wchar('%');
472 473
       lcd_setFont(FONT_MENU);
473
-      lcd_moveto(47, 50);
474
+      lcd_moveto(47, EXTRAS_BASELINE);
474 475
       lcd_put_wchar(LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
475
-      lcd_moveto(93, 50);
476
+      lcd_moveto(93, EXTRAS_BASELINE);
476 477
       lcd_put_wchar(LCD_STR_FILAM_MUL[0]);
477 478
     #endif
478 479
   }
@@ -481,9 +482,9 @@ void lcd_impl_status_screen_0() {
481 482
   // Status line
482 483
   //
483 484
 
484
-  #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
485
+  #define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
485 486
 
486
-  if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_HEIGHT - 1), STATUS_BASELINE)) {
487
+  if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_ASCENT - 1), STATUS_BASELINE)) {
487 488
     lcd_moveto(0, STATUS_BASELINE);
488 489
 
489 490
     #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)

+ 56
- 59
Marlin/src/lcd/dogm/ultralcd_impl_DOGM.cpp View File

@@ -60,18 +60,14 @@
60 60
   #include "../../feature/bedlevel/ubl/ubl.h"
61 61
 #endif
62 62
 
63
-#define FONT_SPECIAL_NAME ISO10646_1_5x7
64
-#define FONT_MENU_NAME ISO10646_1_5x7
65 63
 #include "fontdata/fontdata_ISO10646_1.h"
66 64
 #if ENABLED(USE_SMALL_INFOFONT)
67 65
   #include "fontdata/fontdata_6x9_marlin.h"
68 66
   #define FONT_STATUSMENU_NAME u8g_font_6x9
69 67
 #else
70
-  #define FONT_STATUSMENU_NAME FONT_MENU_NAME
68
+  #define FONT_STATUSMENU_NAME MENU_FONT_NAME
71 69
 #endif
72 70
 
73
-#define START_COL 0
74
-
75 71
 U8G_CLASS u8g(U8G_PARAM);
76 72
 U8GLIB *pu8g = &u8g;
77 73
 
@@ -93,10 +89,9 @@ void lcd_setFont(const MarlinFont font_nr) {
93 89
   if (font_nr != currentfont) {
94 90
     switch ((currentfont = font_nr)) {
95 91
       case FONT_STATUSMENU : u8g.setFont(FONT_STATUSMENU_NAME); break;
92
+      case FONT_EDIT       : u8g.setFont(EDIT_FONT_NAME);       break;
96 93
       default:
97
-      case FONT_MENU       : u8g.setFont(FONT_MENU_NAME);       break;
98
-      case FONT_SPECIAL    : u8g.setFont(FONT_SPECIAL_NAME);    break;
99
-      case FONT_MENU_EDIT  : u8g.setFont(FONT_MENU_EDIT_NAME);  break;
94
+      case FONT_MENU       : u8g.setFont(MENU_FONT_NAME);       break;
100 95
     }
101 96
   }
102 97
 }
@@ -155,7 +150,7 @@ void lcd_setFont(const MarlinFont font_nr) {
155 150
       #if ENABLED(START_BMPHIGH)
156 151
         (LCD_PIXEL_HEIGHT - (START_BMPHEIGHT)) / 2
157 152
       #else
158
-        DOG_CHAR_HEIGHT
153
+        MENU_FONT_HEIGHT
159 154
       #endif
160 155
     ;
161 156
 
@@ -167,13 +162,13 @@ void lcd_setFont(const MarlinFont font_nr) {
167 162
       u8g.drawBitmapP(offx, offy, (START_BMPWIDTH + 7) / 8, START_BMPHEIGHT, start_bmp);
168 163
       lcd_setFont(FONT_MENU);
169 164
       #ifndef STRING_SPLASH_LINE2
170
-        const uint8_t txt1X = width - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH);
171
-        u8g.drawStr(txt1X, (height + DOG_CHAR_HEIGHT) / 2, STRING_SPLASH_LINE1);
165
+        const uint8_t txt1X = width - (sizeof(STRING_SPLASH_LINE1) - 1) * (MENU_FONT_WIDTH);
166
+        u8g.drawStr(txt1X, (height + MENU_FONT_HEIGHT) / 2, STRING_SPLASH_LINE1);
172 167
       #else
173
-        const uint8_t txt1X = (width - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2,
174
-                      txt2X = (width - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
175
-        u8g.drawStr(txt1X, height - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
176
-        u8g.drawStr(txt2X, height - (DOG_CHAR_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
168
+        const uint8_t txt1X = (width - (sizeof(STRING_SPLASH_LINE1) - 1) * (MENU_FONT_WIDTH)) / 2,
169
+                      txt2X = (width - (sizeof(STRING_SPLASH_LINE2) - 1) * (MENU_FONT_WIDTH)) / 2;
170
+        u8g.drawStr(txt1X, height - (MENU_FONT_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
171
+        u8g.drawStr(txt2X, height - (MENU_FONT_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
177 172
       #endif
178 173
     } while (u8g.nextPage());
179 174
     safe_delay(BOOTSCREEN_TIMEOUT);
@@ -252,12 +247,12 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
252 247
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
253 248
 
254 249
     void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder) {
255
-      row_y1 = row * (DOG_CHAR_HEIGHT) + 1;
256
-      row_y2 = row_y1 + DOG_CHAR_HEIGHT - 1;
250
+      row_y1 = row * (MENU_FONT_HEIGHT) + 1;
251
+      row_y2 = row_y1 + MENU_FONT_HEIGHT - 1;
257 252
 
258 253
       if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return;
259 254
 
260
-      lcd_moveto(LCD_PIXEL_WIDTH - 11 * (DOG_CHAR_WIDTH), row_y2);
255
+      lcd_moveto(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), row_y2);
261 256
       lcd_put_wchar('E');
262 257
       lcd_put_wchar((char)('1' + extruder));
263 258
       lcd_put_wchar(' ');
@@ -272,8 +267,8 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
272 267
 
273 268
   // Set the colors for a menu item based on whether it is selected
274 269
   static bool mark_as_selected(const uint8_t row, const bool isSelected) {
275
-    row_y1 = row * (DOG_CHAR_HEIGHT) + 1;
276
-    row_y2 = row_y1 + DOG_CHAR_HEIGHT - 1;
270
+    row_y1 = row * (MENU_FONT_HEIGHT) + 1;
271
+    row_y2 = row_y1 + MENU_FONT_HEIGHT - 1;
277 272
 
278 273
     if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return false;
279 274
 
@@ -283,7 +278,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
283 278
         u8g.drawHLine(0, row_y2 + 2, LCD_PIXEL_WIDTH);
284 279
       #else
285 280
         u8g.setColorIndex(1); // black on white
286
-        u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT - 1);
281
+        u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, MENU_FONT_HEIGHT - 1);
287 282
         u8g.setColorIndex(0); // white on black
288 283
       #endif
289 284
     }
@@ -295,7 +290,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
295 290
 
296 291
     if (!PAGE_CONTAINS(row_y1, row_y2)) return false;
297 292
 
298
-    lcd_moveto((START_COL) * (DOG_CHAR_WIDTH), row_y2);
293
+    lcd_moveto(0, row_y2);
299 294
     return true;
300 295
   }
301 296
 
@@ -304,7 +299,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
304 299
 
305 300
     if (mark_as_selected(row, invert)) {
306 301
 
307
-      uint8_t n = LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * (START_COL); // pixel width of string allowed
302
+      uint8_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
308 303
 
309 304
       if (center && !valstr) {
310 305
         int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2;
@@ -315,7 +310,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
315 310
         n -= lcd_put_u8str_max(valstr, n);
316 311
       }
317 312
 
318
-      while (n - DOG_CHAR_WIDTH > 0) { n -= lcd_put_wchar(' '); }
313
+      while (n - MENU_FONT_WIDTH > 0) { n -= lcd_put_wchar(' '); }
319 314
     }
320 315
   }
321 316
 
@@ -324,11 +319,11 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
324 319
     UNUSED(pre_char);
325 320
 
326 321
     if (mark_as_selected(row, isSelected)) {
327
-      uint8_t n = LCD_WIDTH - (START_COL) - 2;
328
-      n *= DOG_CHAR_WIDTH;
322
+      uint8_t n = LCD_WIDTH - 2;
323
+      n *= MENU_FONT_WIDTH;
329 324
       n -= lcd_put_u8str_max_P(pstr, n);
330
-      while (n - DOG_CHAR_WIDTH > 0) { n -= lcd_put_wchar(' '); }
331
-      lcd_moveto(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH), row_y2);
325
+      while (n - MENU_FONT_WIDTH > 0) { n -= lcd_put_wchar(' '); }
326
+      lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2);
332 327
       lcd_put_wchar(post_char);
333 328
       lcd_put_wchar(' ');
334 329
     }
@@ -338,60 +333,62 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
338 333
   void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) {
339 334
     if (mark_as_selected(row, isSelected)) {
340 335
       const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data));
341
-      uint8_t n = LCD_WIDTH - (START_COL) - 2 - vallen;
342
-      n *= DOG_CHAR_WIDTH;
336
+      uint8_t n = LCD_WIDTH - 2 - vallen;
337
+      n *= MENU_FONT_WIDTH;
343 338
       n -= lcd_put_u8str_max_P(pstr, n);
344 339
       lcd_put_wchar(':');
345
-      while (n - DOG_CHAR_WIDTH > 0) { n -= lcd_put_wchar(' '); }
346
-      lcd_moveto(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * vallen, row_y2);
340
+      while (n - MENU_FONT_WIDTH > 0) { n -= lcd_put_wchar(' '); }
341
+      lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH) * vallen, row_y2);
347 342
       if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str((char*)data);
348 343
     }
349 344
   }
350 345
 
351 346
   void lcd_implementation_drawedit(PGM_P const pstr, const char* const value/*=NULL*/) {
352
-    const uint8_t labellen = utf8_strlen_P(pstr),
353
-                  vallen = utf8_strlen(value);
347
+    const uint8_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value);
354 348
 
355
-    uint8_t rows = (labellen > LCD_WIDTH - 2 - vallen) ? 2 : 1;
349
+    bool extra_row = labellen > LCD_WIDTH - 2 - vallen;
356 350
 
357 351
     #if ENABLED(USE_BIG_EDIT_FONT)
358
-      constexpr uint8_t lcd_width_edit = (LCD_PIXEL_WIDTH) / (DOG_CHAR_WIDTH_EDIT);
359
-
360
-      uint8_t lcd_width, char_width;
361
-      if (labellen <= lcd_width_edit - 1) {
362
-        if (labellen + vallen + 2 >= lcd_width_edit) rows = 2;
363
-        lcd_width = lcd_width_edit + 1;
364
-        char_width = DOG_CHAR_WIDTH_EDIT;
365
-        lcd_setFont(FONT_MENU_EDIT);
352
+      // Use the menu font if the label won't fit on a single line
353
+      constexpr uint8_t lcd_edit_width = (LCD_PIXEL_WIDTH) / (EDIT_FONT_WIDTH);
354
+      uint8_t lcd_chr_fit, one_chr_width;
355
+      if (labellen <= lcd_edit_width - 1) {
356
+        if (labellen + vallen + 1 > lcd_edit_width) extra_row = true;
357
+        lcd_chr_fit = lcd_edit_width + 1;
358
+        one_chr_width = EDIT_FONT_WIDTH;
359
+        lcd_setFont(FONT_EDIT);
366 360
       }
367 361
       else {
368
-        lcd_width = LCD_WIDTH - (START_COL);
369
-        char_width = DOG_CHAR_WIDTH;
362
+        lcd_chr_fit = LCD_WIDTH;
363
+        one_chr_width = MENU_FONT_WIDTH;
370 364
         lcd_setFont(FONT_MENU);
371 365
       }
372 366
     #else
373
-      constexpr uint8_t lcd_width = LCD_WIDTH - (START_COL),
374
-                        char_width = DOG_CHAR_WIDTH;
367
+      constexpr uint8_t lcd_chr_fit = LCD_WIDTH,
368
+                        one_chr_width = MENU_FONT_WIDTH;
375 369
     #endif
376 370
 
377
-    // Center either one or two rows
378
-    const uint8_t segmentHeight = u8g.getHeight() / (rows + 1); // 1 / (rows+1) = 1/2 or 1/3
379
-    uint8_t baseline = segmentHeight + (DOG_CHAR_HEIGHT_EDIT + 1) / 2;
371
+    // Center the label and value lines on the middle line
372
+    uint8_t baseline = extra_row ? (LCD_PIXEL_HEIGHT) / 2
373
+                                 : (LCD_PIXEL_HEIGHT + EDIT_FONT_ASCENT) / 2;
380 374
 
381
-    bool onpage = PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline);
375
+    // Assume the label is alpha-numeric (with a descender)
376
+    bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT);
382 377
     if (onpage) {
383 378
       lcd_moveto(0, baseline);
384 379
       lcd_put_u8str_P(pstr);
385 380
     }
386 381
 
382
+    // If a value is included, print a colon, then print the value right-justified
387 383
     if (value != NULL) {
388 384
       lcd_put_wchar(':');
389
-      if (rows == 2) {
390
-        baseline += segmentHeight;
391
-        onpage = PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline);
385
+      if (extra_row) {
386
+        // Assume the value is numeric (with no descender)
387
+        baseline += EDIT_FONT_ASCENT;
388
+        onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline);
392 389
       }
393 390
       if (onpage) {
394
-        lcd_moveto(((lcd_width - 1) - (vallen + 1)) * char_width, baseline); // Right-justified, leaving padded by spaces
391
+        lcd_moveto(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces
395 392
         lcd_put_wchar(' '); // overwrite char if value gets shorter
396 393
         lcd_put_u8str(value);
397 394
       }
@@ -407,7 +404,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
407 404
 
408 405
       if (!PAGE_CONTAINS(row_y1, row_y2)) return;
409 406
 
410
-      constexpr uint8_t maxlen = LCD_WIDTH - (START_COL) - 1;
407
+      constexpr uint8_t maxlen = LCD_WIDTH - 1;
411 408
       const char *outstr = theCard.longest_filename();
412 409
       if (theCard.longFilename[0]) {
413 410
         #if ENABLED(SCROLL_LONG_FILENAMES)
@@ -432,9 +429,9 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
432 429
       if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]);
433 430
 
434 431
       int n;
435
-      n = lcd_put_u8str_max(outstr, maxlen * (DOG_CHAR_WIDTH));
436
-      n = maxlen * (DOG_CHAR_WIDTH) - n;
437
-      while (n - DOG_CHAR_WIDTH > 0) { n -= lcd_put_wchar(' '); }
432
+      n = lcd_put_u8str_max(outstr, maxlen * (MENU_FONT_WIDTH));
433
+      n = maxlen * (MENU_FONT_WIDTH) - n;
434
+      while (n - MENU_FONT_WIDTH > 0) { n -= lcd_put_wchar(' '); }
438 435
     }
439 436
 
440 437
   #endif // SDSUPPORT

+ 35
- 27
Marlin/src/lcd/ultralcd.h View File

@@ -132,25 +132,9 @@
132 132
   #include "dogm/HAL_LCD_class_defines.h"
133 133
   extern U8G_CLASS u8g;
134 134
 
135
-  // DOGM font sizes
136
-  #define DOG_CHAR_WIDTH         6
137
-  #define DOG_CHAR_HEIGHT        12
138
-  #if ENABLED(USE_BIG_EDIT_FONT)
139
-    #define FONT_MENU_EDIT_NAME u8g_font_9x18
140
-    #define DOG_CHAR_WIDTH_EDIT  9
141
-    #define DOG_CHAR_HEIGHT_EDIT 18
142
-  #else
143
-    #define FONT_MENU_EDIT_NAME FONT_MENU_NAME
144
-    #define DOG_CHAR_WIDTH_EDIT  DOG_CHAR_WIDTH
145
-    #define DOG_CHAR_HEIGHT_EDIT DOG_CHAR_HEIGHT
146
-  #endif
147
-
148
-  enum MarlinFont : uint8_t {
149
-    FONT_STATUSMENU = 1,
150
-    FONT_SPECIAL,
151
-    FONT_MENU_EDIT,
152
-    FONT_MENU,
153
-  };
135
+  // For selective rendering within a Y range
136
+  #define PAGE_UNDER(yb) (u8g.getU8g()->current_page.y0 <= (yb))
137
+  #define PAGE_CONTAINS(ya, yb) (PAGE_UNDER(yb) && u8g.getU8g()->current_page.y1 >= (ya))
154 138
 
155 139
   // Only Western languages support big / small fonts
156 140
   #if DISABLED(DISPLAY_CHARSET_ISO10646_1)
@@ -158,17 +142,41 @@
158 142
     #undef USE_SMALL_INFOFONT
159 143
   #endif
160 144
 
145
+  #define MENU_FONT_NAME    ISO10646_1_5x7
146
+  #define MENU_FONT_WIDTH    6
147
+  #define MENU_FONT_ASCENT  10
148
+  #define MENU_FONT_DESCENT  2
149
+  #define MENU_FONT_HEIGHT  (MENU_FONT_ASCENT + MENU_FONT_DESCENT)
150
+
151
+  #if ENABLED(USE_BIG_EDIT_FONT)
152
+    #define EDIT_FONT_NAME    u8g_font_9x18
153
+    #define EDIT_FONT_WIDTH    9
154
+    #define EDIT_FONT_ASCENT  10
155
+    #define EDIT_FONT_DESCENT  3
156
+  #else
157
+    #define EDIT_FONT_NAME    MENU_FONT_NAME
158
+    #define EDIT_FONT_WIDTH   MENU_FONT_WIDTH
159
+    #define EDIT_FONT_ASCENT  MENU_FONT_ASCENT
160
+    #define EDIT_FONT_DESCENT MENU_FONT_DESCENT
161
+  #endif
162
+  #define EDIT_FONT_HEIGHT (EDIT_FONT_ASCENT + EDIT_FONT_DESCENT)
163
+
164
+  // Get the Ascent, Descent, and total Height for the Info Screen font
161 165
   #if ENABLED(USE_SMALL_INFOFONT)
162 166
     extern const u8g_fntpgm_uint8_t u8g_font_6x9[];
163
-    #define INFO_FONT_HEIGHT 7
167
+    #define INFO_FONT_ASCENT 7
164 168
   #else
165
-    #define INFO_FONT_HEIGHT 8
169
+    #define INFO_FONT_ASCENT 8
166 170
   #endif
171
+  #define INFO_FONT_DESCENT 2
172
+  #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
167 173
 
168
-  // For selective rendering within a Y range
169
-  #define PAGE_UNDER(yb) (u8g.getU8g()->current_page.y0 <= (yb))
170
-  #define PAGE_CONTAINS(ya, yb) (PAGE_UNDER(yb) && u8g.getU8g()->current_page.y1 >= (ya))
171
-
174
+  // Font IDs
175
+  enum MarlinFont : uint8_t {
176
+    FONT_STATUSMENU = 1,
177
+    FONT_EDIT,
178
+    FONT_MENU
179
+  };
172 180
   void lcd_setFont(const MarlinFont font_nr);
173 181
 
174 182
   #if ENABLED(LIGHTWEIGHT_UI)
@@ -251,8 +259,8 @@
251 259
   #endif
252 260
 
253 261
   #if HAS_GRAPHICAL_LCD
254
-    #define SETCURSOR(col, row) lcd_moveto(col * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT))
255
-    #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - len * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT))
262
+    #define SETCURSOR(col, row) lcd_moveto(col * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
263
+    #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - len * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
256 264
   #else
257 265
     #define SETCURSOR(col, row) lcd_moveto(col, row)
258 266
     #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_WIDTH - len, row)

Loading…
Cancel
Save