You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
4.0 KiB
Bash
141 lines
4.0 KiB
Bash
7 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
|
#####################################################################
|
||
|
# genallfont.sh for Marlin
|
||
|
#
|
||
7 years ago
|
# This script generates font data for language headers
|
||
7 years ago
|
#
|
||
7 years ago
|
# Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com>
|
||
7 years ago
|
# License: GPL/BSD
|
||
|
#####################################################################
|
||
7 years ago
|
my_getpath() {
|
||
7 years ago
|
local PARAM_DN="$1"
|
||
7 years ago
|
shift
|
||
|
#readlink -f
|
||
7 years ago
|
local DN="${PARAM_DN}"
|
||
|
local FN=
|
||
7 years ago
|
if [ ! -d "${DN}" ]; then
|
||
|
FN=$(basename "${DN}")
|
||
|
DN=$(dirname "${DN}")
|
||
|
fi
|
||
|
cd "${DN}" > /dev/null 2>&1
|
||
|
DN=$(pwd)
|
||
|
cd - > /dev/null 2>&1
|
||
7 years ago
|
echo -n "${DN}"
|
||
|
[[ -z "$FN" ]] || echo -n "/${FN}"
|
||
7 years ago
|
}
|
||
|
#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") )
|
||
7 years ago
|
|
||
7 years ago
|
EXEC_WXGGEN="${DN_EXEC}/uxggenpages.sh"
|
||
|
|
||
6 years ago
|
#
|
||
|
# Locate the bdf2u8g command
|
||
|
#
|
||
7 years ago
|
EXEC_BDF2U8G=`which bdf2u8g`
|
||
7 years ago
|
[ -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; }
|
||
7 years ago
|
|
||
6 years ago
|
#
|
||
|
# Get language arguments
|
||
|
#
|
||
|
LANG_ARG="$@"
|
||
7 years ago
|
|
||
6 years ago
|
#
|
||
|
# Use 6x12 combined font data for Western languages
|
||
|
#
|
||
|
FN_FONT="${DN_EXEC}/marlin-6x12-3.bdf"
|
||
7 years ago
|
|
||
6 years ago
|
#
|
||
|
# 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; }
|
||
7 years ago
|
|
||
6 years ago
|
#
|
||
|
# Compile the 'genpages' command in-place
|
||
|
#
|
||
7 years ago
|
(cd ${DN_EXEC}; gcc -o genpages genpages.c getline.c)
|
||
|
|
||
6 years ago
|
#
|
||
|
# By default loop through all languages
|
||
|
#
|
||
5 years ago
|
LANGS_DEFAULT="an bg ca cz da de el el_gr en es eu fi fr gl hr it jp_kana ko_KR nl pl pt pt_br ru sk tr uk vi zh_CN zh_TW test"
|
||
7 years ago
|
|
||
6 years ago
|
#
|
||
|
# Generate data for language list MARLIN_LANGS or all if not provided
|
||
|
#
|
||
|
for LANG in ${LANG_ARG:=$LANGS_DEFAULT} ; do
|
||
7 years ago
|
echo "Generating Marlin language data for '${LANG}'" >&2
|
||
6 years ago
|
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`
|
||
7 years ago
|
cp Configuration.h ${DN_WORK}/
|
||
|
cp src/lcd/language/language_${LANG}.h ${DN_WORK}/
|
||
6 years ago
|
cd "${DN_WORK}"
|
||
|
${EXEC_WXGGEN} "${FONTFILE}"
|
||
7 years ago
|
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
|
||
6 years ago
|
cd - >/dev/null
|
||
6 years ago
|
mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/fontdata/langdata_${LANG}.h
|
||
6 years ago
|
rm -rf ${DN_WORK}
|
||
7 years ago
|
done
|
||
|
|
||
7 years ago
|
#
|
||
|
# Generate default ASCII font (char range 0-255):
|
||
6 years ago
|
# Marlin/src/lcd/dogm/fontdata/fontdata_ISO10646_1.h
|
||
7 years ago
|
#
|
||
7 years ago
|
#if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then
|
||
|
if [ 1 = 1 ]; then
|
||
6 years ago
|
DN_WORK=`mktemp -d`
|
||
|
cd ${DN_WORK}
|
||
7 years ago
|
${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
|
||
6 years ago
|
TMP1=$(cat tmp1.h)
|
||
|
TMP2=$(cat tmp2.h)
|
||
|
cd - >/dev/null
|
||
|
rm -rf ${DN_WORK}
|
||
7 years ago
|
|
||
6 years ago
|
cat <<EOF >src/lcd/dogm/fontdata/fontdata_ISO10646_1.h
|
||
7 years ago
|
/**
|
||
|
* Marlin 3D Printer Firmware
|
||
5 years ago
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||
6 years ago
|
*
|
||
7 years ago
|
* 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/>.
|
||
|
*
|
||
|
*/
|
||
7 years ago
|
#include <U8glib.h>
|
||
|
|
||
|
#if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7)
|
||
7 years ago
|
// reduced font (only symbols 1 - 127) - saves about 1278 bytes of FLASH
|
||
7 years ago
|
|
||
7 years ago
|
$TMP1
|
||
7 years ago
|
#else
|
||
7 years ago
|
// extended (original) font (symbols 1 - 255)
|
||
7 years ago
|
|
||
|
$TMP2
|
||
7 years ago
|
|
||
|
#endif
|
||
|
EOF
|
||
|
|
||
|
fi
|
||
6 years ago
|
|
||
|
(cd ${DN_EXEC}; rm genpages)
|
||
|
|
||
|
cd "$OLDWD"
|