Browse Source

Fix u8g.h search path error (#10419)

Support env MARLIN_LANGS for user select generated language, and update doc; update script to generate dogm_font_data_ISO10646_1.h automatically.
Yunhui Fu 6 years ago
parent
commit
93273a4c9e

+ 4
- 0
.travis.yml View File

@@ -44,6 +44,10 @@ before_script:
44 44
   #
45 45
 script:
46 46
   #
47
+  # Fix include path problem in platformio.ini, U8glib-HAL_ID1932/src/lib/u8g.h
48
+  #
49
+  - find Marlin/ -name "*.h" | while read a; do sed -e 's|clib/u8g.h|u8g.h|' -i "$a"; done
50
+  #
47 51
   # Backup pins_RAMPS.h
48 52
   #
49 53
   - cp Marlin/src/pins/pins_RAMPS.h Marlin/src/pins/pins_RAMPS.h.backup

+ 3
- 4
Marlin/src/lcd/u8g_fontutf8.c View File

@@ -8,7 +8,6 @@
8 8
  */
9 9
 
10 10
 #include <string.h>
11
-#include <clib/u8g.h>
12 11
 #include "fontutils.h"
13 12
 #include "u8g_fontutf8.h"
14 13
 
@@ -216,7 +215,7 @@ unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t
216 215
   const font_t *fnt_default = uxg_GetFont(pu8g);
217 216
 
218 217
   if (!uxg_Utf8FontIsInited()) {
219
-    u8g_DrawStrP(pu8g, x, y, PSTR("Err: utf8 font not initialized."));
218
+    u8g_DrawStrP(pu8g, x, y, (const u8g_pgm_uint8_t *)PSTR("Err: utf8 font not initialized."));
220 219
     return 0;
221 220
   }
222 221
   data.pu8g = pu8g;
@@ -250,7 +249,7 @@ unsigned int uxg_DrawUtf8Str(u8g_t *pu8g, unsigned int x, unsigned int y, const
250 249
   const font_t *fnt_default = uxg_GetFont(pu8g);
251 250
 
252 251
   if (!uxg_Utf8FontIsInited()) {
253
-    u8g_DrawStrP(pu8g, x, y, PSTR("Err: utf8 font not initialized."));
252
+    u8g_DrawStrP(pu8g, x, y, (const u8g_pgm_uint8_t *)PSTR("Err: utf8 font not initialized."));
254 253
     return 0;
255 254
   }
256 255
   data.pu8g = pu8g;
@@ -285,7 +284,7 @@ unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, const
285 284
 
286 285
   if (!uxg_Utf8FontIsInited()) {
287 286
     TRACE("Error, utf8string not inited!");
288
-    u8g_DrawStrP(pu8g, x, y, PSTR("Err: utf8 font not initialized."));
287
+    u8g_DrawStrP(pu8g, x, y, (const u8g_pgm_uint8_t *)PSTR("Err: utf8 font not initialized."));
289 288
     return 0;
290 289
   }
291 290
   data.pu8g = pu8g;

+ 42
- 7
buildroot/share/fonts/genallfont.sh View File

@@ -37,16 +37,13 @@ EXEC_BDF2U8G=`which bdf2u8g`
37 37
 echo "0 set EXEC_BDF2U8G=$EXEC_BDF2U8G"
38 38
 if [ ! -x "${EXEC_BDF2U8G}" ]; then
39 39
     EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g"
40
-echo "1 set EXEC_BDF2U8G=$EXEC_BDF2U8G"
41 40
 fi
42 41
 if [ ! -x "${EXEC_BDF2U8G}" ]; then
43 42
     EXEC_BDF2U8G="${PWD}/bdf2u8g"
44
-echo "2 set EXEC_BDF2U8G=$EXEC_BDF2U8G"
45 43
 fi
46 44
 if [ ! -x "${EXEC_BDF2U8G}" ]; then
47
-  echo "Not found bdf2u8g!"
48
-  echo "plaese compile u8blib/tools/font/bdf2u8g/bdf2u8g and link to it from here!"
49
-
45
+  echo "ERR: Not found bdf2u8g!" >&2
46
+  echo "plaese compile u8blib/tools/font/bdf2u8g/bdf2u8g and link to it from here!" >&2
50 47
   exit 1
51 48
 fi
52 49
 
@@ -59,17 +56,55 @@ DN_WORK=./tmp1
59 56
 
60 57
 (cd ${DN_EXEC}; gcc -o genpages genpages.c getline.c)
61 58
 
62
-LANGS="an bg ca zh_CN zh_TW cz da de el el-gr en es eu fi fr gl hr it jp-kana nl pl pt pt-br ru sk tr uk test"
59
+LANGS_DEFAULT="an bg ca zh_CN zh_TW cz da de el el-gr en es eu fi fr gl hr it jp-kana nl pl pt pt-br ru sk tr uk test"
60
+
61
+for LANG in ${MARLIN_LANGS:=$LANGS_DEFAULT} ; do
62
+    echo "INFO: generate Marlin language data for '${LANG}'" >&2
63 63
 
64
-for LANG in ${LANGS} ; do
65 64
     rm -rf ${DN_WORK}/
66 65
     mkdir -p ${DN_WORK}
67 66
     cp Configuration.h    ${DN_WORK}/
68 67
     cp src/lcd/language/language_${LANG}.h ${DN_WORK}/
69 68
     cd ${DN_WORK}/
70 69
     ${EXEC_WXGGEN} "${FN_NEWFONT}"
70
+    sed -e 's|fonts//|fonts/|g' -e 's|fonts//|fonts/|g' -e 's|[/0-9a-zA-Z_\-]*buildroot/share/fonts|buildroot/share/fonts|' -i fontutf8-data.h
71 71
     cd ../
72 72
     mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/language_data_${LANG}.h
73 73
     rm -rf ${DN_WORK}/
74 74
 done
75 75
 
76
+
77
+# generate default ASCII font (char range 0-255):
78
+#   Marlin/src/lcd/dogm/dogm_font_data_ISO10646_1.h
79
+#if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then
80
+if [ 1 = 1 ]; then
81
+    rm -rf ${DN_WORK}/
82
+    mkdir -p ${DN_WORK}
83
+    cd ${DN_WORK}/
84
+    ${EXEC_BDF2U8G} -b 1 -e 127 ${FN_NEWFONT} ISO10646_1_5x7 tmp1.h
85
+    ${EXEC_BDF2U8G} -b 1 -e 255 ${FN_NEWFONT} ISO10646_1_5x7 tmp2.h
86
+
87
+    cat << EOF >tmp3.h
88
+#include <U8glib.h>
89
+
90
+#if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7)
91
+  // reduced font (only sysmbols 1 - 127) - saves about 1278 bytes of FLASH
92
+
93
+EOF
94
+    cat tmp1.h >>tmp3.h
95
+    cat << EOF >>tmp3.h
96
+#else
97
+  // extended (original) font (sysmbols 1 - 255)
98
+EOF
99
+    cat tmp2.h >>tmp3.h
100
+    cat << EOF >>tmp3.h
101
+
102
+#endif
103
+EOF
104
+    sed -e 's|#include "u8g.h"|#include <clib/u8g.h>|' -i tmp3.h
105
+
106
+    cd ..
107
+    mv ${DN_WORK}/tmp3.h src/lcd/dogm/dogm_font_data_ISO10646_1.h
108
+fi
109
+
110
+

+ 10
- 6
buildroot/share/fonts/uxggenpages.md View File

@@ -3,7 +3,7 @@
3 3
 ### Supported hardware
4 4
 
5 5
 Marlin supports HD44780 character LCD and 128x64 graphical LCD via U8GLIB.
6
-Because of the limitation of HD44780 hardware, Marlin can only support three
6
+Because of the limitation of HD44780 hardwares, Marlin can only support three
7 7
 character sets for that hardware:
8 8
 Japanese (kana_utf8), Russian/Cyrillic (ru), or Western (Roman characters)
9 9
 
@@ -61,18 +61,19 @@ ln -s u8glib-master/tools/font/bdf2u8g/bdf2u8g
61 61
 ```
62 62
 
63 63
 The 'genallfont.sh' script will generate the font data for all of the
64
-language translation files. You may edit the script to change the variable
65
-LANGS to the list of languages you want to process. For example:
64
+language translation files.
65
+
66
+You may specify the language list you want to process. For example:
66 67
 
67 68
 ```bash
68
-LANGS="zh_TW"
69
+MARLIN_LANGS="zh_CN zh_TW"
69 70
 ```
70 71
 
71
-and then run the script to generate the font data (`language_data_xx.h`):
72
+and run the script to generate the font data (`language_data_xx.h`):
72 73
 
73 74
 ```bash
74 75
 cd marlin-git/Marlin/
75
-../buildroot/share/fonts/genallfont.sh
76
+MARLIN_LANGS="zh_CN zh_TW" ../buildroot/share/fonts/genallfont.sh
76 77
 ```
77 78
 
78 79
 3. Change the language settings
@@ -108,6 +109,9 @@ example, your new font file name is `newfont.bdf`, then run the following comman
108 109
 ```bash
109 110
 cd Marlin/
110 111
 ../buildroot/share/fonts/genallfont.sh ./newfont.bdf
112
+
113
+# OR if you just want to regenerate the language font data for a specific language:
114
+MARLIN_LANGS="zh_TW" ../buildroot/share/fonts/genallfont.sh ./newfont.bdf
111 115
 ```
112 116
 
113 117
 ### Suggestions for Maintainers

+ 1
- 1
buildroot/share/fonts/uxggenpages.sh View File

@@ -143,7 +143,7 @@ grep -Hrn _UxGT . | grep '"' | \
143 143
   while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
144 144
     if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \
145 145
       ${EXEC_BDF2U8G} -u ${PAGE} -b ${BEGIN} -e ${END} ${FN_FONT} fontpage_${PAGE}_${BEGIN}_${END} ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h > /dev/null 2>&1 ;
146
-      #sed -i 's|#include "u8g.h"|#include "utility/u8g.h"|' ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ;
146
+      #sed -i 's|#include "u8g.h"|#include <clib/u8g.h>|' ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ;
147 147
     fi ;\
148 148
     grep -A 10000000000 u8g_fntpgm_uint8_t ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h >> tmpa ;\
149 149
     echo "    FONTDATA_ITEM(${PAGE}, ${BEGIN}, ${END}, fontpage_${PAGE}_${BEGIN}_${END}), // '${UTF8BEGIN}' -- '${UTF8END}'" >> tmpb ;\

Loading…
Cancel
Save