-
Notifications
You must be signed in to change notification settings - Fork 4
/
xfont-install.zsh
executable file
·91 lines (71 loc) · 2.21 KB
/
xfont-install.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#! /usr/bin/env zsh
# Create a X Windows PCF font from a BDF.
#
# See README for more details.
usage="Usage: ${0:t} FONT-NAME.bdf
Generate and install a PCF.
To start a new font, copy an existing BDF:
cp .../orp-medium.bdf lib/my-font.bdf
Hack your new font:
gbdfed lib/my-font.bdf
Install it:
$0:t lib/my-font.bdf
"
# Check for a bunch of misuses.
[[ $# > 0 ]] || { print $usage; exit 1 }
bdf=${1?Must provide font.bdf file}
[[ -f $bdf ]] || { print "ERROR: missing $bdf file.\n\n$usage"; exit 1 }
[[ $bdf:t:e == 'bdf' ]] || { print "ERROR: only will work with .bdf files.\n\n$usage"; exit 1 }
bdfdir=$bdf:h
font=$bdf:t:r
cd $0:h
basedir=$PWD
cd -
libdir=$basedir/lib
[[ -d $libdir ]] || { print $usage; exit 1 }
# Do the generation work from the local misc dir.
pcfdir=$PWD/misc
[[ -d $pcfdir ]] || { print "INFO: creating a misc dir to sit on your font path"; mkdir $pcfdir }
# Mysterious temp file.
trunc="$font-trunc"
# Needed for something UTF stuff.
utfs=$libdir/8859-1.TXT
# Check for system utility dependencies.
deps=( ucs2any bdftopcf mkfontdir gzip xset )
print "Checking for dependencies…"
for d in $deps; do
which $d >/dev/null || {
print "missing $d"
exit 1
}
done
pushd $bdfdir
# Generate intermediate truncated file.
# Performance workaround for sparse fonts.
# Taken out of package:
# http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz
../bdftruncate.pl 'U+3200' <$font.bdf >$trunc.bdf
# Generate BDF fonts containing subsets of ISO 10646-1 codepoints.
ucs2any +d $font.bdf $utfs ISO8859-1
# Generate the PCF.
bdftopcf $trunc.bdf >$font.pcf
# Remove mysterious generated file.
rm -f ${font}-ISO8859-1.bdf
# Turn into compressed/usable form.
gzip -f -9 $font.pcf
# Clean up junk.
rm $trunc.bdf
pushd $pcfdir
mv ~1/$font.pcf.gz .
# Add this new PCF-GZ to $PWD/fonts.dir
mkfontdir
# Tell X that this font is now available.
# Stupid stupid xsel bug makes adding multiple times cause duplicate
# path entries, so have to delete the dir (which successfully removes
# all duplicates), and then add. Use `xset q` to see everything.
xset -fp $PWD
xset +fp $PWD
# Show new font path.
xset q |grep -A1 'Font Path:'
print "\nYou can remove this path if you messed up with:"
print " xset -fp $PWD"