Updates to font scripts and fonts documentation

This commit is contained in:
Scott Lahteine 2018-04-19 03:07:25 -05:00
parent 8ca3c43d73
commit dde941cac8
5 changed files with 186 additions and 193 deletions

View File

@ -3,12 +3,12 @@
##################################################################### #####################################################################
# genallfont.sh for Marlin # genallfont.sh for Marlin
# #
# This script will generates font data for language headers # This script generates font data for language headers
# #
# Copyright 2015-2016 Yunhui Fu <yhfudev@gmail.com> # Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com>
# License: GPL/BSD # License: GPL/BSD
##################################################################### #####################################################################
my_getpath () { my_getpath() {
local PARAM_DN="$1" local PARAM_DN="$1"
shift shift
#readlink -f #readlink -f
@ -21,37 +21,22 @@ my_getpath () {
cd "${DN}" > /dev/null 2>&1 cd "${DN}" > /dev/null 2>&1
DN=$(pwd) DN=$(pwd)
cd - > /dev/null 2>&1 cd - > /dev/null 2>&1
echo "${DN}/${FN}" echo -n "${DN}"
[[ -z "$FN" ]] || echo -n "/${FN}"
} }
#DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'` #DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'`
DN_EXEC=$(dirname $(my_getpath "$0") ) DN_EXEC=$(dirname $(my_getpath "$0") )
if [ ! "${DN_EXEC}" = "" ]; then
DN_EXEC="$(my_getpath "${DN_EXEC}")/"
else
DN_EXEC="${DN_EXEC}/"
fi
#####################################################################
EXEC_WXGGEN="${DN_EXEC}/uxggenpages.sh" EXEC_WXGGEN="${DN_EXEC}/uxggenpages.sh"
EXEC_BDF2U8G=`which bdf2u8g` EXEC_BDF2U8G=`which bdf2u8g`
echo "0 set EXEC_BDF2U8G=$EXEC_BDF2U8G" [ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g"
if [ ! -x "${EXEC_BDF2U8G}" ]; then [ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${PWD}/bdf2u8g"
EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g" [ -x "${EXEC_BDF2U8G}" ] || { EOL=$'\n' ; echo "ERR: Can't find bdf2u8g!${EOL}See uxggenpages.md for bdf2u8g build instructions." >&2 ; exit 1; }
fi
if [ ! -x "${EXEC_BDF2U8G}" ]; then
EXEC_BDF2U8G="${PWD}/bdf2u8g"
fi
if [ ! -x "${EXEC_BDF2U8G}" ]; then
echo "ERR: Not found bdf2u8g!" >&2
echo "plaese compile u8blib/tools/font/bdf2u8g/bdf2u8g and link to it from here!" >&2
exit 1
fi
#FN_FONT="${1:-}" #FN_FONT="${1:-}"
FN_FONT="${DN_EXEC}/marlin-6x12-3.bdf" FN_FONT="${DN_EXEC}/marlin-6x12-3.bdf"
if [ ! "$1" = "" ]; then [ "$1" = "" ] || FN_FONT="$1"
FN_FONT="$1"
fi
DN_FONT0=`dirname ${FN_FONT}` DN_FONT0=`dirname ${FN_FONT}`
DN_FONT="$(my_getpath ${DN_FONT0})" DN_FONT="$(my_getpath ${DN_FONT0})"
@ -61,7 +46,7 @@ FN_FONT="$(my_getpath "${DN_FONT}")/"`basename ${FN_FONT}`
[ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/wenquanyi/${FN_FONT_BASE}.bdf" [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/wenquanyi/${FN_FONT_BASE}.bdf"
[ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/X11/misc/${FN_FONT_BASE}.bdf" [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/X11/misc/${FN_FONT_BASE}.bdf"
[ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/misc/${FN_FONT_BASE}.bdf" [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/misc/${FN_FONT_BASE}.bdf"
echo "genallfont.sh: FN_FONT=${FN_FONT}" #echo "genallfont.sh: FN_FONT=${FN_FONT}"
DN_WORK=./tmp1 DN_WORK=./tmp1
@ -70,49 +55,69 @@ DN_WORK=./tmp1
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" 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"
for LANG in ${MARLIN_LANGS:=$LANGS_DEFAULT} ; do for LANG in ${MARLIN_LANGS:=$LANGS_DEFAULT} ; do
echo "INFO: generate Marlin language data for '${LANG}'" >&2 echo "Generating Marlin language data for '${LANG}'" >&2
rm -rf ${DN_WORK}/
rm -rf ${DN_WORK}/ mkdir -p ${DN_WORK}
mkdir -p ${DN_WORK} cp Configuration.h ${DN_WORK}/
cp Configuration.h ${DN_WORK}/ cp src/lcd/language/language_${LANG}.h ${DN_WORK}/
cp src/lcd/language/language_${LANG}.h ${DN_WORK}/ cd ${DN_WORK}/
cd ${DN_WORK}/ ${EXEC_WXGGEN} "${FN_FONT}"
${EXEC_WXGGEN} "${FN_FONT}" 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
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 cd ../
cd ../ mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/language_data_${LANG}.h
mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/language_data_${LANG}.h rm -rf ${DN_WORK}/
rm -rf ${DN_WORK}/
done done
#
# generate default ASCII font (char range 0-255): # Generate default ASCII font (char range 0-255):
# Marlin/src/lcd/dogm/dogm_font_data_ISO10646_1.h # Marlin/src/lcd/dogm/dogm_font_data_ISO10646_1.h
#
#if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then #if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then
if [ 1 = 1 ]; then if [ 1 = 1 ]; then
rm -rf ${DN_WORK}/ rm -rf ${DN_WORK}/
mkdir -p ${DN_WORK} mkdir -p ${DN_WORK}
cd ${DN_WORK}/ cd ${DN_WORK}/
${EXEC_BDF2U8G} -b 1 -e 127 ${FN_FONT} ISO10646_1_5x7 tmp1.h ${EXEC_BDF2U8G} -b 1 -e 127 ${FN_FONT} ISO10646_1_5x7 tmp1.h >/dev/null
${EXEC_BDF2U8G} -b 1 -e 255 ${FN_FONT} ISO10646_1_5x7 tmp2.h ${EXEC_BDF2U8G} -b 1 -e 255 ${FN_FONT} ISO10646_1_5x7 tmp2.h >/dev/null
TMP1=$(cat tmp1.h) ; rm tmp1.h
TMP2=$(cat tmp2.h) ; rm tmp2.h
cat << EOF >tmp3.h cat <<EOF >../src/lcd/dogm/dogm_font_data_ISO10646_1.h
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <U8glib.h> #include <U8glib.h>
#if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7) #if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7)
// reduced font (only symbols 1 - 127) - saves about 1278 bytes of FLASH // reduced font (only symbols 1 - 127) - saves about 1278 bytes of FLASH
EOF $TMP1
cat tmp1.h >>tmp3.h
cat << EOF >>tmp3.h
#else #else
// extended (original) font (symbols 1 - 255) // extended (original) font (symbols 1 - 255)
EOF
cat tmp2.h >>tmp3.h $TMP2
cat << EOF >>tmp3.h
#endif #endif
EOF EOF
cd .. rmdir ../${DN_WORK}
mv ${DN_WORK}/tmp3.h src/lcd/dogm/dogm_font_data_ISO10646_1.h cd - >/dev/null
fi fi

View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
#####################################################################
# get-bdf2u8g.sh for Marlin
#
# This script downloads, patches, and builds bdf2u8g
# License: CC-SA
#
# Execute from within buildroot/share/fonts
#
#####################################################################
HERE=$(pwd)
[[ $HERE =~ 'buildroot/share/fonts'$ ]] || { echo "Change to buildroot/share/fonts to run $(basename $0)" ; exit 1; }
# Download u8glib
curl -LJO https://github.com/olikraus/u8glib/archive/master.zip
unzip u8glib-master.zip >/dev/null 2>&1
# Patch and build bdf2u8g
cd u8glib-master/tools/font/bdf2u8g
patch -p0 <../../../../u8glib-bdf2u8g.patch bdf2u8g.c >/dev/null 2>&1
make >/dev/null 2>&1
mv bdf2u8g ../../../../
# Clean up
cd -
rm -rf u8glib-master*
cd "$HERE"

View File

@ -1,47 +1,32 @@
--- tools/font/bdf2u8g/bdf2u8g.c 2017-04-08 01:04:48.000000000 -0400 178c178
+++ tools/font/bdf2u8g/bdf2u8g.c 2018-02-24 17:24:26.368926703 -0500 < fprintf(out_fp, "%d", data_buf[i]);
@@ -175,9 +175,9 @@ ---
for( i = 0; i < data_pos; i++ ) > fprintf(out_fp, "0x%02x", data_buf[i]);
{ 180c180
#ifdef BDF2U8G_COMPACT_OUTPUT < fprintf(out_fp, "%3d", data_buf[i]);
- fprintf(out_fp, "%d", data_buf[i]); ---
+ fprintf(out_fp, "0x%02x", data_buf[i]); > fprintf(out_fp, "0x%02x", data_buf[i]);
#else 487c487,488
- fprintf(out_fp, "%3d", data_buf[i]); < int bdf_delta_x; /* DWIDTH arg 1 */
+ fprintf(out_fp, "0x%02x", data_buf[i]); ---
#endif > int bdf_delta_x_default = -1;
if ( i+1 != data_pos ) > int bdf_delta_x = -1; /* DWIDTH arg 1 */
fprintf(out_fp, ","); 1097a1099,1114
@@ -484,7 +484,8 @@ > else if ( strcmp(p_buf, "CHARS") == 0 )
int bdf_char_max_y; > {
int bdf_char_min_y; > if (bdf_delta_x < 0) {
> bdf_delta_x = 0;
-int bdf_delta_x; /* DWIDTH arg 1 */ > }
+int bdf_delta_x_default = -1; > if (bdf_delta_x_default < 0) {
+int bdf_delta_x = -1; /* DWIDTH arg 1 */ > bdf_delta_x_default = bdf_delta_x;
int bdf_delta_max_x; > }
int bdf_delta_min_x; > }
int bdf_delta_y; /* DWIDTH arg 2 */ > else if ( strcmp(p_buf, "STARTCHAR") == 0 )
@@ -1095,6 +1096,22 @@ > {
bdf_char_ascent = bdf_char_height + bdf_char_y; > if (bdf_delta_x_default < 0) {
//printf("h:%d w:%d ascent: %d\n", bdf_char_height, bdf_char_width, bdf_char_ascent); > bdf_delta_x_default = 0;
} > }
+ else if ( strcmp(p_buf, "CHARS") == 0 ) > bdf_delta_x = bdf_delta_x_default;
+ { > }
+ if (bdf_delta_x < 0) { 1293d1309
+ bdf_delta_x = 0; < fprintf(out_fp, "#include \"u8g.h\"\n");
+ }
+ if (bdf_delta_x_default < 0) {
+ bdf_delta_x_default = bdf_delta_x;
+ }
+ }
+ else if ( strcmp(p_buf, "STARTCHAR") == 0 )
+ {
+ if (bdf_delta_x_default < 0) {
+ bdf_delta_x_default = 0;
+ }
+ bdf_delta_x = bdf_delta_x_default;
+ }
else if ( strcmp(p_buf, "BITMAP") == 0 )
{
bdf_line_state = BDF_LINE_STATE_BITMAP;

View File

@ -2,68 +2,46 @@
### Supported hardware ### Supported hardware
Marlin supports HD44780 character LCD and 128x64 graphical LCD via U8GLIB. 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)
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)
For the graphical LCD modules, there's far less limitation. Users and language
maintainers can easily change the language translation strings if they save
with UTF-8 encoding. The only extra step is to regenerate the font data from
an existing BDF font file.
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.
### How to support a new language? ### How to support a new language?
1. prepare the translation source file 1. Prepare the translation source file
You need to add a language header file language_xx.h, 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:
where xx is the language/country code, for example en is for English.
You may start with a existing language file by copying it to a new location:
```bash ```bash
cp language_zh_CN.h language_zh_TW.h cp language_zh_CN.h language_zh_TW.h
``` ```
Then you can replace the strings in the macro _UxGT(). Then simply replace the strings inside the `_UxGT()` macros.
Make sure the file is saved as UTF-8 encoded. Make sure the file is saved as UTF-8 encoded.
2. Generate the font data file 2. Generate the font data file
This step is to gather the glyph appearing in the language file from a 9pt bitmap font, 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.
and save the data in a language_data_xx.h file. So the font used for conversion should
contain all the characters in your language file.
The default bitmap font is WQY's 9pt bitmap font. You may download from The default bitmap font is WQY's 9pt bitmap font.
http://wenq.org/daily/wqy-bitmapfont-bdf-gb18030-nightly_build.tar.gz Download from [here](http://wenq.org/daily/wqy-bitmapfont-bdf-gb18030-nightly_build.tar.gz), or to install in a Debian/Ubuntu system:
or install in Debian/Ubuntu system:
``` ```
sudo apt-get install xfonts-wqy sudo apt-get install xfonts-wqy
``` ```
You need also compile the bdf2u8g which convert the BDF font file to U8glib supported data structures. You also need to compile the `bdf2u8g` binary to convert BDF font files into U8glib data structures:
Before you compile bdf2u8g, it would better to patch the source file bdf2u8g.c.
``` ```bash
cd marlin-git/buildroot/share/fonts/ cd marlin-git/buildroot/share/fonts/
wget https://github.com/olikraus/u8glib/archive/master.zip ./get-bdf2u8g.sh
unzip master.zip
cd u8glib-master/
patch -p0 < ../u8glib-bdf2u8g.patch
make -C tools/font/bdf2u8g/
cd -
ln -s u8glib-master/tools/font/bdf2u8g/bdf2u8g
``` ```
The 'genallfont.sh' script will generate the font data for all of the The `genallfont.sh` script generates font data for all language translation files.
language translation files.
You may specify the language list you want to process. For example: You may specify a list of languages to process. For example:
```bash ```bash
MARLIN_LANGS="zh_CN zh_TW" MARLIN_LANGS="zh_CN zh_TW"
@ -78,8 +56,7 @@ MARLIN_LANGS="zh_CN zh_TW" ../buildroot/share/fonts/genallfont.sh
3. Change the language settings 3. Change the language settings
To compile the firmware for your language, you need choose a language To compile Marlin with your language, choose a language in `Configuration.h`. For Chinese (Taiwan) you would use:
in `Configuration.h`. For Chinese (Taiwan) you would use:
```cpp ```cpp
#define LCD_LANGUAGE zh_TW #define LCD_LANGUAGE zh_TW
@ -87,42 +64,34 @@ in `Configuration.h`. For Chinese (Taiwan) you would use:
4. Compile and Upload the firmware 4. Compile and Upload the firmware
Open `Marlin.ino` in your IDE and compile the firmware. If it's compiled succeeds, upload it to your Arduino hardware. Open `Marlin.ino` in your IDE and compile the firmware. Once the build succeeds, upload it to your board.
### Update the language translation ### Update the language translation
If you change the language files, you need to run the script `genallfont.sh` Whenever language files are changed, you need to run the script `genallfont.sh` again to update the font data file.
again to update the font data file.
### Use a cool font ### Use a cool font
You may need to use a different font to support your own language, because the 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.)
default 9pt font is not complete. (You may also support them by adding the missing
glyphs to the font.)
After you've prepared your font, specify the font file path as an argument to 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:
`genallfont.sh`, so that the font used for your language is your new font. For
example, your new font file name is `newfont.bdf`, then run the following command:
```bash ```bash
cd Marlin/ cd Marlin/
../buildroot/share/fonts/genallfont.sh ./newfont.bdf ../buildroot/share/fonts/genallfont.sh ./newfont.bdf
```
# OR if you just want to regenerate the language font data for a specific language: ...or to regenerate the language font data for a specific language:
```bash
MARLIN_LANGS="zh_TW" ../buildroot/share/fonts/genallfont.sh ./newfont.bdf MARLIN_LANGS="zh_TW" ../buildroot/share/fonts/genallfont.sh ./newfont.bdf
``` ```
### Suggestions for Maintainers ### Suggestions for Maintainers
Even the tool and the language engine can be easily updated, 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.
since it use the common bitmap font files and UTF-8 text,
the maintainer need to confirm that the fonts contains the glyph
in the language files.
The font file currently used to generate the font data is the file ISO10646-0-3.bdf, 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.
which is combined with the Marlin's ISO10646-1 fonts and WQY 9pt bitmap font.
### Related resources ### Related resources
@ -135,7 +104,7 @@ which is combined with the Marlin's ISO10646-1 fonts and WQY 9pt bitmap font.
Documents related to the old version of the language engine: Documents related to the old version of the language engine:
- [Marlin Fonts Documentation](http://www.marlinfw.org/docs/development/fonts.html) - [Marlin Fonts Documentation](http://www.marlinfw.org/docs/development/fonts.html)
- [Marlin LCD Language](https://github.com/MarlinFirmware/Marlin/wiki/LCD-Language) - [Marlin LCD Language](http://marlinfw.org/docs/development/lcd_language.html)
- [U8GLIB](https://github.com/olikraus/u8glib.git) - [U8GLIB](https://github.com/olikraus/u8glib.git)
- [UTF-8 for U8GLIB](https://github.com/yhfudev/u8glib-fontutf8.git) - [UTF-8 for U8GLIB](https://github.com/yhfudev/u8glib-fontutf8.git)
- [Standalone test project for the Marlin UTF-8 language engine](https://github.com/yhfudev/marlin-fontutf8.git) - [Standalone test project for the Marlin UTF-8 language engine](https://github.com/yhfudev/marlin-fontutf8.git)

View File

@ -5,10 +5,11 @@
# #
# This script will generate u8g c files for specified fonts # This script will generate u8g c files for specified fonts
# #
# Copyright 2015-2016 Yunhui Fu <yhfudev@gmail.com> # Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com>
# License: GPL/BSD # License: GPL/BSD
##################################################################### #####################################################################
my_getpath () {
my_getpath() {
local PARAM_DN="$1" local PARAM_DN="$1"
shift shift
@ -22,22 +23,19 @@ my_getpath () {
cd "${DN}" > /dev/null 2>&1 cd "${DN}" > /dev/null 2>&1
DN=$(pwd) DN=$(pwd)
cd - > /dev/null 2>&1 cd - > /dev/null 2>&1
echo "${DN}/${FN}" echo -n "${DN}"
[[ -z "$FN" ]] || echo -n "/${FN}"
} }
#DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'` #DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'`
DN_EXEC=$(dirname $(my_getpath "$0") ) DN_EXEC=$(dirname $(my_getpath "$0") )
if [ ! "${DN_EXEC}" = "" ]; then
DN_EXEC="$(my_getpath "${DN_EXEC}")/"
else
DN_EXEC="${DN_EXEC}/"
fi
##################################################################### #####################################################################
EXEC_GENPAGES=${DN_EXEC}/genpages EXEC_GENPAGES=${DN_EXEC}/genpages
[ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES="$(my_getpath ${DN_EXEC}/../../../genpages)" [ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES="$(my_getpath ${DN_EXEC}/../../../genpages)"
[ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES=$(which genpages) [ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES=$(which genpages)
[ -x "${EXEC_GENPAGES}" ] || { echo "Error: genpages not found!" ; exit 1; } [ -x "${EXEC_GENPAGES}" ] || { echo "Error: genpages not found!" ; exit 1; }
#echo "EXEC_GENPAGES=${EXEC_GENPAGES}"
echo "EXEC_GENPAGES=${EXEC_GENPAGES}"
EXEC_BDF2U8G=${DN_EXEC}/bdf2u8g EXEC_BDF2U8G=${DN_EXEC}/bdf2u8g
[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/../../../bdf2u8g" [ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/../../../bdf2u8g"
@ -49,6 +47,7 @@ DN_DATA=$(pwd)/datatmp
mkdir -p "${DN_DATA}" mkdir -p "${DN_DATA}"
##################################################################### #####################################################################
FONTHOME=/usr/share/fonts FONTHOME=/usr/share/fonts
FN_FONT_BASE="marlin-6x12-3" FN_FONT_BASE="marlin-6x12-3"
@ -65,7 +64,7 @@ FN_FONT="$(my_getpath "${DN_FONT}")/"`basename ${FN_FONT}`
[ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/wenquanyi/${FN_FONT_BASE}.bdf" [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/wenquanyi/${FN_FONT_BASE}.bdf"
[ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/X11/misc/${FN_FONT_BASE}.bdf" [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/X11/misc/${FN_FONT_BASE}.bdf"
[ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/misc/${FN_FONT_BASE}.bdf" [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/misc/${FN_FONT_BASE}.bdf"
echo "uxggenpages.sh: FN_FONT=${FN_FONT}" #echo "uxggenpages.sh: FN_FONT=${FN_FONT}"
if [ ! -f "${FN_FONT}" ]; then if [ ! -f "${FN_FONT}" ]; then
FN_FONT_PCF="$FONTHOME/X11/misc/${FN_FONT_BASE}.pcf" FN_FONT_PCF="$FONTHOME/X11/misc/${FN_FONT_BASE}.pcf"
@ -91,10 +90,11 @@ fi
#(cd ${DN_EXEC}; gcc -o genpages genpages.c getline.c) #(cd ${DN_EXEC}; gcc -o genpages genpages.c getline.c)
rm -f tmpa tmpb rm -f tmpa tmpb
touch tmpa tmpb
#rm -f ${DN_EXEC}/fontpage_*.h #rm -f ${DN_EXEC}/fontpage_*.h
rm -f fontpage_*.h rm -f fontpage_*.h
cat << EOF > tmp-proc-page.awk cat << EOF >"proc.awk"
BEGIN { BEGIN {
cur_page=0; cur_page=0;
val_begin=0; val_begin=0;
@ -139,33 +139,36 @@ BEGIN {
} }
EOF EOF
grep -Hrn _UxGT . | grep '"' | \ grep -Hrn _UxGT . | grep '"' \
sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' | \ | sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \
${EXEC_GENPAGES} | \ | ${EXEC_GENPAGES} \
sort -k 1n -k 2n | uniq | \ | sort -k 1n -k 2n | uniq \
gawk -v EXEC_PREFIX=${DN_EXEC} -f tmp-proc-page.awk | \ | gawk -v EXEC_PREFIX=${DN_EXEC} -f "proc.awk" \
while read PAGE BEGIN END UTF8BEGIN UTF8END; do \ | while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \ if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \
${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 ; ${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 ;
#sed -i 's|#include "u8g.h"|#include <U8glib.h>|' ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ; fi ; \
fi ;\ grep -A 10000000000 u8g_fntpgm_uint8_t ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h >> tmpa ; \
grep -A 10000000000 u8g_fntpgm_uint8_t ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h >> tmpa ;\
echo " FONTDATA_ITEM(${PAGE}, ${BEGIN}, ${END}, fontpage_${PAGE}_${BEGIN}_${END}), // '${UTF8BEGIN}' -- '${UTF8END}'" >> tmpb ;\ echo " FONTDATA_ITEM(${PAGE}, ${BEGIN}, ${END}, fontpage_${PAGE}_${BEGIN}_${END}), // '${UTF8BEGIN}' -- '${UTF8END}'" >> tmpb ;\
done done
rm -f fontutf8-data.h TMPA=$(cat tmpa)
echo "/* Generated by $0 */" >> fontutf8-data.h TMPB=$(cat tmpb)
echo "/* This file is generated automatically, any changes to the file may be REPLACED by future processing. */" >> fontutf8-data.h
echo "/* Please turn to the tools call this script to change the contents! */" >> fontutf8-data.h
echo "" >> fontutf8-data.h
echo "#include <U8glib.h>" >> fontutf8-data.h
#echo "#include \"fontutf8u8g.h\"" >> fontutf8-data.h
echo "" >> fontutf8-data.h
cat tmpa >> fontutf8-data.h
echo "" >> fontutf8-data.h
echo "#define FONTDATA_ITEM(page, begin, end, data) {page, begin, end, NUM_ARRAY(data), data}" >> fontutf8-data.h
echo "static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {" >> fontutf8-data.h
cat tmpb >> fontutf8-data.h
echo "};" >> fontutf8-data.h
rm -f tmpa tmpb tmp-proc-page.awk EOL=$'\n'
[[ ! "$TMPA" == "" ]] && TMPA="$EOL$TMPA$EOL"
[[ ! "$TMPB" == "" ]] && TMPB="$EOL$TMPB$EOL"
rm -f tmpa tmpb "proc.awk"
cat <<EOF >fontutf8-data.h
/**
* Generated automatically by buildroot/share/fonts/uxggenpages.sh
* Contents will be REPLACED by future processing!
* Use genallfont.sh to generate font data for updated languages.
*/
#include <U8glib.h>
$TMPA
#define FONTDATA_ITEM(page, begin, end, data) {page, begin, end, NUM_ARRAY(data), data}
static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {$TMPB};
EOF