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