1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-26 05:17:17 +00:00

🔨 Update font scripts

This commit is contained in:
Scott Lahteine 2023-03-01 19:07:47 -06:00
parent 030559bf7f
commit 6a8ebddaf6
10 changed files with 1263 additions and 104 deletions

3
.gitignore vendored
View File

@ -21,7 +21,8 @@
# Generated files
_Version.h
bdf2u8g
bdf2u8g.exe
genpages.exe
marlin_config.json
mczip.h
*.gen

View File

@ -0,0 +1,15 @@
CFLAGS = -g -Wall
#CFLAGS = -O4 -Wall
SRC = bdf2u8g.c
OBJ = $(SRC:.c=.o)
bdf2u8g: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o bdf2u8g.exe
clean:
-rm $(OBJ) bdf2u8g.exe
test:
./bdf2u8g.exe -f 2 ../bdf/9x18.bdf u8g_aafont_9x18 u8g_aafont_9x18.c

File diff suppressed because it is too large Load Diff

View File

@ -24,19 +24,9 @@ my_getpath() {
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=$(dirname $(my_getpath "$0") )
EXEC_WXGGEN="${DN_EXEC}/uxggenpages.sh"
#
# Locate the bdf2u8g command
#
EXEC_BDF2U8G=`which bdf2u8g`
[ -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; }
#
# Get language arguments
#
@ -55,9 +45,19 @@ OLDWD=`pwd`
[[ -f "Configuration.h" ]] || { echo -n "cd to the 'Marlin' folder to run " ; basename $0 ; exit 1; }
#
# Compile the 'genpages' command in-place
# Compile the 'genpages.exe' and 'bdf2u8g.exe' commands in-place
#
(cd ${DN_EXEC}; cc -o genpages genpages.c getline.c)
if [[ ! -x "${DN_EXEC}/genpages/genpages.exe" ]]; then
echo "Building genpages.exe..."
( cd ${DN_EXEC}/genpages ; cc -o genpages.exe genpages.c getline.c )
[[ -x "${DN_EXEC}/genpages/genpages.exe" ]] || { echo "Build of genpages.exe failed" ; exit 1 ; }
fi
if [[ ! -x "${DN_EXEC}/bdf2u8g/bdf2u8g.exe" ]]; then
echo "Building bdf2u8g.exe..."
( cd ${DN_EXEC}/bdf2u8g ; make )
[[ -x "${DN_EXEC}/bdf2u8g/bdf2u8g.exe" ]] || { echo "Build of bdf2u8g.exe failed" ; exit 1 ; }
fi
#
# By default loop through all languages
@ -74,11 +74,11 @@ for LANG in ${LANG_ARG:=$LANGS_DEFAULT} ; do
ko_* ) FONTFILE="${DN_EXEC}/NanumGothic.bdf" ;;
* ) FONTFILE="${DN_EXEC}/marlin-6x12-3.bdf" ;;
esac
DN_WORK=`mktemp -d`
DN_WORK=$(mktemp -d)
cp Configuration.h ${DN_WORK}/
cp src/lcd/language/language_${LANG}.h ${DN_WORK}/
cd "${DN_WORK}"
${EXEC_WXGGEN} "${FONTFILE}"
${DN_EXEC}/uxggenpages.sh "${FONTFILE}" $LANG
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
cd - >/dev/null
mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/fontdata/langdata_${LANG}.h
@ -89,9 +89,10 @@ done
# Generate default ASCII font (char range 0-255):
# Marlin/src/lcd/dogm/fontdata/fontdata_ISO10646_1.h
#
EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g/bdf2u8g.exe"
#if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then
if [ 1 = 1 ]; then
DN_WORK=`mktemp -d`
DN_WORK=$(mktemp -d)
cd ${DN_WORK}
${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
@ -103,7 +104,7 @@ if [ 1 = 1 ]; then
cat <<EOF >src/lcd/dogm/fontdata/fontdata_ISO10646_1.h
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
@ -139,6 +140,4 @@ EOF
fi
(cd ${DN_EXEC}; rm genpages)
cd "$OLDWD"

View File

@ -66,7 +66,7 @@ wchar_t get_val_utf82uni(uint8_t *pstart) {
*/
uint8_t* get_utf8_value(uint8_t *pstart, wchar_t *pval) {
uint32_t val = 0;
const uint8_t *p = pstart;
uint8_t *p = pstart;
/*size_t maxlen = strlen(pstart);*/
assert(NULL != pstart);

View File

@ -1,35 +0,0 @@
#!/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)
for CMD in curl unzip patch make; do
which $CMD >/dev/null || { echo "'$CMD' is required for this script." ; exit 1 ; }
done
[[ $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,32 +0,0 @@
178c178
< fprintf(out_fp, "%d", data_buf[i]);
---
> fprintf(out_fp, "0x%02x", data_buf[i]);
180c180
< fprintf(out_fp, "%3d", data_buf[i]);
---
> fprintf(out_fp, "0x%02x", data_buf[i]);
487c487,488
< int bdf_delta_x; /* DWIDTH arg 1 */
---
> int bdf_delta_x_default = -1;
> int bdf_delta_x = -1; /* DWIDTH arg 1 */
1097a1099,1114
> else if ( strcmp(p_buf, "CHARS") == 0 )
> {
> if (bdf_delta_x < 0) {
> bdf_delta_x = 0;
> }
> 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;
> }
1293d1309
< fprintf(out_fp, "#include \"u8g.h\"\n");

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash
#####################################################################
# genpages.sh for u8g
# uxggenpages.sh for u8g
#
# This script will generate u8g c files for specified fonts
#
# Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com>
# License: GPL/BSD
# License: BSD
#####################################################################
my_getpath() {
@ -31,16 +31,11 @@ DN_EXEC=$(dirname $(my_getpath "$0") )
#####################################################################
EXEC_GENPAGES=${DN_EXEC}/genpages
[ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES="$(my_getpath ${DN_EXEC}/../../../genpages)"
[ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES=$(which genpages)
EXEC_GENPAGES=${DN_EXEC}/genpages/genpages.exe
[ -x "${EXEC_GENPAGES}" ] || { echo "Error: genpages not found!" ; exit 1; }
#echo "EXEC_GENPAGES=${EXEC_GENPAGES}"
EXEC_BDF2U8G=${DN_EXEC}/bdf2u8g
[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/../../../bdf2u8g"
[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G=$(which bdf2u8g)
[ -x "${EXEC_BDF2U8G}" ] || { echo "Error: bdf2u8g not found!" ; echo "Please compile u8glib/tools/font/bdf2u8g/bdf2u8g and link to it from here!"; exit 1; }
EXEC_BDF2U8G=${DN_EXEC}/bdf2u8g/bdf2u8g.exe
[ -x "${EXEC_BDF2U8G}" ] || { echo "Error: bdf2u8g not found!" ; exit 1; }
DN_CUR=$(pwd)
DN_DATA=$(pwd)/datatmp
@ -56,6 +51,7 @@ FN_FONT_BASE="marlin-6x12-3"
#FN_FONT_BASE=wenquanyi_9pt
FN_FONT="${1:-}"
LANG="$2"
DN_FONT0=`dirname ${FN_FONT}`
DN_FONT="$(my_getpath ${DN_FONT0})"
FN_FONT="$(my_getpath "${DN_FONT}")/"`basename ${FN_FONT}`
@ -151,14 +147,14 @@ grep -Hrn _UxGT . | grep '"' \
${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 ;
fi ; \
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
TMPA=$(cat tmpa)
TMPB=$(cat tmpb)
EOL=$'\n'
[[ ! "$TMPA" == "" ]] && TMPA="$EOL$TMPA$EOL"
[[ ! "$TMPA" == "" ]] && TMPA="$TMPA$EOL$EOL"
[[ ! "$TMPB" == "" ]] && TMPB="$EOL$TMPB$EOL"
rm -f tmpa tmpb "proc.awk"
@ -169,8 +165,9 @@ cat <<EOF >fontutf8-data.h
* Contents will be REPLACED by future processing!
* Use genallfont.sh to generate font data for updated languages.
*/
#include <U8glib-HAL.h>
$TMPA
#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data }
static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {$TMPB};
#pragma once
#include "langdata.h"
${TMPA}static const uxg_fontinfo_t g_fontinfo_${LANG}[] PROGMEM = {${TMPB}};
EOF