about summary refs log tree commit diff
path: root/test/pbmtext-bdf.test
blob: 1bd7c52c803c321643457291652f3d1068365609 (plain) (blame)
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
92
93
94
95
96
97
98
99
#! /bin/bash
# This script tests: pbmtext
# Also requires:

tmpdir=${tmpdir:-/tmp}

font_bdf=${tmpdir}/font.bdf
font_corrupt_bdf=${tmpdir}/fontcorrupt.bdf

# Though this BDF font file defines only three letters, it is valid.

cat > ${font_bdf} << EOF
STARTFONT 2.1
COMMENT simple font for pbmtext test
COMMENT derived from: $XFree86: xc/fonts/bdf/misc/micro.bdf,v 1.1 1999/09/25 14:36:34 dawes Exp $
FONT test
SIZE 4 75 75
FONTBOUNDINGBOX 4 5 0 0
STARTPROPERTIES 5
FONT_DESCENT 0
FONT_ASCENT 5
CHARSET_REGISTRY "ISO88591"
CHARSET_ENCODING "1"
COPYRIGHT "Public domain font.  Share and enjoy."
ENDPROPERTIES
CHARS 3
STARTCHAR A
ENCODING 65
SWIDTH 1000 0
DWIDTH 4 0
BBX 4 5 0 0
BITMAP
e0
a0
e0
a0
a0
ENDCHAR
STARTCHAR B
ENCODING 66
SWIDTH 1000 0
DWIDTH 4 0
BBX 4 5 0 0
BITMAP
e0
a0
c0
a0
e0
ENDCHAR
STARTCHAR C
ENCODING 67
SWIDTH 1000 0
DWIDTH 4 0
BBX 4 5 0 0
BITMAP
e0
80
80
80
e0
ENDCHAR
ENDFONT
EOF

# Test 1
# This should succeed and produce 386826492 35
pbmtext -font ${font_bdf} ABC | cksum


# Test 2
# The rest should all fail.  Writes 1 seven times.

echo "Test whether corrupted BDF font files are properly handled." 1>&2
echo "Error messages will appear." 1>&2
echo 1>&2

pbmtext -font ${font_bdf} BCD
echo $?

sed 's/FONTBOUNDINGBOX 4 5 0 0/FONTBOUNDINGBOX 4 4 0 0/' \
  ${font_bdf} >  ${font_corrupt_bdf}
pbmtext -font ${font_corrupt_bdf} ABC > /dev/null
echo $?
rm ${font_corrupt_bdf}

sed 's/BBX 4 5 0 0/BBX 4 6 0 0/' \
  ${font_bdf} >  ${font_corrupt_bdf}
pbmtext -font ${font_corrupt_bdf} ABC > /dev/null
echo $?
rm ${font_corrupt_bdf}

for delete_line in 14 16 18 20
  do
  sed "${delete_line}"d ${font_bdf} >  ${font_corrupt_bdf}
  pbmtext -font ${font_corrupt_bdf} ABC > /dev/null
  echo $?
  rm ${font_corrupt_bdf}
  done