arduinoprojects

git clone https://git.tarina.org/arduinoprojects
Log | Files | Refs

makefonts.sh (1221B)


      1 #!/bin/bash
      2 
      3 # Ugly little Bash script, generates a set of .h files for GFX using
      4 # GNU FreeFont sources.  There are three fonts: 'Mono' (Courier-like),
      5 # 'Sans' (Helvetica-like) and 'Serif' (Times-like); four styles: regular,
      6 # bold, oblique or italic, and bold+oblique or bold+italic; and four
      7 # sizes: 9, 12, 18 and 24 point.  No real error checking or anything,
      8 # this just powers through all the combinations, calling the fontconvert
      9 # utility and redirecting the output to a .h file for each combo.
     10 
     11 # Adafruit_GFX repository does not include the source outline fonts
     12 # (huge zipfile, different license) but they're easily acquired:
     13 # http://savannah.gnu.org/projects/freefont/
     14 
     15 convert=./fontconvert
     16 inpath=~/Desktop/freefont/
     17 outpath=../Fonts/
     18 fonts=(FreeMono FreeSans FreeSerif)
     19 styles=("" Bold Italic BoldItalic Oblique BoldOblique)
     20 sizes=(9 12 18 24)
     21 
     22 for f in ${fonts[*]}
     23 do
     24 	for index in ${!styles[*]}
     25 	do
     26 		st=${styles[$index]}
     27 		for si in ${sizes[*]}
     28 		do
     29 			infile=$inpath$f$st".ttf"
     30 			if [ -f $infile ] # Does source combination exist?
     31 			  then
     32 				outfile=$outpath$f$st$si"pt7b.h"
     33 #				printf "%s %s %s > %s\n" $convert $infile $si $outfile
     34 				$convert $infile $si > $outfile
     35 			fi
     36 		done
     37 	done
     38 done