#!/usr/bin/env bash

# List of GMT fonts
dy=-0.2222
y0=4.3
yy=4.0778

cat > tt.d << EOF
Helvetica
Helvetica-Bold
Helvetica-Oblique
Helvetica-BoldOblique
Times-Roman
Times-Bold
Times-Italic
Times-BoldItalic
Courier
Courier-Bold
Courier-Oblique
Courier-BoldOblique
Symbol
AvantGarde-Book
AvantGarde-BookOblique
AvantGarde-Demi
AvantGarde-DemiOblique
Bookman-Demi
Bookman-DemiItalic
Bookman-Light
Bookman-LightItalic
Helvetica-Narrow
Helvetica-Narrow-Bold
Helvetica-Narrow-Oblique
Helvetica-Narrow-BoldOblique
NewCenturySchlbk-Roman
NewCenturySchlbk-Italic
NewCenturySchlbk-Bold
NewCenturySchlbk-BoldItalic
Palatino-Roman
Palatino-Italic
Palatino-Bold
Palatino-BoldItalic
ZapfChancery-MediumItalic
ZapfDingbats
EOF

gmt begin GMT_fonts
gmt set MAP_FRAME_PEN thinner
gmt plot -R0/5.4/0/$y0 -Jx1i -B0 << EOF
>
0.3	0
0.3	$y0
>
2.7	0
2.7	$y0
>
3	0
3	$y0
EOF
gmt text -Y${yy}i -F+f10p+jBC << EOF
0.15	0.05	\\043
1.55	0.05	Font Name
2.85	0.05	\\043
4.15	0.05	Font Name
EOF
gmt plot <<EOF
0	0
5.4	0
EOF

let i=1
while [ $i -le 17 ]
do
	i1=$(( i-1 ))
	i2=$(( i1+17 ))
	k1=$i
	k2=$(( i+17 ))

	f1=$(sed -n ${k1}p tt.d)
	f2=$(sed -n ${k2}p tt.d)

	if [ $i1 -eq "12" ]; then
		f1="Symbol @%0%(Symbol)@%%"
	fi
	fn2=$i2
	gmt text -Y${dy}i -F+f+j << EOF
0.15	0.03	10p,$i1		BC	$i1
0.4	0.03	10p,$i1		BL	$f1
2.85	0.03	10p,$fn2	BC	$i2
3.1	0.03	10p,$i2		BL	$f2
EOF
	let i=i+1
done

gmt text -Y${dy}i -F+f+j << EOF
2.85	0.03	10p,Helvetica		BC	34
3.1	0.03	10p,ZapfDingbats	BL	ZapfDingbats @%0%(ZapfDingbats)@%%
EOF

rm tt.d
gmt end show
