Updates to font scripts and fonts documentation
This commit is contained in:
		@@ -5,10 +5,11 @@
 | 
			
		||||
#
 | 
			
		||||
# 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
 | 
			
		||||
#####################################################################
 | 
			
		||||
my_getpath () {
 | 
			
		||||
 | 
			
		||||
my_getpath() {
 | 
			
		||||
  local PARAM_DN="$1"
 | 
			
		||||
  shift
 | 
			
		||||
 | 
			
		||||
@@ -22,22 +23,19 @@ my_getpath () {
 | 
			
		||||
  cd "${DN}" > /dev/null 2>&1
 | 
			
		||||
  DN=$(pwd)
 | 
			
		||||
  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=$(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
 | 
			
		||||
[ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES="$(my_getpath ${DN_EXEC}/../../../genpages)"
 | 
			
		||||
[ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES=$(which genpages)
 | 
			
		||||
[ -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
 | 
			
		||||
[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/../../../bdf2u8g"
 | 
			
		||||
@@ -49,6 +47,7 @@ DN_DATA=$(pwd)/datatmp
 | 
			
		||||
mkdir -p "${DN_DATA}"
 | 
			
		||||
 | 
			
		||||
#####################################################################
 | 
			
		||||
 | 
			
		||||
FONTHOME=/usr/share/fonts
 | 
			
		||||
 | 
			
		||||
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/X11/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
 | 
			
		||||
  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)
 | 
			
		||||
 | 
			
		||||
rm -f tmpa tmpb
 | 
			
		||||
touch tmpa tmpb
 | 
			
		||||
#rm -f ${DN_EXEC}/fontpage_*.h
 | 
			
		||||
rm -f fontpage_*.h
 | 
			
		||||
 | 
			
		||||
cat << EOF > tmp-proc-page.awk
 | 
			
		||||
cat << EOF >"proc.awk"
 | 
			
		||||
BEGIN {
 | 
			
		||||
  cur_page=0;
 | 
			
		||||
  val_begin=0;
 | 
			
		||||
@@ -139,33 +139,36 @@ BEGIN {
 | 
			
		||||
}
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
grep -Hrn _UxGT . | grep '"' | \
 | 
			
		||||
  sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' | \
 | 
			
		||||
  ${EXEC_GENPAGES} | \
 | 
			
		||||
  sort -k 1n -k 2n | uniq | \
 | 
			
		||||
  gawk -v EXEC_PREFIX=${DN_EXEC} -f tmp-proc-page.awk | \
 | 
			
		||||
  while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
 | 
			
		||||
grep -Hrn _UxGT . | grep '"' \
 | 
			
		||||
  | sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \
 | 
			
		||||
  | ${EXEC_GENPAGES} \
 | 
			
		||||
  | sort -k 1n -k 2n | uniq \
 | 
			
		||||
  | gawk -v EXEC_PREFIX=${DN_EXEC} -f "proc.awk" \
 | 
			
		||||
  | while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
 | 
			
		||||
    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 ;
 | 
			
		||||
      #sed -i 's|#include "u8g.h"|#include <U8glib.h>|' ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ;
 | 
			
		||||
    fi ;\
 | 
			
		||||
    grep -A 10000000000 u8g_fntpgm_uint8_t ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h >> tmpa ;\
 | 
			
		||||
    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 ;\
 | 
			
		||||
  done
 | 
			
		||||
 | 
			
		||||
rm -f fontutf8-data.h
 | 
			
		||||
echo "/* Generated by $0 */" >> fontutf8-data.h
 | 
			
		||||
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
 | 
			
		||||
TMPA=$(cat tmpa)
 | 
			
		||||
TMPB=$(cat tmpb)
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user