#! /bin/csh # Last edited on 2011-11-07 19:12:27 by stolfi set usage = "$0 [ -font FONTNAME ] [ -size SIZE ] < INFILE.iso > OUTFILE.ps" set font = "Courier" set size = 10 set expand = "/usr/bin/expand" set sed = "/bin/sed" set psquote = "${STOLFIHOME}/bin/${PLATFORM}/psquote" while ( ( $#argv > 0 ) && ( "x$1" =~ x-* ) ) if ( ( $#argv >= 2 ) && ( "x$1" == "x-font" ) ) then set font = "$2" shift; shift else if ( ( $#argv >= 2 ) && ( "x$1" == "x-size" ) ) then set size = "$2" shift; shift else echo "usage: ${usage}"; exit 1 endif end if ( $#argv > 0 ) then echo "usage: ${usage}"; exit 1 endif /bin/cat < % Tests whether character CHARNAME is defined in the given FONT exch % stack: CHARNAME FONT dup % stack: CHARNAME FONT FONT /Metrics known { /Metrics get } { /CharStrings get } ifelse % stack: CHARNAME DICT 1 index known { % stack: CHARNAME pop } { % stack: CHARNAME (undefined:) == == } ifelse } def /reencode { % NEWENC NEWNAME OLDNAME --> % Creates a new font NEWNAME equal to OLDNAME with the encoding % modified by the given NEWENC. The latter is a vector; each element % is either the index of the slot to be redefined next, % of the name that is to be stored in the current slot % (which gets incremented). % stack: NEWENC NEWNAME OLDNAME findfont begin % stack: NEWENC NEWNAME % Create new font: currentdict dup length dict begin % stack: NEWENC NEWNAME OLDFONT { % stack: NEWENC NEWNAME KEY VAL 1 index /FID ne { def } { pop pop } ifelse } forall % stack: NEWENC NEWNAME /FontName exch def % stack: NEWENC dup length 0 eq { pop } { % stack: NEWENC /Encoding Encoding 256 array copy def % stack: NEWENC 0 exch % stack: 0 NEWENC { % stack: CHNUM ENCELEM dup type /nametype eq { % stack: CHNUM CHNAME % check if defined dup currentdict exch % stack: CHNUM CHNAME NEWFONT CHNAME testcharname % stack: CHNUM CHNAME Encoding 2 index 2 index put % stack: CHNUM CHNAME pop 1 add } { % stack: CHNUM CHNUM2 exch pop } ifelse % stack: CHNUM } forall % stack: CHNUM pop } ifelse % stack: currentdict dup % stack: NEWFONT NEWFONT end % NEWFONT % stack: NEWFONT NEWFONT end % OLDFONT % stack: NEWFONT NEWFONT /FontName get exch % stack: NEWNAME NEWFONT 1 index == definefont pop } def /isoenc [ 160 /space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright 170 /ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior 180 /acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf 190 /threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla 200 /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde 210 /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex 220 /Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring 230 /ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis 240 /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave 250 /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis ] def /isoencode { % NEWNAME OLDNAME % Reencodes the font OLDNAME with the iso encoding, defines % it as NEWNAME isoenc 3 1 roll reencode } def /top 750 def /bottom 50 def /margin 35 def /topleft { margin top } def /fontsize { ${size} } def save (hello!) == /font /${font} findfont isoencode /font findfont fontsize scalefont setfont /bol { % Called on beginning-of-line, checks for space currentpoint exch pop bottom lt { showpage init } if } def /eol { % STRING -> % Called at end-of-line, positions cursor for next line show currentpoint exch pop margin exch moveto 0 fontsize neg rmoveto } def /init { topleft moveto } def init EOF /bin/cat \ | ${expand} \ | ${psquote} \ | ${sed} -e 's@^\(.*\)$@bol (\1) eol@g' /bin/cat <