Selaa lähdekoodia

Updates to font scripts and fonts documentation

Scott Lahteine 6 vuotta sitten
vanhempi
commit
dde941cac8

+ 60
- 55
buildroot/share/fonts/genallfont.sh Näytä tiedosto

@@ -3,12 +3,12 @@
3 3
 #####################################################################
4 4
 # genallfont.sh for Marlin
5 5
 #
6
-# This script will generates font data for language headers
6
+# This script generates font data for language headers
7 7
 #
8
-# Copyright 2015-2016 Yunhui Fu <yhfudev@gmail.com>
8
+# Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com>
9 9
 # License: GPL/BSD
10 10
 #####################################################################
11
-my_getpath () {
11
+my_getpath() {
12 12
   local PARAM_DN="$1"
13 13
   shift
14 14
   #readlink -f
@@ -21,37 +21,22 @@ my_getpath () {
21 21
   cd "${DN}" > /dev/null 2>&1
22 22
   DN=$(pwd)
23 23
   cd - > /dev/null 2>&1
24
-  echo "${DN}/${FN}"
24
+  echo -n "${DN}"
25
+  [[ -z "$FN" ]] || echo -n "/${FN}"
25 26
 }
26 27
 #DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'`
27 28
 DN_EXEC=$(dirname $(my_getpath "$0") )
28
-if [ ! "${DN_EXEC}" = "" ]; then
29
-    DN_EXEC="$(my_getpath "${DN_EXEC}")/"
30
-else
31
-    DN_EXEC="${DN_EXEC}/"
32
-fi
33
-#####################################################################
29
+
34 30
 EXEC_WXGGEN="${DN_EXEC}/uxggenpages.sh"
35 31
 
36 32
 EXEC_BDF2U8G=`which bdf2u8g`
37
-echo "0 set EXEC_BDF2U8G=$EXEC_BDF2U8G"
38
-if [ ! -x "${EXEC_BDF2U8G}" ]; then
39
-    EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g"
40
-fi
41
-if [ ! -x "${EXEC_BDF2U8G}" ]; then
42
-    EXEC_BDF2U8G="${PWD}/bdf2u8g"
43
-fi
44
-if [ ! -x "${EXEC_BDF2U8G}" ]; then
45
-  echo "ERR: Not found bdf2u8g!" >&2
46
-  echo "plaese compile u8blib/tools/font/bdf2u8g/bdf2u8g and link to it from here!" >&2
47
-  exit 1
48
-fi
33
+[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g"
34
+[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${PWD}/bdf2u8g"
35
+[ -x "${EXEC_BDF2U8G}" ] || { EOL=$'\n' ; echo "ERR: Can't find bdf2u8g!${EOL}See uxggenpages.md for bdf2u8g build instructions." >&2 ; exit 1; }
49 36
 
50 37
 #FN_FONT="${1:-}"
51 38
 FN_FONT="${DN_EXEC}/marlin-6x12-3.bdf"
52
-if [ ! "$1" = "" ]; then
53
-  FN_FONT="$1"
54
-fi
39
+[ "$1" = "" ] || FN_FONT="$1"
55 40
 
56 41
 DN_FONT0=`dirname ${FN_FONT}`
57 42
 DN_FONT="$(my_getpath  ${DN_FONT0})"
@@ -61,7 +46,7 @@ FN_FONT="$(my_getpath "${DN_FONT}")/"`basename ${FN_FONT}`
61 46
 [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/wenquanyi/${FN_FONT_BASE}.bdf"
62 47
 [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/X11/misc/${FN_FONT_BASE}.bdf"
63 48
 [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/misc/${FN_FONT_BASE}.bdf"
64
-echo "genallfont.sh: FN_FONT=${FN_FONT}"
49
+#echo "genallfont.sh: FN_FONT=${FN_FONT}"
65 50
 
66 51
 DN_WORK=./tmp1
67 52
 
@@ -70,49 +55,69 @@ DN_WORK=./tmp1
70 55
 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"
71 56
 
72 57
 for LANG in ${MARLIN_LANGS:=$LANGS_DEFAULT} ; do
73
-    echo "INFO: generate Marlin language data for '${LANG}'" >&2
74
-
75
-    rm -rf ${DN_WORK}/
76
-    mkdir -p ${DN_WORK}
77
-    cp Configuration.h    ${DN_WORK}/
78
-    cp src/lcd/language/language_${LANG}.h ${DN_WORK}/
79
-    cd ${DN_WORK}/
80
-    ${EXEC_WXGGEN} "${FN_FONT}"
81
-    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
82
-    cd ../
83
-    mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/language_data_${LANG}.h
84
-    rm -rf ${DN_WORK}/
58
+  echo "Generating Marlin language data for '${LANG}'" >&2
59
+  rm -rf ${DN_WORK}/
60
+  mkdir -p ${DN_WORK}
61
+  cp Configuration.h ${DN_WORK}/
62
+  cp src/lcd/language/language_${LANG}.h ${DN_WORK}/
63
+  cd ${DN_WORK}/
64
+  ${EXEC_WXGGEN} "${FN_FONT}"
65
+  sed -i fontutf8-data.h -e 's|fonts//|fonts/|g' -e 's|fonts//|fonts/|g' -e 's|[/0-9a-zA-Z_\-]*buildroot/share/fonts|buildroot/share/fonts|' 2>/dev/null
66
+  cd ../
67
+  mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/language_data_${LANG}.h
68
+  rm -rf ${DN_WORK}/
85 69
 done
86 70
 
87
-
88
-# generate default ASCII font (char range 0-255):
71
+#
72
+# Generate default ASCII font (char range 0-255):
89 73
 #   Marlin/src/lcd/dogm/dogm_font_data_ISO10646_1.h
74
+#
90 75
 #if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then
91 76
 if [ 1 = 1 ]; then
92
-    rm -rf ${DN_WORK}/
93
-    mkdir -p ${DN_WORK}
94
-    cd ${DN_WORK}/
95
-    ${EXEC_BDF2U8G} -b 1 -e 127 ${FN_FONT} ISO10646_1_5x7 tmp1.h
96
-    ${EXEC_BDF2U8G} -b 1 -e 255 ${FN_FONT} ISO10646_1_5x7 tmp2.h
97
-
98
-    cat << EOF >tmp3.h
77
+  rm -rf ${DN_WORK}/
78
+  mkdir -p ${DN_WORK}
79
+  cd ${DN_WORK}/
80
+  ${EXEC_BDF2U8G} -b 1 -e 127 ${FN_FONT} ISO10646_1_5x7 tmp1.h >/dev/null
81
+  ${EXEC_BDF2U8G} -b 1 -e 255 ${FN_FONT} ISO10646_1_5x7 tmp2.h >/dev/null
82
+  TMP1=$(cat tmp1.h) ; rm tmp1.h
83
+  TMP2=$(cat tmp2.h) ; rm tmp2.h
84
+
85
+  cat <<EOF >../src/lcd/dogm/dogm_font_data_ISO10646_1.h
86
+/**
87
+ * Marlin 3D Printer Firmware
88
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
89
+ *
90
+ * Based on Sprinter and grbl.
91
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
92
+ *
93
+ * This program is free software: you can redistribute it and/or modify
94
+ * it under the terms of the GNU General Public License as published by
95
+ * the Free Software Foundation, either version 3 of the License, or
96
+ * (at your option) any later version.
97
+ *
98
+ * This program is distributed in the hope that it will be useful,
99
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
100
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
101
+ * GNU General Public License for more details.
102
+ *
103
+ * You should have received a copy of the GNU General Public License
104
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
105
+ *
106
+ */
99 107
 #include <U8glib.h>
100 108
 
101 109
 #if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7)
102 110
   // reduced font (only symbols 1 - 127) - saves about 1278 bytes of FLASH
103 111
 
104
-EOF
105
-    cat tmp1.h >>tmp3.h
106
-    cat << EOF >>tmp3.h
112
+$TMP1
107 113
 #else
108 114
   // extended (original) font (symbols 1 - 255)
109
-EOF
110
-    cat tmp2.h >>tmp3.h
111
-    cat << EOF >>tmp3.h
115
+
116
+$TMP2
112 117
 
113 118
 #endif
114 119
 EOF
115 120
 
116
-    cd ..
117
-    mv ${DN_WORK}/tmp3.h src/lcd/dogm/dogm_font_data_ISO10646_1.h
121
+  rmdir ../${DN_WORK}
122
+  cd - >/dev/null
118 123
 fi

+ 31
- 0
buildroot/share/fonts/get-bdf2u8g.sh Näytä tiedosto

@@ -0,0 +1,31 @@
1
+#!/usr/bin/env bash
2
+
3
+#####################################################################
4
+# get-bdf2u8g.sh for Marlin
5
+#
6
+# This script downloads, patches, and builds bdf2u8g
7
+# License: CC-SA
8
+#
9
+# Execute from within buildroot/share/fonts
10
+#
11
+#####################################################################
12
+
13
+HERE=$(pwd)
14
+
15
+[[ $HERE =~ 'buildroot/share/fonts'$ ]] || { echo "Change to buildroot/share/fonts to run $(basename $0)" ; exit 1; }
16
+
17
+# Download u8glib
18
+curl -LJO https://github.com/olikraus/u8glib/archive/master.zip
19
+unzip u8glib-master.zip >/dev/null 2>&1
20
+
21
+# Patch and build bdf2u8g
22
+cd u8glib-master/tools/font/bdf2u8g
23
+patch -p0 <../../../../u8glib-bdf2u8g.patch bdf2u8g.c >/dev/null 2>&1
24
+make >/dev/null 2>&1
25
+mv bdf2u8g ../../../../
26
+
27
+# Clean up
28
+cd -
29
+rm -rf u8glib-master*
30
+
31
+cd "$HERE"

+ 32
- 47
buildroot/share/fonts/u8glib-bdf2u8g.patch Näytä tiedosto

@@ -1,47 +1,32 @@
1
---- tools/font/bdf2u8g/bdf2u8g.c	2017-04-08 01:04:48.000000000 -0400
2
-+++ tools/font/bdf2u8g/bdf2u8g.c	2018-02-24 17:24:26.368926703 -0500
3
-@@ -175,9 +175,9 @@
4
-   for( i = 0; i < data_pos; i++ )
5
-   {
6
- #ifdef BDF2U8G_COMPACT_OUTPUT
7
--    fprintf(out_fp, "%d", data_buf[i]);
8
-+    fprintf(out_fp, "0x%02x", data_buf[i]);
9
- #else
10
--    fprintf(out_fp, "%3d", data_buf[i]);
11
-+    fprintf(out_fp, "0x%02x", data_buf[i]);
12
- #endif
13
-     if ( i+1 != data_pos )
14
-       fprintf(out_fp, ",");
15
-@@ -484,7 +484,8 @@
16
- int bdf_char_max_y;
17
- int bdf_char_min_y;
18
- 
19
--int bdf_delta_x;           /* DWIDTH arg 1 */
20
-+int bdf_delta_x_default = -1;
21
-+int bdf_delta_x = -1;           /* DWIDTH arg 1 */
22
- int bdf_delta_max_x;
23
- int bdf_delta_min_x;
24
- int bdf_delta_y;           /* DWIDTH arg 2 */
25
-@@ -1095,6 +1096,22 @@
26
-       bdf_char_ascent = bdf_char_height + bdf_char_y;
27
-       //printf("h:%d w:%d ascent: %d\n", bdf_char_height, bdf_char_width, bdf_char_ascent);
28
-     }
29
-+    else if ( strcmp(p_buf, "CHARS") == 0 )
30
-+    {
31
-+        if (bdf_delta_x < 0) {
32
-+            bdf_delta_x = 0;
33
-+        }
34
-+        if (bdf_delta_x_default < 0) {
35
-+            bdf_delta_x_default = bdf_delta_x;
36
-+        }
37
-+    }
38
-+    else if ( strcmp(p_buf, "STARTCHAR") == 0 )
39
-+    {
40
-+        if (bdf_delta_x_default < 0) {
41
-+            bdf_delta_x_default = 0;
42
-+        }
43
-+        bdf_delta_x = bdf_delta_x_default;
44
-+    }
45
-     else if ( strcmp(p_buf, "BITMAP") == 0 )
46
-     {
47
-       bdf_line_state = BDF_LINE_STATE_BITMAP;
1
+178c178
2
+<     fprintf(out_fp, "%d", data_buf[i]);
3
+---
4
+>     fprintf(out_fp, "0x%02x", data_buf[i]);
5
+180c180
6
+<     fprintf(out_fp, "%3d", data_buf[i]);
7
+---
8
+>     fprintf(out_fp, "0x%02x", data_buf[i]);
9
+487c487,488
10
+< int bdf_delta_x;           /* DWIDTH arg 1 */
11
+---
12
+> int bdf_delta_x_default = -1;
13
+> int bdf_delta_x = -1;           /* DWIDTH arg 1 */
14
+1097a1099,1114
15
+>     else if ( strcmp(p_buf, "CHARS") == 0 )
16
+>     {
17
+>         if (bdf_delta_x < 0) {
18
+>             bdf_delta_x = 0;
19
+>         }
20
+>         if (bdf_delta_x_default < 0) {
21
+>             bdf_delta_x_default = bdf_delta_x;
22
+>         }
23
+>     }
24
+>     else if ( strcmp(p_buf, "STARTCHAR") == 0 )
25
+>     {
26
+>         if (bdf_delta_x_default < 0) {
27
+>             bdf_delta_x_default = 0;
28
+>         }
29
+>         bdf_delta_x = bdf_delta_x_default;
30
+>     }
31
+1293d1309
32
+<   fprintf(out_fp, "#include \"u8g.h\"\n");  

+ 25
- 56
buildroot/share/fonts/uxggenpages.md Näytä tiedosto

@@ -2,68 +2,46 @@
2 2
 
3 3
 ### Supported hardware
4 4
 
5
-Marlin supports HD44780 character LCD and 128x64 graphical LCD via U8GLIB.
6
-Because of the limitation of HD44780 hardwares, Marlin can only support three
7
-character sets for that hardware:
8
-Japanese (kana_utf8), Russian/Cyrillic (ru), or Western (Roman characters)
9
-
10
-For the graphical LCD modules, there's far less limitation. Users and language
11
-maintainers can easily change the language translation strings if they save
12
-with UTF-8 encoding. The only extra step is to regenerate the font data from
13
-an existing BDF font file.
5
+Marlin supports HD44780 character LCD and 128x64 graphical LCD via U8GLIB. Because of the limitation of HD44780 hardwares, Marlin can only support three character sets for that hardware: Japanese (kana_utf8), Russian/Cyrillic (ru), or Western (Roman characters)
14 6
 
7
+For the graphical LCD modules, there's far less limitation. Users and language maintainers can easily change the language translation strings when saved with UTF-8 encoding. The only extra step is to regenerate the font data from an existing BDF font file.
15 8
 
16 9
 ### How to support a new language?
17 10
 
18
-1. prepare the translation source file
11
+1. Prepare the translation source file
19 12
 
20
-You need to add a language header file language_xx.h,
21
-where xx is the language/country code, for example en is for English.
22
-You may start with a existing language file by copying it to a new location:
13
+You need to add a language header file `language_xx.h`, replacing xx with the language/country code. (e.g., "en" for English). You can start with a existing language file by copying it to a new location:
23 14
 
24 15
 ```bash
25 16
 cp language_zh_CN.h language_zh_TW.h
26 17
 ```
27 18
 
28
-Then you can replace the strings in the macro _UxGT().
19
+Then simply replace the strings inside the `_UxGT()` macros.
29 20
 
30 21
 Make sure the file is saved as UTF-8 encoded.
31 22
 
32
-
33 23
 2. Generate the font data file
34 24
 
35
-This step is to gather the glyph appearing in the language file from a 9pt bitmap font,
36
-and save the data in a language_data_xx.h file. So the font used for conversion should
37
-contain all the characters in your language file.
38
-
39
-The default bitmap font is WQY's 9pt bitmap font. You may download from
25
+This step gathers the glyphs used in the language file from a 9pt bitmap font and saves the data in a language_data_xx.h file. So the font used for conversion should contain all the characters in your language file.
40 26
 
41
-http://wenq.org/daily/wqy-bitmapfont-bdf-gb18030-nightly_build.tar.gz
27
+The default bitmap font is WQY's 9pt bitmap font.
42 28
 
43
-or install in Debian/Ubuntu system:
29
+Download from [here](http://wenq.org/daily/wqy-bitmapfont-bdf-gb18030-nightly_build.tar.gz), or to install in a Debian/Ubuntu system:
44 30
 
45 31
 ```
46 32
 sudo apt-get install xfonts-wqy
47 33
 ```
48 34
 
49
-You need also compile the bdf2u8g which convert the BDF font file to U8glib supported data structures.
50
-Before you compile bdf2u8g, it would better to patch the source file bdf2u8g.c.
35
+You also need to compile the `bdf2u8g` binary to convert BDF font files into U8glib data structures:
51 36
 
52
-```
37
+```bash
53 38
 cd marlin-git/buildroot/share/fonts/
54
-wget https://github.com/olikraus/u8glib/archive/master.zip
55
-unzip master.zip
56
-cd u8glib-master/
57
-patch -p0 < ../u8glib-bdf2u8g.patch
58
-make -C tools/font/bdf2u8g/
59
-cd -
60
-ln -s u8glib-master/tools/font/bdf2u8g/bdf2u8g
39
+./get-bdf2u8g.sh
61 40
 ```
62 41
 
63
-The 'genallfont.sh' script will generate the font data for all of the
64
-language translation files.
42
+The `genallfont.sh` script generates font data for all language translation files.
65 43
 
66
-You may specify the language list you want to process. For example:
44
+You may specify a list of languages to process. For example:
67 45
 
68 46
 ```bash
69 47
 MARLIN_LANGS="zh_CN zh_TW"
@@ -78,8 +56,7 @@ MARLIN_LANGS="zh_CN zh_TW" ../buildroot/share/fonts/genallfont.sh
78 56
 
79 57
 3. Change the language settings
80 58
 
81
-To compile the firmware for your language, you need choose a language
82
-in `Configuration.h`. For Chinese (Taiwan) you would use:
59
+To compile Marlin with your language, choose a language in `Configuration.h`. For Chinese (Taiwan) you would use:
83 60
 
84 61
 ```cpp
85 62
 #define LCD_LANGUAGE zh_TW
@@ -87,42 +64,34 @@ in `Configuration.h`. For Chinese (Taiwan) you would use:
87 64
 
88 65
 4. Compile and Upload the firmware
89 66
 
90
-Open `Marlin.ino` in your IDE and compile the firmware. If it's compiled succeeds, upload it to your Arduino hardware.
91
-
67
+Open `Marlin.ino` in your IDE and compile the firmware. Once the build succeeds, upload it to your board.
92 68
 
93 69
 ### Update the language translation
94 70
 
95
-If you change the language files, you need to run the script `genallfont.sh`
96
-again to update the font data file.
97
-
71
+Whenever language files are changed, you need to run the script `genallfont.sh` again to update the font data file.
98 72
 
99 73
 ### Use a cool font
100 74
 
101
-You may need to use a different font to support your own language, because the
102
-default 9pt font is not complete. (You may also support them by adding the missing
103
-glyphs to the font.)
75
+You may need to use a different font to support your own language, because the default 9pt font is not complete. (You may also support them by adding the missing glyphs to the font.)
104 76
 
105
-After you've prepared your font, specify the font file path as an argument to
106
-`genallfont.sh`, so that the font used for your language is your new font. For
107
-example, your new font file name is `newfont.bdf`, then run the following command:
77
+After you've prepared your font, specify the font file path as an argument to `genallfont.sh`, so that the font used for your language is your new font. For example, if your font is named `newfont.bdf` run the following command:
108 78
 
109 79
 ```bash
110 80
 cd Marlin/
111 81
 ../buildroot/share/fonts/genallfont.sh ./newfont.bdf
82
+```
112 83
 
113
-# OR if you just want to regenerate the language font data for a specific language:
84
+...or to regenerate the language font data for a specific language:
85
+
86
+```bash
114 87
 MARLIN_LANGS="zh_TW" ../buildroot/share/fonts/genallfont.sh ./newfont.bdf
115 88
 ```
116 89
 
117 90
 ### Suggestions for Maintainers
118 91
 
119
-Even the tool and the language engine can be easily updated,
120
-since it use the common bitmap font files and UTF-8 text,
121
-the maintainer need to confirm that the fonts contains the glyph
122
-in the language files.
92
+The tool and the language engine can be easily updated. Since it uses common bitmap font files and UTF-8 text, the maintainer needs to confirm that the font contains the glyphs in the language files.
123 93
 
124
-The font file currently used to generate the font data is the file ISO10646-0-3.bdf,
125
-which is combined with the Marlin's ISO10646-1 fonts and WQY 9pt bitmap font.
94
+At this time, the font file `marlin-6x12-3.bdf` is used to generate the font data. It combines all of Marlin's ISO10646-1 fonts and the WQY 9pt bitmap font.
126 95
 
127 96
 ### Related resources
128 97
 
@@ -135,7 +104,7 @@ which is combined with the Marlin's ISO10646-1 fonts and WQY 9pt bitmap font.
135 104
 Documents related to the old version of the language engine:
136 105
 
137 106
 - [Marlin Fonts Documentation](http://www.marlinfw.org/docs/development/fonts.html)
138
-- [Marlin LCD Language](https://github.com/MarlinFirmware/Marlin/wiki/LCD-Language)
107
+- [Marlin LCD Language](http://marlinfw.org/docs/development/lcd_language.html)
139 108
 - [U8GLIB](https://github.com/olikraus/u8glib.git)
140 109
 - [UTF-8 for U8GLIB](https://github.com/yhfudev/u8glib-fontutf8.git)
141 110
 - [Standalone test project for the Marlin UTF-8 language engine](https://github.com/yhfudev/marlin-fontutf8.git)

+ 40
- 37
buildroot/share/fonts/uxggenpages.sh Näytä tiedosto

@@ -5,10 +5,11 @@
5 5
 #
6 6
 # This script will generate u8g c files for specified fonts
7 7
 #
8
-# Copyright 2015-2016 Yunhui Fu <yhfudev@gmail.com>
8
+# Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com>
9 9
 # License: GPL/BSD
10 10
 #####################################################################
11
-my_getpath () {
11
+
12
+my_getpath() {
12 13
   local PARAM_DN="$1"
13 14
   shift
14 15
 
@@ -22,22 +23,19 @@ my_getpath () {
22 23
   cd "${DN}" > /dev/null 2>&1
23 24
   DN=$(pwd)
24 25
   cd - > /dev/null 2>&1
25
-  echo "${DN}/${FN}"
26
+  echo -n "${DN}"
27
+  [[ -z "$FN" ]] || echo -n "/${FN}"
26 28
 }
27 29
 #DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'`
28 30
 DN_EXEC=$(dirname $(my_getpath "$0") )
29
-if [ ! "${DN_EXEC}" = "" ]; then
30
-  DN_EXEC="$(my_getpath "${DN_EXEC}")/"
31
-else
32
-  DN_EXEC="${DN_EXEC}/"
33
-fi
31
+
34 32
 #####################################################################
33
+
35 34
 EXEC_GENPAGES=${DN_EXEC}/genpages
36 35
 [ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES="$(my_getpath ${DN_EXEC}/../../../genpages)"
37 36
 [ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES=$(which genpages)
38 37
 [ -x "${EXEC_GENPAGES}" ] || { echo "Error: genpages not found!" ; exit 1; }
39
-
40
-echo "EXEC_GENPAGES=${EXEC_GENPAGES}"
38
+#echo "EXEC_GENPAGES=${EXEC_GENPAGES}"
41 39
 
42 40
 EXEC_BDF2U8G=${DN_EXEC}/bdf2u8g
43 41
 [ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/../../../bdf2u8g"
@@ -49,6 +47,7 @@ DN_DATA=$(pwd)/datatmp
49 47
 mkdir -p "${DN_DATA}"
50 48
 
51 49
 #####################################################################
50
+
52 51
 FONTHOME=/usr/share/fonts
53 52
 
54 53
 FN_FONT_BASE="marlin-6x12-3"
@@ -65,7 +64,7 @@ FN_FONT="$(my_getpath "${DN_FONT}")/"`basename ${FN_FONT}`
65 64
 [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/wenquanyi/${FN_FONT_BASE}.bdf"
66 65
 [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/X11/misc/${FN_FONT_BASE}.bdf"
67 66
 [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/misc/${FN_FONT_BASE}.bdf"
68
-echo "uxggenpages.sh: FN_FONT=${FN_FONT}"
67
+#echo "uxggenpages.sh: FN_FONT=${FN_FONT}"
69 68
 
70 69
 if [ ! -f "${FN_FONT}" ]; then
71 70
   FN_FONT_PCF="$FONTHOME/X11/misc/${FN_FONT_BASE}.pcf"
@@ -91,10 +90,11 @@ fi
91 90
 #(cd ${DN_EXEC}; gcc -o genpages genpages.c getline.c)
92 91
 
93 92
 rm -f tmpa tmpb
93
+touch tmpa tmpb
94 94
 #rm -f ${DN_EXEC}/fontpage_*.h
95 95
 rm -f fontpage_*.h
96 96
 
97
-cat << EOF > tmp-proc-page.awk
97
+cat << EOF >"proc.awk"
98 98
 BEGIN {
99 99
   cur_page=0;
100 100
   val_begin=0;
@@ -139,33 +139,36 @@ BEGIN {
139 139
 }
140 140
 EOF
141 141
 
142
-grep -Hrn _UxGT . | grep '"' | \
143
-  sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' | \
144
-  ${EXEC_GENPAGES} | \
145
-  sort -k 1n -k 2n | uniq | \
146
-  gawk -v EXEC_PREFIX=${DN_EXEC} -f tmp-proc-page.awk | \
147
-  while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
142
+grep -Hrn _UxGT . | grep '"' \
143
+  | sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \
144
+  | ${EXEC_GENPAGES} \
145
+  | sort -k 1n -k 2n | uniq \
146
+  | gawk -v EXEC_PREFIX=${DN_EXEC} -f "proc.awk" \
147
+  | while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
148 148
     if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \
149 149
       ${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 ;
150
-      #sed -i 's|#include "u8g.h"|#include <U8glib.h>|' ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ;
151
-    fi ;\
152
-    grep -A 10000000000 u8g_fntpgm_uint8_t ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h >> tmpa ;\
150
+    fi ; \
151
+    grep -A 10000000000 u8g_fntpgm_uint8_t ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h >> tmpa ; \
153 152
     echo "    FONTDATA_ITEM(${PAGE}, ${BEGIN}, ${END}, fontpage_${PAGE}_${BEGIN}_${END}), // '${UTF8BEGIN}' -- '${UTF8END}'" >> tmpb ;\
154 153
   done
155 154
 
156
-rm -f fontutf8-data.h
157
-echo "/* Generated by $0 */" >> fontutf8-data.h
158
-echo "/* This file is generated automatically, any changes to the file may be REPLACED by future processing. */" >> fontutf8-data.h
159
-echo "/* Please turn to the tools call this script to change the contents! */" >> fontutf8-data.h
160
-echo "" >> fontutf8-data.h
161
-echo "#include <U8glib.h>" >> fontutf8-data.h
162
-#echo "#include \"fontutf8u8g.h\"" >> fontutf8-data.h
163
-echo "" >> fontutf8-data.h
164
-cat tmpa >> fontutf8-data.h
165
-echo "" >> fontutf8-data.h
166
-echo "#define FONTDATA_ITEM(page, begin, end, data) {page, begin, end, NUM_ARRAY(data), data}" >> fontutf8-data.h
167
-echo "static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {" >> fontutf8-data.h
168
-cat tmpb >> fontutf8-data.h
169
-echo "};" >> fontutf8-data.h
170
-
171
-rm -f tmpa tmpb tmp-proc-page.awk
155
+TMPA=$(cat tmpa)
156
+TMPB=$(cat tmpb)
157
+
158
+EOL=$'\n'
159
+[[ ! "$TMPA" == "" ]] && TMPA="$EOL$TMPA$EOL"
160
+[[ ! "$TMPB" == "" ]] && TMPB="$EOL$TMPB$EOL"
161
+
162
+rm -f tmpa tmpb "proc.awk"
163
+
164
+cat <<EOF >fontutf8-data.h
165
+/**
166
+ * Generated automatically by buildroot/share/fonts/uxggenpages.sh
167
+ * Contents will be REPLACED by future processing!
168
+ * Use genallfont.sh to generate font data for updated languages.
169
+ */
170
+#include <U8glib.h>
171
+$TMPA
172
+#define FONTDATA_ITEM(page, begin, end, data) {page, begin, end, NUM_ARRAY(data), data}
173
+static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {$TMPB};
174
+EOF

Loading…
Peruuta
Tallenna