2018-04-13 03:14:01 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# genallfont.sh for Marlin
|
|
|
|
#
|
2018-04-19 10:07:25 +02:00
|
|
|
# This script generates font data for language headers
|
2018-04-13 03:14:01 +02:00
|
|
|
#
|
2018-04-19 10:07:25 +02:00
|
|
|
# Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com>
|
2018-04-13 03:14:01 +02:00
|
|
|
# License: GPL/BSD
|
|
|
|
#####################################################################
|
2018-04-19 10:07:25 +02:00
|
|
|
my_getpath() {
|
2018-04-17 06:03:06 +02:00
|
|
|
local PARAM_DN="$1"
|
2018-04-13 03:14:01 +02:00
|
|
|
shift
|
|
|
|
#readlink -f
|
2018-04-17 06:03:06 +02:00
|
|
|
local DN="${PARAM_DN}"
|
|
|
|
local FN=
|
2018-04-13 03:14:01 +02:00
|
|
|
if [ ! -d "${DN}" ]; then
|
|
|
|
FN=$(basename "${DN}")
|
|
|
|
DN=$(dirname "${DN}")
|
|
|
|
fi
|
|
|
|
cd "${DN}" > /dev/null 2>&1
|
|
|
|
DN=$(pwd)
|
|
|
|
cd - > /dev/null 2>&1
|
2018-04-19 10:07:25 +02:00
|
|
|
echo -n "${DN}"
|
|
|
|
[[ -z "$FN" ]] || echo -n "/${FN}"
|
2018-04-13 03:14:01 +02:00
|
|
|
}
|
|
|
|
#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") )
|
2018-04-19 10:07:25 +02:00
|
|
|
|
2018-04-13 03:14:01 +02:00
|
|
|
EXEC_WXGGEN="${DN_EXEC}/uxggenpages.sh"
|
|
|
|
|
2018-11-24 03:02:19 +01:00
|
|
|
#
|
|
|
|
# Locate the bdf2u8g command
|
|
|
|
#
|
2018-04-13 03:14:01 +02:00
|
|
|
EXEC_BDF2U8G=`which bdf2u8g`
|
2018-04-19 10:07:25 +02:00
|
|
|
[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g"
|
|
|
|
[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${PWD}/bdf2u8g"
|
|
|
|
[ -x "${EXEC_BDF2U8G}" ] || { EOL=$'\n' ; echo "ERR: Can't find bdf2u8g!${EOL}See uxggenpages.md for bdf2u8g build instructions." >&2 ; exit 1; }
|
2018-04-13 03:14:01 +02:00
|
|
|
|
2018-11-24 03:02:19 +01:00
|
|
|
#
|
|
|
|
# Get language arguments
|
|
|
|
#
|
|
|
|
LANG_ARG="$@"
|
2018-04-13 03:14:01 +02:00
|
|
|
|
2018-11-24 03:02:19 +01:00
|
|
|
#
|
|
|
|
# Use 6x12 combined font data for Western languages
|
|
|
|
#
|
|
|
|
FN_FONT="${DN_EXEC}/marlin-6x12-3.bdf"
|
2018-04-17 06:03:06 +02:00
|
|
|
|
2018-11-24 03:02:19 +01:00
|
|
|
#
|
|
|
|
# Change to working directory 'Marlin'
|
|
|
|
#
|
|
|
|
OLDWD=`pwd`
|
|
|
|
[[ $(basename "$OLDWD") != 'Marlin' && -d "Marlin" ]] && cd Marlin
|
|
|
|
[[ -f "Configuration.h" ]] || { echo -n "cd to the 'Marlin' folder to run " ; basename $0 ; exit 1; }
|
2018-04-13 03:14:01 +02:00
|
|
|
|
2018-11-24 03:02:19 +01:00
|
|
|
#
|
|
|
|
# Compile the 'genpages' command in-place
|
|
|
|
#
|
2021-01-14 09:21:28 +01:00
|
|
|
(cd ${DN_EXEC}; cc -o genpages genpages.c getline.c)
|
2018-04-13 03:14:01 +02:00
|
|
|
|
2018-11-24 03:02:19 +01:00
|
|
|
#
|
|
|
|
# By default loop through all languages
|
|
|
|
#
|
2020-06-28 05:59:44 +02:00
|
|
|
LANGS_DEFAULT="an bg ca cz da de el el_gr en es eu fi fr gl hr hu it jp_kana ko_KR nl pl pt pt_br ro ru sk tr uk vi zh_CN zh_TW test"
|
2018-04-15 20:12:02 +02:00
|
|
|
|
2018-11-24 03:02:19 +01:00
|
|
|
#
|
|
|
|
# Generate data for language list MARLIN_LANGS or all if not provided
|
|
|
|
#
|
|
|
|
for LANG in ${LANG_ARG:=$LANGS_DEFAULT} ; do
|
2018-04-19 10:07:25 +02:00
|
|
|
echo "Generating Marlin language data for '${LANG}'" >&2
|
2018-11-24 03:02:19 +01:00
|
|
|
case "$LANG" in
|
|
|
|
zh_* ) FONTFILE="wenquanyi_12pt" ;;
|
|
|
|
ko_* ) FONTFILE="${DN_EXEC}/NanumGothic.bdf" ;;
|
|
|
|
* ) FONTFILE="${DN_EXEC}/marlin-6x12-3.bdf" ;;
|
|
|
|
esac
|
|
|
|
DN_WORK=`mktemp -d`
|
2018-04-19 10:07:25 +02:00
|
|
|
cp Configuration.h ${DN_WORK}/
|
|
|
|
cp src/lcd/language/language_${LANG}.h ${DN_WORK}/
|
2018-11-24 03:02:19 +01:00
|
|
|
cd "${DN_WORK}"
|
|
|
|
${EXEC_WXGGEN} "${FONTFILE}"
|
2018-04-19 10:07:25 +02:00
|
|
|
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
|
2018-11-24 03:02:19 +01:00
|
|
|
cd - >/dev/null
|
2018-10-31 02:40:36 +01:00
|
|
|
mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/fontdata/langdata_${LANG}.h
|
2018-11-24 03:02:19 +01:00
|
|
|
rm -rf ${DN_WORK}
|
2018-04-13 03:14:01 +02:00
|
|
|
done
|
|
|
|
|
2018-04-19 10:07:25 +02:00
|
|
|
#
|
|
|
|
# Generate default ASCII font (char range 0-255):
|
2018-10-24 10:38:13 +02:00
|
|
|
# Marlin/src/lcd/dogm/fontdata/fontdata_ISO10646_1.h
|
2018-04-19 10:07:25 +02:00
|
|
|
#
|
2018-04-15 20:12:02 +02:00
|
|
|
#if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then
|
|
|
|
if [ 1 = 1 ]; then
|
2018-11-24 03:02:19 +01:00
|
|
|
DN_WORK=`mktemp -d`
|
|
|
|
cd ${DN_WORK}
|
2018-04-19 10:07:25 +02:00
|
|
|
${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 >/dev/null
|
2018-11-24 03:02:19 +01:00
|
|
|
TMP1=$(cat tmp1.h)
|
|
|
|
TMP2=$(cat tmp2.h)
|
|
|
|
cd - >/dev/null
|
|
|
|
rm -rf ${DN_WORK}
|
2018-04-19 10:07:25 +02:00
|
|
|
|
2018-11-24 03:02:19 +01:00
|
|
|
cat <<EOF >src/lcd/dogm/fontdata/fontdata_ISO10646_1.h
|
2018-04-19 10:07:25 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 15:00:57 +01:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2019-02-12 22:06:53 +01:00
|
|
|
*
|
2018-04-19 10:07:25 +02:00
|
|
|
* 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
|
2020-07-17 16:30:41 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2018-04-19 10:07:25 +02:00
|
|
|
*
|
|
|
|
*/
|
2018-04-15 20:12:02 +02:00
|
|
|
#include <U8glib.h>
|
|
|
|
|
|
|
|
#if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7)
|
2018-04-19 00:06:18 +02:00
|
|
|
// reduced font (only symbols 1 - 127) - saves about 1278 bytes of FLASH
|
2018-04-15 20:12:02 +02:00
|
|
|
|
2018-04-19 10:07:25 +02:00
|
|
|
$TMP1
|
2018-04-15 20:12:02 +02:00
|
|
|
#else
|
2018-04-19 00:06:18 +02:00
|
|
|
// extended (original) font (symbols 1 - 255)
|
2018-04-19 10:07:25 +02:00
|
|
|
|
|
|
|
$TMP2
|
2018-04-15 20:12:02 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
EOF
|
|
|
|
|
|
|
|
fi
|
2018-11-24 03:02:19 +01:00
|
|
|
|
|
|
|
(cd ${DN_EXEC}; rm genpages)
|
|
|
|
|
|
|
|
cd "$OLDWD"
|