My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

uxggenpages.sh 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #!/usr/bin/env bash
  2. #####################################################################
  3. # genpages.sh for u8g
  4. #
  5. # This script will generate u8g c files for specified fonts
  6. #
  7. # Copyright 2015-2018 Yunhui Fu <yhfudev@gmail.com>
  8. # License: GPL/BSD
  9. #####################################################################
  10. my_getpath() {
  11. local PARAM_DN="$1"
  12. shift
  13. #readlink -f
  14. local DN="${PARAM_DN}"
  15. local FN=
  16. if [ ! -d "${DN}" ]; then
  17. FN=$(basename "${DN}")
  18. DN=$(dirname "${DN}")
  19. fi
  20. cd "${DN}" > /dev/null 2>&1
  21. DN=$(pwd)
  22. cd - > /dev/null 2>&1
  23. echo -n "${DN}"
  24. [[ -z "$FN" ]] || echo -n "/${FN}"
  25. }
  26. #DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'`
  27. DN_EXEC=$(dirname $(my_getpath "$0") )
  28. #####################################################################
  29. EXEC_GENPAGES=${DN_EXEC}/genpages
  30. [ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES="$(my_getpath ${DN_EXEC}/../../../genpages)"
  31. [ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES=$(which genpages)
  32. [ -x "${EXEC_GENPAGES}" ] || { echo "Error: genpages not found!" ; exit 1; }
  33. #echo "EXEC_GENPAGES=${EXEC_GENPAGES}"
  34. EXEC_BDF2U8G=${DN_EXEC}/bdf2u8g
  35. [ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/../../../bdf2u8g"
  36. [ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G=$(which bdf2u8g)
  37. [ -x "${EXEC_BDF2U8G}" ] || { echo "Error: bdf2u8g not found!" ; echo "Please compile u8glib/tools/font/bdf2u8g/bdf2u8g and link to it from here!"; exit 1; }
  38. DN_CUR=$(pwd)
  39. DN_DATA=$(pwd)/datatmp
  40. mkdir -p "${DN_DATA}"
  41. #####################################################################
  42. FONTHOME=/usr/share/fonts
  43. FN_FONT_BASE="marlin-6x12-3"
  44. #FN_FONT_BASE=unifont
  45. #FN_FONT_BASE=wenquanyi_12pt
  46. #FN_FONT_BASE=wenquanyi_9pt
  47. FN_FONT="${1:-}"
  48. DN_FONT0=`dirname ${FN_FONT}`
  49. DN_FONT="$(my_getpath ${DN_FONT0})"
  50. FN_FONT="$(my_getpath "${DN_FONT}")/"`basename ${FN_FONT}`
  51. [ -z "${FN_FONT}" ] && FN_FONT=${DN_DATA}/../${FN_FONT_BASE}.bdf
  52. [ -f "${FN_FONT}" ] || FN_FONT=${DN_EXEC}/${FN_FONT_BASE}.bdf
  53. [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/wenquanyi/${FN_FONT_BASE}.bdf"
  54. [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/X11/misc/${FN_FONT_BASE}.bdf"
  55. [ -f "${FN_FONT}" ] || FN_FONT="$FONTHOME/misc/${FN_FONT_BASE}.bdf"
  56. #echo "uxggenpages.sh: FN_FONT=${FN_FONT}"
  57. if [ ! -f "${FN_FONT}" ]; then
  58. FN_FONT_PCF="$FONTHOME/X11/misc/${FN_FONT_BASE}.pcf"
  59. [ -f "${FN_FONT_PCF}" ] || FN_FONT_PCF="$FONTHOME/misc/${FN_FONT_BASE}.pcf"
  60. [ -f "${FN_FONT_PCF}" ] || FN_FONT_PCF="$FONTHOME/wenquanyi/${FN_FONT_BASE}.pcf"
  61. if [ -f "${FN_FONT_PCF}" ]; then
  62. EXEC_PCF2BDF=$(which pcf2bdf)
  63. if [ ! -x "${EXEC_PCF2BDF}" ]; then
  64. echo "Error: not found pcf2bdf!"
  65. echo " Please install pcf2bdf."
  66. exit 1
  67. fi
  68. FN_FONT="./${FN_FONT_BASE}.bdf"
  69. echo ${EXEC_PCF2BDF} -o "${FN_FONT}" "${FN_FONT_PCF}"
  70. ${EXEC_PCF2BDF} -o "${FN_FONT}" "${FN_FONT_PCF}"
  71. fi
  72. fi
  73. [ -f "${FN_FONT}" ] || { echo "Error: can't find font ${FN_FONT}!" ; exit 1; }
  74. #####################################################################
  75. #(cd ${DN_EXEC}; gcc -o genpages genpages.c getline.c)
  76. rm -f tmpa tmpb
  77. touch tmpa tmpb
  78. #rm -f ${DN_EXEC}/fontpage_*.h
  79. rm -f fontpage_*.h
  80. cat << EOF >"proc.awk"
  81. BEGIN {
  82. cur_page=0;
  83. val_begin=0;
  84. val_pre=0;
  85. utf8_pre="";
  86. utf8_begin="";
  87. }{
  88. page=\$1;
  89. val_real=\$2;
  90. utf8=\$3;
  91. # assert (val_real < 128);
  92. val=val_real + 128;
  93. if (cur_page != page) {
  94. if (cur_page != 0) {
  95. if (val_begin != 0) {
  96. print cur_page " " val_begin " " val_pre " " utf8_begin " " utf8_pre;
  97. }
  98. }
  99. cur_page=page;
  100. val_begin=val;
  101. val_pre=val;
  102. utf8_begin=utf8;
  103. utf8_pre=utf8;
  104. } else {
  105. if (val_pre + 1 != val) {
  106. if (cur_page != 0) {
  107. print cur_page " " val_begin " " val_pre " " utf8_begin " " utf8_pre;
  108. }
  109. val_begin=val;
  110. val_pre=val;
  111. utf8_begin=utf8;
  112. utf8_pre=utf8;
  113. } else {
  114. val_pre = val;
  115. utf8_pre=utf8;
  116. }
  117. }
  118. } END {
  119. if (cur_page != 0) {
  120. print cur_page " " val_begin " " val_pre " " utf8_begin " " utf8_pre;
  121. }
  122. }
  123. EOF
  124. AWK=$(which gawk || which awk)
  125. grep -Hrn _UxGT . | grep '"' \
  126. | sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \
  127. | ${EXEC_GENPAGES} \
  128. | sort -k 1n -k 2n | uniq \
  129. | "$AWK" -v EXEC_PREFIX=${DN_EXEC} -f "proc.awk" \
  130. | while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
  131. if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \
  132. ${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 ;
  133. fi ; \
  134. grep -A 10000000000 u8g_fntpgm_uint8_t ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h >> tmpa ; \
  135. echo " FONTDATA_ITEM(${PAGE}, ${BEGIN}, ${END}, fontpage_${PAGE}_${BEGIN}_${END}), // '${UTF8BEGIN}' -- '${UTF8END}'" >> tmpb ;\
  136. done
  137. TMPA=$(cat tmpa)
  138. TMPB=$(cat tmpb)
  139. EOL=$'\n'
  140. [[ ! "$TMPA" == "" ]] && TMPA="$EOL$TMPA$EOL"
  141. [[ ! "$TMPB" == "" ]] && TMPB="$EOL$TMPB$EOL"
  142. rm -f tmpa tmpb "proc.awk"
  143. cat <<EOF >fontutf8-data.h
  144. /**
  145. * Generated automatically by buildroot/share/fonts/uxggenpages.sh
  146. * Contents will be REPLACED by future processing!
  147. * Use genallfont.sh to generate font data for updated languages.
  148. */
  149. #include <U8glib-HAL.h>
  150. $TMPA
  151. #define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data }
  152. static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {$TMPB};
  153. EOF