Here's a python to produce linux console fonts from the font pictures in data/art, and the startup script I use to run dw with them.
You'll need to install the kbd or kbd-compat packages to use setfont, and python-imaging aka the PIL to use the converter.
Go to data/art and do 'python "(the python)" *.psf ' to make the font files, then tweak DF_LIB in the startup script to suit
and run it from the native console. That gets me 160x85.
[14Mar EDIT: fixes -
- Force INTRO:NO to actually use large consoles
- female sign codepoint was wrong
- df2psf.py takes filename arguments (e.g. 'df2psf.py *.png')
- general cleanup]
the python to make the psfs
#!python -B
# $Id: df2psf.py,v 1.2 2011/03/14 21:30:52 jthill Exp jthill $ $Name: $
# $Log: df2psf.py,v $
# Revision 1.2 2011/03/14 21:30:52 jthill
# more convenient file handling, fix female glyph codepoint
#
import Image
# df's unicode mapping, lifted from df2ttf.py
mapping = [
0, 9786, 9787, 9829, 9830, 9827, 9824, 8226, 9688, 9675, 9689, 9794, 9792, 9834, 9835, 9788,
9658, 9668, 8597, 8252, 182, 167, 9644, 8616, 8593, 8595, 8594, 8592, 8735, 8596, 9650, 9660,
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, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 8962,
199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197,
201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 162, 163, 165, 8359, 402,
225, 237, 243, 250, 241, 209, 170, 186, 191, 8976, 172, 189, 188, 161, 171, 187,
9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488,
9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575,
9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600,
945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745,
8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 0]
def le4(i): return unichr(i).encode('utf_32_le')
def df2psf(instream,outstream):
pic=Image.open(instream).convert('1')
w,h=pic.size[0]/16,pic.size[1]/16
psfbits=b''.join([pic.crop((i%16*w,i/16*h,i%16*w+w,i/16*h+h)).tostring() for i in range(256)])
if w == 8:
psfleader=b'\x36\x04\x02' + chr(h)
dfunimap=b''.join([unichr(c).encode('utf_16_le')+b'\xff\xff' for c in mapping])
else:
psfleader=b''.join([ b'\x72\xb5\x4a\x86', le4(0), le4(32), le4(1), le4(256),
le4((w+7)/8*h), le4(h),le4(w) ])
dfunimap=b''.join([unichr(c).encode('utf8')+b'\xff' for c in mapping])
outstream.write(psfleader+psfbits+dfunimap)
if __name__ == '__main__':
import sys,os
if len(sys.argv) > 1:
for f in sys.argv[1:]:
instream=open(f,'rb')
outstream=open(os.path.splitext(os.path.basename(f))[0]+'.psf','wb')
df2psf(instream,outstream)
else: df2psf(os.fdopen(0,'rb'),os.fdopen(1,'wb'))
and a df startup script to use them automatically.
#!/bin/sh
# $Id: dw,v 1.1 2011/03/14 20:31:46 jthill Exp $ $Name: $
# $Log: dw,v $
# Revision 1.1 2011/03/14 20:31:46 jthill
# better compat with non-console use
#
DF_DIR="${DF_DIR:-$HOME/lib/df_linux}"
get_inittxt_fixups () {
eval $(stty size | sed -r 's,([0-9]*) ([0-9]*),LINES=\1 COLUMNS=\2,')
LINES=$((LINES>255?255:LINES))
COLUMNS=$((COLUMNS>255?255:COLUMNS))
sedx=$sedx'/^\[WINDOWED:/ s,:.*,:YES],;'
sedx=$sedx'/^\[WINDOWEDX:/ s,:.*,:'$LINES'],;'
sedx=$sedx'/^\[WINDOWEDY:/ s,:.*,:'$COLUMNS'],;'
sedx=$sedx'/^\[INTRO::/ s,:.*,:NO],;' # YES forces 80x25
}
sedx=''
case `tty` in
/dev/tty*)
eval $(sed -nr "$DF_DIR/data/init/init.txt" \
-e 's/.*\[WINDOWED:([^]]*)\].*/WINDOWED="\1"/p' \
-e 's/.*\[FONT:([^]]*)\].*/FONT="\1"/p' \
-e 's/.*\[FULLFONT:([^]]*)\].*/FULLFONT="\1"/p'
)
if [ -r "$DF_DIR/data/art/${FONT%.*}.psf" ] ; then
savedfont="${TMPDIR:-/tmp}/saved_console_font.psf"
setfont -O "$savedfont"
trap 'setfont $savedfont' 0 1 2 3 15
setfont "$DF_DIR/data/art/${FONT%.*}.psf"
fi
get_inittxt_fixups
sedx=$sedx'/^\[PRINT_MODE:/ s,:.*,:TEXT],;'
;;
*)
# not directly on a console,
get_inittxt_fixups
sedx=$sedx'/^\[PRINT_MODE:/ s,:.*,:2D],;'
;;
esac
sed -re "$sedx" -i "$DF_DIR/data/init/init.txt"
cd "${DF_DIR}"
export SDL_DISABLE_LOCK_KEYS=1 # Work around for bug in Debian/Ubuntu SDL patch.
#export SDL_VIDEO_CENTERED=1 # Centre the screen. Messes up resizing.
./libs/Dwarf_Fortress "$@"