This repository has been archived on 2022-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
Marlin-Artillery-M600/buildroot/share/fonts/genallfont.sh

118 lines
3.4 KiB
Bash
Executable file

#!/usr/bin/env bash
#####################################################################
# genallfont.sh for Marlin
#
# This script will generates font data for language headers
#
# Copyright 2015-2016 Yunhui Fu <yhfudev@gmail.com>
# License: GPL/BSD
#####################################################################
my_getpath () {
local PARAM_DN="$1"
shift
#readlink -f
local DN="${PARAM_DN}"
local FN=
if [ ! -d "${DN}" ]; then
FN=$(basename "${DN}")
DN=$(dirname "${DN}")
fi
cd "${DN}" > /dev/null 2>&1
DN=$(pwd)
cd - > /dev/null 2>&1
echo "${DN}/${FN}"
}
#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") )
if [ ! "${DN_EXEC}" = "" ]; then
DN_EXEC="$(my_getpath "${DN_EXEC}")/"
else
DN_EXEC="${DN_EXEC}/"
fi
#####################################################################
EXEC_WXGGEN="${DN_EXEC}/uxggenpages.sh"
EXEC_BDF2U8G=`which bdf2u8g`
echo "0 set EXEC_BDF2U8G=$EXEC_BDF2U8G"
if [ ! -x "${EXEC_BDF2U8G}" ]; then
EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g"
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="${DN_EXEC}/marlin-6x12-3.bdf"
if [ ! "$1" = "" ]; then
FN_FONT="$1"
fi
DN_FONT0=`dirname ${FN_FONT}`
DN_FONT="$(my_getpath ${DN_FONT0})"
FN_FONT="$(my_getpath "${DN_FONT}")/"`basename ${FN_FONT}`
[ -z "${FN_FONT}" ] && FN_FONT=${DN_DATA}/../${FN_FONT_BASE}.bdf
[ -f "${FN_FONT}" ] || FN_FONT=${DN_EXEC}/${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/misc/${FN_FONT_BASE}.bdf"
echo "genallfont.sh: FN_FONT=${FN_FONT}"
DN_WORK=./tmp1
(cd ${DN_EXEC}; gcc -o genpages genpages.c getline.c)
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
echo "INFO: generate Marlin language data for '${LANG}'" >&2
rm -rf ${DN_WORK}/
mkdir -p ${DN_WORK}
cp Configuration.h ${DN_WORK}/
cp src/lcd/language/language_${LANG}.h ${DN_WORK}/
cd ${DN_WORK}/
${EXEC_WXGGEN} "${FN_FONT}"
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 ../
mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/language_data_${LANG}.h
rm -rf ${DN_WORK}/
done
# generate default ASCII font (char range 0-255):
# Marlin/src/lcd/dogm/dogm_font_data_ISO10646_1.h
#if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then
if [ 1 = 1 ]; then
rm -rf ${DN_WORK}/
mkdir -p ${DN_WORK}
cd ${DN_WORK}/
${EXEC_BDF2U8G} -b 1 -e 127 ${FN_FONT} ISO10646_1_5x7 tmp1.h
${EXEC_BDF2U8G} -b 1 -e 255 ${FN_FONT} ISO10646_1_5x7 tmp2.h
cat << EOF >tmp3.h
#include <U8glib.h>
#if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7)
// reduced font (only sysmbols 1 - 127) - saves about 1278 bytes of FLASH
EOF
cat tmp1.h >>tmp3.h
cat << EOF >>tmp3.h
#else
// extended (original) font (sysmbols 1 - 255)
EOF
cat tmp2.h >>tmp3.h
cat << EOF >>tmp3.h
#endif
EOF
cd ..
mv ${DN_WORK}/tmp3.h src/lcd/dogm/dogm_font_data_ISO10646_1.h
fi