#! /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