[comp.lang.postscript] Adding IBM-PC graphic chars to a ps font

BEC.SHAPIN@ECLA.USC.EDU (Ted Shapin) (03/09/88)

%This shows how to add IBM-PC line graphic characters to
%the PostScript Courier Font. (Not all graphics are here.)
%x%x%x% cut here %x%x%
%%Title: Courier font with added IBM-PC line graphics
%%Creator: Ted Shapin, Beckman Instruments; (based upon Adobe info)
%%CreationDate: 2/29/88

userdict /Bproc known not {/Bproc 15 dict def
 Bproc begin
 /charStr (.) def
 /foo
  {Bproc begin /char exch def  /fd exch def save
   /Courier findfont 1000 scalefont setfont

   char 179 lt char 199 eq or{
     charStr 0 char put
     /chnm (others) def
     fd /CharProcs get
     dup chnm known {chnm} {/.notdef} ifelse
     get newpath exec}

    {/chnm fd /Encoding get
     char get def
     fd /CharProcs get
     dup chnm known {chnm} {/.notdef} ifelse
     get 
     600 0 0 0 600 1000 setcachedevice newpath 
     exec} ifelse         %% char lt 179

   restore end
 } def        %% of /foo
end} if    %% of not known

/newfont 10 dict def
newfont begin
/FontType 3 def
/FontMatrix [.001 0 0 .001 0 0] def
/FontBBox [0 0 600 1000] def
/Encoding 256 array def
/BuildChar { Bproc /foo get exec} def
0 1 255 {Encoding exch dup put} for

%Encoding  17 /ltri    put
Encoding 179 /cvbar   put
Encoding 185 /dvdlbar put
Encoding 186 /dvbar   put
Encoding 187 /tdcr    put
Encoding 188 /bdcr    put
Encoding 191 /tccr    put
Encoding 192 /bccl    put
Encoding 196 /chbar   put
Encoding 200 /bdcl    put
Encoding 201 /tdcl    put
Encoding 203 /dhddbar put
Encoding 204 /dvdrbar put
Encoding 205 /dhbar   put
Encoding 217 /bccr    put
Encoding 218 /tccl    put

/CharProcs 20 dict def
CharProcs begin

/.notdef{} def

/cvbar{                %179
       300    0 moveto
       300 1000 lineto
        40 setlinewidth
         stroke } def

/dvdlbar{     %185
         0  600 moveto
       200  600 lineto
       200 1000 lineto
         0  400 moveto
       200  400 lineto
       200    0 moveto
       200  400 lineto
       400    0 moveto
       400 1000 lineto
        40 setlinewidth
         stroke} def


/dvbar{   %186
      200    0 moveto
      200 1000 lineto
      400    0 moveto
      400 1000 lineto
      40 setlinewidth
        stroke} def

/tdcr{   %187
        0  400 moveto
      200  400 lineto
      200    0 moveto
      200  400 lineto
        0  600 moveto
      400  600 lineto
      400    0 moveto
      400  600 lineto
      40 setlinewidth
        stroke} def

/bdcr{   %188
        0  600 moveto
      200  600 lineto
      200 1000 lineto
        0  400 moveto
      400  400 lineto
      400 1000 lineto
      40 setlinewidth
        stroke} def

/tccr{   %191
      300    0 moveto
      300  500 lineto
        0  500 moveto
      300  500 lineto
      40 setlinewidth
        stroke} def

/bccl{   %192
      300  500 moveto
      300 1000 lineto
      300  500 moveto
      600  500 lineto
      40 setlinewidth
        stroke} def

/chbar{   %196
        0  500 moveto
      600  500 lineto
      40 setlinewidth
        stroke} def

/bdcl{   %200
      200  400 moveto
      200 1000 lineto
      200  400 moveto
      600  400 lineto
      400  600 moveto
      400 1000 lineto
      400  600 moveto
      600  600 lineto
      40 setlinewidth
        stroke} def

/tdcl{   %201
      200    0 moveto
      200  600 lineto
      600  600 lineto
      400    0 moveto
      400  400 lineto
      600  400 lineto
      40 setlinewidth
        stroke} def


/dhddbar{   %203
        0  400 moveto
      200  400 lineto
      200    0 moveto
      200  400 lineto
      400    0 moveto
      400  400 lineto
      600  400 lineto
        0  600 moveto
      600  600 lineto
      40 setlinewidth
        stroke} def

/dvdrbar{   %204
      400    0 moveto
      400  400 lineto
      600  400 lineto
      400  600 moveto
      400 1000 lineto
      400  600 moveto
      600  600 lineto
      200    0 moveto
      200 1000 lineto
      40 setlinewidth
        stroke} def

/dhbar{   %205
        0  400 moveto
      600  400 lineto
        0  600 moveto
      600  600 lineto
      40 setlinewidth
        stroke} def

/bccr{   %217
        0  500 moveto
      300  500 lineto
      300 1000 lineto
      40 setlinewidth
        stroke} def

/tccl{   %218
      300    0 moveto
      300  500 lineto
      600  500 lineto
      40 setlinewidth
        stroke} def

/ltri{  %17
      200  325 moveto
      900  750 lineto
      900    0 lineto
      closepath fill
      } def



/others {600 0 0 -200 600 1000 setcachedevice newpath 0 0 moveto
charStr show } def

end  % of CharProcs

end

/Courier-G newfont definefont pop
% *************************************
%  Now print out the whole font  
%--------Variables & Procedures
/textfont {/Courier findfont 10 scalefont setfont }def
/zfont {/Courier-G findfont 10 scalefont setfont }def
/char 1 string def
/nstr 3 string def

/newline
 {currentpoint 11 sub
  exch pop LM
  exch moveto} def

/prt-n   %stack:code
 {textfont nstr cvs show} def
  
/prtchar     %stack:code
 {zfont
  char 0
  3 -1 roll put
  char show} def
  

/PrintCodeandChar  %stack:code
 {dup prt-n
  ( )show
  prtchar newline} def

%--------Begin Program -------
/LM 72 def
LM 750 moveto
0 1 63{PrintCodeandChar} for

/LM 144 def
LM 750 moveto
64 1 127{PrintCodeandChar} for

/LM 216 def
LM 750 moveto
128 1 191 {PrintCodeandChar} for

/LM 288 def
LM 750 moveto
192 1 255 {PrintCodeandChar} for

showpage

-------