]> code.delx.au - refind/blob - fonts/mkfont.sh
2f035e516c7ec223015cc82f126cfbbf36b8a20f
[refind] / fonts / mkfont.sh
1 #!/bin/bash
2 #
3 # Program to generate a PNG file suitable for use as a rEFInd font
4 # To obtain a list of available font names, type:
5 #
6 # convert -list font | less
7 #
8 # The font used MUST be a monospaced font; searching for the string
9 # "Mono" will turn up most suitable candidates.
10 #
11 # Usage:
12 # ./mkfont.sh font-name font-size font-Y-offset bitmap-filename.png
13 #
14 # This script is part of the rEFInd package. Version numbers refer to
15 # the rEFInd version with which the script was released.
16 #
17 # Version history:
18 #
19 # 0.6.6 - Initial release
20
21 if [[ $# != 4 ]] ; then
22 echo "Usage: $0 font-name font-size y-offset bitmap-filename.png"
23 echo " font-name: Name of font (use 'convert -list font | less' to get list)"
24 echo " NOTE: Font MUST be monospaced!"
25 echo " font-size: Font size in points"
26 echo " y-offset: pixels font is shifted (may be negative)"
27 echo " bitmap-filename.png: output filename"
28 echo ""
29 exit 1
30 fi
31
32 Convert=`which convert 2> /dev/null`
33 if [[ ! -x $Convert ]] ; then
34 echo "The 'convert' program is required but could not be found. It's part of the"
35 echo "ImagMagick program, usually installed in the 'imagemagick' package."
36 echo ""
37 exit 1
38 fi
39
40 Height=$2
41 let CellWidth=(${Height}*6+5)/10
42 let Width=${CellWidth}*96
43 echo "Creating ${Width}x${Height} font bitmap...."
44 $Convert -size ${Width}x${Height} xc:transparent -gravity NorthWest -font $1 -pointsize $2 \
45 -draw "text 0,$3 ' !\"#\$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~?'" $4