rfc1168.ps

来自「RFC 的详细文档!」· PS 代码 · 共 3,319 行 · 第 1/5 页

PS
3,319
字号
%!PS-Adobe-1.0
%  Copyright 1987 Interleaf, Inc.
%  Ten Canal Park, Cambridge, MA  02141
%%%%%%%%%%%%%%%%%%%%%%%%%
%	PS macros
%%%%%%%%%%%%%%%%%%%%%%%%%
/bdf {bind def} bind def
/xdf {exch def} bdf
/ldd {load def} bdf

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	global constants and variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	Version
%
/PSPRO-VERSION_MAJOR	3 def	%Feb 28, 1987
/PSPRO-VERSION_MINOR	2 def	%Oct 9, 1987
/PSPRO-VERSION_SUB	1 def	%Oct 28, 1987

%
%	Drawing modes
%
/PL_SET 	0 def		%ink black
/PL_CLEAR	1 def		%ink white
/PL_XOR		2 def		%ink by xor'ing source onto page - can PS do it?
/PL_REPLACE	3 def		%ink by replacing, e.g. overlayed bitmaps

%
%	 Default global PS state 
%
/drawmode	PL_SET def	%default is ink black
/useNativeFonts	false def	
/numtextures	21 def		%creator should initialize this
/whitefill	13 def		%FOR NOW, white always position 13 in pat font
/docutmark	false def	%should cropping marks be printed
/invertmatrix [1 0 0 -1 0 0] def

%
%	Font limits
%
/MAXFONT 1024 def
/MAXFONT1 MAXFONT 1 sub def
/MAXCHARS 128 def	%per font
/MAXCHARS1 MAXCHARS 1 sub def
/VMHEADROOM 1000 def
/BOGUSWIDTH -1 def

%%%%%%%%%%%%%%%%%%%%%%%%%
%	Memory Defs
%%%%%%%%%%%%%%%%%%%%%%%%%
/mesg 64 string def
/charname 12 string def
/istr 3 string def
/ILEncoding 256 array def	% New global Encoding vector.
/ILSymEncoding 256 array def	% SymbolB Encoding vector.
/trashheap 1024 string def
/emsg1 256 string def
/emsg2 256 string def

%
%%%%%%%%%%%%%%%%%%%%%%%%%
%	Job Utilities
%%%%%%%%%%%%%%%%%%%%%%%%%
/inch {72 mul} bdf

/headerpage {
  %assumes standard PS state
  /y 9 def
  /nl {/y y 1 sub def 1 inch y inch moveto } bdf
  /#copies 1 def
  /Helvetica-Bold findfont 18 scalefont setfont
  1 inch 1 inch moveto 
  nl nl
  0 1 hline length 1 sub { 
   hline exch get show nl
  } for
  /Helvetica findfont 8 scalefont setfont
  1 inch 1 inch moveto 
  (pl2ps )show PSPRO-VERSION_SUB PSPRO-VERSION_MINOR PSPRO-VERSION_MAJOR vershow
  (   Copyright 1987 Interleaf, Inc. ) show 
  emsg1 0 get 0 ne { 1 inch .75 inch moveto emsg1 show } if
  emsg2 0 get 0 ne { 1 inch .5 inch moveto emsg2 show } if
} bdf

/logme {
  (\tInterleaf::pl2ps ) print
  PSPRO-VERSION_SUB PSPRO-VERSION_MINOR PSPRO-VERSION_MAJOR verprint
  hline length 1 sub  -1  0 { 
    (\tInterleaf::) print hline exch get print (\n) print
  } for
  flush 
} bdf

/verprint {
  10 mesg cvrs print (.) print 
  10 mesg cvrs print (.) print 
  10 mesg cvrs print (\n) print
} bdf
/vershow {
  10 mesg cvrs show (.) show 
  10 mesg cvrs show (.) show
  10 mesg cvrs show 
} bdf
    
/versioncheck {
  /PL2PS-VERSION_MAJOR xdf
  /PL2PS-VERSION_MINOR xdf
  /PL2PS-VERSION_SUB xdf
  /doheader userdict /hline known def
  PL2PS-VERSION_MAJOR PSPRO-VERSION_MAJOR ne 
  PL2PS-VERSION_MINOR PSPRO-VERSION_MINOR ne or
  PL2PS-VERSION_SUB PSPRO-VERSION_SUB ne or {
    doheader {logme } if
    (\tInterleaf:: FATAL ERROR: pspro.ps and pl2ps versions do not agree.) print
    (\n\tInterleaf:: pspro.ps version: \t) print
    PSPRO-VERSION_SUB PSPRO-VERSION_MINOR PSPRO-VERSION_MAJOR verprint
    (\tInterleaf:: pl2ps version: \t) print
    PL2PS-VERSION_SUB PL2PS-VERSION_MINOR PL2PS-VERSION_MAJOR verprint
    flush 
    doheader {headerpage } if
    ( FATAL ERROR. pspro version ) show
    PSPRO-VERSION_SUB PSPRO-VERSION_MINOR PSPRO-VERSION_MAJOR vershow
    ( does not agree with pl2ps version ) show 
    PL2PS-VERSION_SUB PL2PS-VERSION_MINOR PL2PS-VERSION_MAJOR vershow
    showpage
    quit 
  } if
} bdf

%
%%%%%%%%%%%%%%%%%%%%%%%%%
%	Graphics
%%%%%%%%%%%%%%%%%%%%%%%%%
/sw /setlinewidth ldd
/m { /vpos xdf /hpos xdf } bdf %record pl current point, in rsu
/v { /vpos xdf } bdf
/h { /hpos xdf } bdf
/pm /moveto ldd
/as /lineto ldd % add segment 
/av /moveto ldd % add vertex 
% 
%	Add an arc to the current path ala cookbook
%	but note clockwise is opposite sense for us.
% 
/el { 0 begin	
  /endangle xdf /startangle xdf 
  /rotation xdf
  /yrad xdf /xrad xdf
  /yc xdf /xc xdf
  /savematrix matrix currentmatrix def
  xc yc translate
  rotation rotate
  xrad yrad  scale
  0 0 1 startangle  endangle  arc
  savematrix setmatrix
  end
} bdf
/el load 0 8 dict put

/addconic { 0 begin
  %similar to el, but rotation is around local origin
  % after imaging an unrotated ellipse at (xc,yc)
  /clockwise xdf
  /endangle xdf /startangle xdf 
  /rotation xdf
  /yrad xdf /xrad xdf
  /yc xdf /xc xdf	%center in rotated x0-y0 space
	
  /savematrix matrix currentmatrix def
  xc yc translate
  rotation rotate	%rotate the imaged ellipse
  xrad yrad scale
  0 0 1 startangle  endangle  
  clockwise 1 eq {arc} {arcn} ifelse

  savematrix setmatrix
  end
} bdf
/addconic load 0 9 dict put

%
%	Draw current path
%
/dp {
  gsave  
  1 setlinejoin 		% round line ends  
  1 setlinecap 			% round line ends
  drawmode PL_CLEAR eq {1} {0} ifelse setgray %only support two modes 
  stroke 
  grestore  
} bdf 

%
%	Pen pattern routines
%
/ALIGN_NONE 0 def
/ALIGN_OPEN 1 def
/ALIGN_CLOSE 2 def
/PENPATWIDTHADJ [0 0 4 8 12 16 20] def	% WARNING these values are derived 
					% by scaling widthadj[], defined
					% in /usr/xops/lib/crt/scr/pens.c,
					% by the same factor (.4) that the
					% pen patterns were scaled when
					% sent to printerleaf.
/MINSCALE .1 def			% Do not scale pen pattern below 10%
					% of original size.
% 
% Calulates length of current path. Ala cookbook.
%
/pathlength { 0 begin
    flattenpath				% changes all curveto's to lineto's
    /dist 0 def

    { /yfirst xdf /xfirst xdf
      /ymoveto yfirst def /xmoveto xfirst def}
    { /ynext xdf /xnext xdf
      /dist dist ynext yfirst sub dup mul
	xnext xfirst sub dup mul add sqrt add def
      /yfirst ynext def /xfirst xnext def}
    {}

    { /ynext ymoveto def /xnext xmoveto def
      /dist dist ynext yfirst sub dup mul
	xnext xfirst sub dup mul add sqrt add def
      /yfirst ynext def /xfirst xnext def}
    pathforall
    dist
    end
} bdf
/pathlength load 0 7 dict put

/setpenpat { 0 begin		% define penpattern dictionary
    /style xdf			% alignment style 
    /width xdf
    /pattern xdf

    % 
    % Adjust pattern for various pen widths.
    %
    /scaleup DPIx 300 div def		% Seybold hack!!!!
    /indx width 1 add scaleup div 4 div cvi def	% Change width into an index
    indx 1 gt indx 7 lt and {
	/adj PENPATWIDTHADJ indx get def% Get ajustment for specified pen width
	/adj adj scaleup mul def	% from predefined array PENPATWIDTHADJ
					% and scale up to the resolution.
	/indx 0 def
	pattern {
	    /iszero indx 2 mod def	% Add ajustment for pen width
	    iszero 0 ne			% to just "off" phases of pattern.
		{adj add /val xdf}
		{/val xdf}
	    ifelse
	    pattern indx val put
	    /indx indx 1 add def
	} forall
    } if

    %
    % Align pattern to pathlength.
    %
    /offset 0 def
    /patternlen 0 def
    /pathlen pathlength def		% Computes path length.
    pattern				% Compute total len of repeating pattern
	{patternlen add /patternlen xdf
	} forall

    style ALIGN_NONE eq {
    } if
    style ALIGN_CLOSE eq {		% from /usr/xops/lib/crt/scr/pens.c
	/n pathlen patternlen div cvi def
	/extralen pathlen cvi patternlen cvi mod def
	/halfpatlen patternlen 2 div def
	extralen halfpatlen gt {/n n 1 add def} if
	n 0 eq {/n 1 def} if
	/scale1 pathlen n patternlen mul div def
	scale1 MINSCALE gt {
	    /indx 0 def
	    pattern {
		scale1 mul /val xdf
		val 0 eq {/val 1 def} if
		pattern indx val round put
		/indx indx 1 add def
	    } forall
	} if
	/offset pattern 0 get 2 div round def
    } if
    style ALIGN_OPEN eq {		% from /usr/xops/lib/crt/scr/pens.c
	/firstdash pattern 0 get def
	/dashpct firstdash patternlen div def
	/n pathlen patternlen div dashpct sub cvi def
	/scale1 pathlen n dashpct add patternlen mul div def
	/scale2 pathlen n dashpct add 1 add patternlen mul div def
	/x scale2 1 sub abs def
	/y scale1 1 sub abs def
	x y lt {/scale1 scale2 def} if
	scale1 MINSCALE gt {
	    /indx 0 def
	    pattern {
		scale1 mul /val xdf
		val 0 eq {/val 1 def} if
		pattern indx val round put
		/indx indx 1 add def
	    } forall
	    /offset 0 def
	} if 
    } if

    pattern offset setdash
    end
} bdf
/setpenpat load 0 50 dict put

%
%%%%%%%%%%%%%%%%%%%%%%%%%
%	Text handling
%%%%%%%%%%%%%%%%%%%%%%%%%
/s {
  /mappedsp xdf
  /spAdj xdf
  /stEnd xdf
  /fstring xdf

  hpos vpos moveto
  drawmode PL_CLEAR eq {1} {0} ifelse setgray %only support two modes for text
  spAdj 0 ne mappedsp -1 ne and {
    spAdj 0 mappedsp fstring widthshow	% justify it
  } {
    fstring show
  } ifelse
  /hpos stEnd def	%adjust idea of current point
} bdf

%
%%%%%%%%%%%%%%%%%%%%%%%%%
%	Images
%%%%%%%%%%%%%%%%%%%%%%%%%
/PL_bitmap { 0 begin
  gsave
  /vpix xdf
  /hpix xdf

  /nbytes hpix 15 add 16 idiv 2 mul def
  /picstr nbytes string def
  hpos vpos translate
  nbytes 8 mul vpix false [1 0 0 1 0 0 ] 
  {currentfile picstr 0 nbytes getinterval readhexstring pop}
    imagemask
  grestore
  end
} bdf
/PL_bitmap load 0 4 dict put

/PL_contone { 0 begin
   gsave
  /nbits xdf
  /vpix xdf
  /hpix xdf

  /nbytes hpix nbits mul 15 add 16 idiv 2 mul def
  /picstr nbytes string def
  hpos vpos translate
  hpix vpix nbits [1 0 0 1 0 0] 
  {currentfile picstr 0 nbytes getinterval readhexstring pop }
    image
  grestore
  end
} bdf
/PL_contone load 0 5 dict put

/PL_image { 0 begin
  gsave
  /ho xdf	% upper left corner of image.
  /vo xdf	%
  /hh xdf	% Transformed upper right corner relative
  /vh xdf	% to upper left corner.
  /hv xdf	% Transformed lower left corner relative
  /vv xdf	% to upper left corner.
  /nbits xdf	% depth
  /vpix xdf	% height
  /hpix xdf	% width
  /mapsz xdf	% PL_MAP data size
  /map xdf	% PL_MAP data

  mapsz 0 ne
  {
    /mapsz mapsz 1 sub def
    {map exch mapsz mul round cvi get mapsz div} settransfer
  } if 
  /picstr hpix nbits mul 7 add 8 idiv string def
  ho vo translate
  [hh vh hv vv 0 0] concat
  nbits 1 eq mapsz 0 eq and{
    hpix vpix false [hpix 0 0 vpix 0 0]
    {currentfile picstr readhexstring pop }
      imagemask
  } {
    hpix vpix nbits [hpix 0 0 vpix 0 0]
    {currentfile picstr readhexstring pop }
      image
  } ifelse
  grestore
  end
} bdf
/PL_image load 0 12 dict put

%
%%%%%%%%%%%%%%%%%%%%%%%%%
%	FONT GOODIES
%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	ReEncodeSubset -map character set a'la Interleaf
%	
%	snarfed from PS manual, example 22
%	At the moment, it seems like all overlays will start at char 0,
%		but we might as well be general
/reencodesubdict 12 dict def
/ReEncode {
%
%	Copy basefontdict into newfont except for the FID entry.
%	First create a new font dictionary the size of basefontdict
%	plus 2 for a FID entry which definefont will provide.
%
  reencodesubdict begin
  /newencoding xdf
  /newfontname xdf
  /basefontname xdf
	
  /basefontdict basefontname findfont def
  /newfont basefontdict maxlength 2 add dict def
  basefontdict { 		% Copy basefontdict to newfont 
    exch dup /FID ne {		% except for the FID entry.
      exch newfont 3 1 roll put	% Copy entry into newfont.
    } {
      pop pop			% Remove entry from stack if equal FID.
    } ifelse
  } forall
  newfont /FontName newfontname put
  newencoding -1 ne {
    newfont /Encoding newencoding put
  } if
  newfontname newfont definefont pop
  end
} bdf

%
%	Now make a global Encoding vector
%
/insertcharnum { 0 begin	% Put /char# into entry i
  /encoding xdf			% of new encoding vector as
  /i xdf			% character names.

  (char) charname copy pop
  i istr cvs pop
  charname 4 istr  putinterval
  encoding i charname cvn  put
  end
} bdf
/insertcharnum load 0 2 dict put

StandardEncoding   ILEncoding copy
  dup 5	/florin put
  dup 7	/fraction put
  dup 12 /sterling put
  dup 27 /section put
  dup 28 /periodcentered put
  dup 29 /cent put
  dup 30 /hyphen put
  dup 31 /emdash put
  dup 34 /quotedblright put
  dup 45 /endash put
      127 /quotedblleft put

  0 1 4 { ILEncoding insertcharnum } for 
  6 1 6 { ILEncoding insertcharnum } for 
  8 1 11 { ILEncoding insertcharnum } for 
  13 1 26 { ILEncoding insertcharnum } for 

%
%	Create a dictionary entry in "fontmap" indexed by
%	PL fontnames with PS names and sizes as entries
%	a call is of the form:    /timsps10 /ILtims 10 map
%
/map { 0 begin
  
  /PSsize xdf
  /PSname xdf
  /PLname xdf

  /psd 2 dict def
  psd /pssize PSsize put
  psd /psname PSname put 
  fontmap PLname psd put	% install it
  end
} bdf
/map load 0 4 dict put

%
%	Symbol_B character encoding vector. Encodes IL char num to PS
%	symbol names.
%
ILSymEncoding 32
[
/space /logicalor /arrowright /arrowdblleft /arrowdblup 
/arrowdblright /lozenge /arrowhorizex /angleleft /registersans
/Upsilon1 /plusminus /second /angle /greaterequal
/radical /ellipsis /Ifraktur /spade /lessequal
/minute /degree /fraction /florin /infinity
/approxequal /integral /propersuperset /parenrightbt /arrowup
/bracketrighttp /aleph /arrowdblboth /bracerightbt /integralbt
/notsubset /bracketleftbt /trademarksans /bracelefttp /braceleftmid
/braceleftbt /bracketlefttp /braceex /apple /angleright
/parenrightex /parenrighttp /arrowdown /divide /element
/summation /bracketleftex /parenlefttp /parenleftbt /dotmath
/copyrightsans /integralex /parenleftex /integraltp /registerserif 
/intersection /trademarkserif /arrowdbldown /gradient /logicalnot
/reflexsubset /equivalence /propersubset /partialdiff /arrowboth
/circlemultiply /heart /bracketrightex /bracerightmid /emptyset
/bracketrightbt /Rfraktur /proportional /reflexsuperset /carriagereturn
/notequal /notelement /diamond /club /bracerighttp
/arrowleft /weierstrass /bullet /circleplus /multiply
/arrowvertex /copyrightserif /union /product /logicaland
] putinterval
0 1 32 {ILSymEncoding insertcharnum } for
127 1 255 {ILSymEncoding insertcharnum } for

/declareFont {
    /PLnum xdf
    /PLname xdf 
    useNativeFonts  {
    	PSfontobj PLnum
           fontmap PLname get dup 
	    /psname get findfont 
	    invertmatrix makefont exch
	    /pssize get DPIx 72 div mul scalefont 
	put
    } {
	PSfontobj PLnum % into the Plnum'th object make a dictionary:
	10 dict dup begin
	    /FontType 3 def
	    % scale 300 dpi downloaded fonts to target resolution (1270/300).
	    /FontMatrix [DPIx 300 div 0 0 DPIy 300 div 0 0] def
	    /FontBBox [0 0 0 0] def	%updated by LoadGlyph
	    /Encoding ILEncoding def
	    /BuildChar { 0 begin
		/char xdf
		/fontdict xdf
		/charname fontdict /Encoding get char get def
		/charinfo fontdict /CharData get charname get def
		/wx charinfo 0 get def
		charinfo 0 get BOGUSWIDTH eq 
		{puterrchar} 
		{ /charbbox charinfo 1 4 getinterval def
		  wx 0 charbbox aload pop setcachedevice	
		  charinfo 5 get charinfo 6 get true
		  fontdict /imagemaskmatrix get
		    dup 5 charinfo 8 get put
		    dup 4 charinfo 7 get  put
		  charinfo 9  get
		  imagemask
		}ifelse
	    end %BuildChar dict
	    }def %BuildChar
	    /BuildChar load 0 7 dict put
	    /imagemaskmatrix [1 0 0 1 0 0] def %scale factors irrelevant
	    /CharData MAXCHARS dict def	% CharData is built by LoadGlyph.
	end %font dictionary defn
	PLname exch definefont  put

	%load a bogus space character in case no one does
	PSfontobj PLnum get /CharData get 
		/space [16 0 0 1 1 16 1 0 0 [<00>] cvx ] put
    } ifelse
} def

/numLoadEmptyGlyph { 0 begin
	% by number, load font data for char with width but no bits
	/charno xdf
	/fontno xdf
	/w xdf
	w fontno PSfontobj fontno get /Encoding get charno get
	LoadEmptyGlyph
	end
} bdf
/numLoadEmptyGlyph load 0 3 dict put

/LoadEmptyGlyph { 0 begin
	% by name, load font data for char with width but no bits
	
	/charname xdf
	/fontno xdf
	/w xdf
	PSfontobj fontno get  /CharData get
	    charname [w 0 0 1 1 w 1 0 0 [<00>] cvx ] put
	end
} bdf
/LoadEmptyGlyph load 0 3 dict put

/puterrchar {
	PSfontobj errfontno  get dup 
	/BuildChar get  errcharno exch exec 
	(\tInterleaf::out of VM loading bitmap (?). Try breaking up document\n) 
		dup print flush
	emsg1 copy pop
} bdf

/timeToQuit {
%	initialstate restore
	(\tInterleaf::completely out of memory. \n\tTry breaking up the document \n) 
		dup print flush
	emsg2 copy pop
%	headerpage showpage
	stop
} bdf

/LoadGlyph { 0 begin
	% load a glyph into the CharData entry of PSFontobj[fontno]
	% the entry is in the position implied by charno
	% and with the metrics height, width, lsb

	/charno xdf
	/fontno xdf
	/height xdf
	/vadj xdf
	/width xdf
	/hsize xdf
	/lsb xdf

	/noVMHEADROOM vmstatus exch sub exch pop dup
		VMHEADROOM 2 idiv lt {timeToQuit} if
		VMHEADROOM lt 
		{true } {false} ifelse def
	/nbytes hsize 15 add 16 idiv 2 mul height mul def	
	noVMHEADROOM not  {/glyph nbytes string def } if
	currentfile noVMHEADROOM 
		{trashheap 0 nbytes getinterval } {glyph} ifelse 
		readhexstring pop pop
	
	   %actually, we pass bitmap rounded to 16 bits wide:
	/hsize hsize 15 add 16 idiv 16 mul def
	
	/thefont PSfontobj fontno get	def %the font dict
		% if we are loading glyphs, PSfontobj is an array of
		% dictionaries each of which already has the form
		% of Program 21, PS T&C
	/charname thefont /Encoding get charno get def %access by name !

	%now make the parameters for the CharData
	% 1 unit = 1 pixel
	
		
	/tx lsb  neg def
	/ty vadj neg def
	/lly  height vadj add def	%lower left of bbox
	/llx  lsb def
	/urx hsize lsb add def %upper right
	/ury vadj def
	thefont /CharData get charname 
	    noVMHEADROOM
	    { [BOGUSWIDTH] }
	    {[width llx lly urx ury hsize height tx ty [glyph] cvx ]} ifelse
	put
	end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?