📄 gs_init.ps
字号:
% Copyright (C) 1989, 1996 Aladdin Enterprises. All rights reserved.
%
% This file is part of Aladdin Ghostscript.
%
% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
% or distributor accepts any responsibility for the consequences of using it,
% or for whether it serves any particular purpose or works at all, unless he
% or she says so in writing. Refer to the Aladdin Ghostscript Free Public
% License (the "License") for full details.
%
% Every copy of Aladdin Ghostscript must include a copy of the License,
% normally in a plain ASCII text file named PUBLIC. The License grants you
% the right to copy, modify and redistribute Aladdin Ghostscript, but only
% under certain conditions described in the License. Among other things, the
% License requires that the copyright notice and this notice be preserved on
% all copies.
% Initialization file for the interpreter.
% When this is run, systemdict is still writable.
% Comment lines of the form
% %% Replace <n> <file(s)>
% indicate places where the next <n> lines should be replaced by
% the contents of <file(s)>, when creating a single merged init file.
% The interpreter can call out to PostScript code. All procedures
% called in this way, and no other procedures defined in these
% initialization files, have names that begin with %, e.g.,
% (%Type1BuildChar) cvn.
% Check the interpreter revision. NOTE: the interpreter code requires
% that the first non-comment token in this file be an integer.
403
dup revision ne
{ (gs: Interpreter revision \() print revision 10 string cvs print
(\) does not match gs_init.ps revision \() print 10 string cvs print
(\).\n) print flush null 1 .quit
}
if pop
% Acquire userdict, and set its length if necessary.
/userdict where
{ pop userdict maxlength 0 eq }
{ true }
ifelse
{ % userdict wasn't already set up by iinit.c.
/userdict
currentdict dup 200 .setmaxlength % userdict
systemdict begin def % can't use 'put', userdict is local
}
{ systemdict begin
}
ifelse
% Define dummy local/global operators if needed.
systemdict /.setglobal known
{ true .setglobal
}
{ /.setglobal { pop } bind def
/.currentglobal { false } bind def
/.gcheck { pop false } bind def
}
ifelse
% Define .languagelevel if needed.
systemdict /.languagelevel known not { /.languagelevel 1 def } if
% Optionally choose a default paper size other than U.S. letter.
% (a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse
% Turn on array packing for the rest of initialization.
true setpacking
% Define the old MS-DOS EOF character as a no-op.
% This is a hack to get around the absurd habit of MS-DOS editors
% of adding an EOF character at the end of the file.
<1a> cvn { } def
% Acquire the debugging flags.
currentdict /DEBUG known /DEBUG exch def
/VMDEBUG
DEBUG {{print mark
systemdict /level2dict known
{ .currentglobal dup false .setglobal vmstatus
true .setglobal vmstatus 3 -1 roll pop
6 -2 roll pop .setglobal
}
{ vmstatus 3 -1 roll pop
}
ifelse usertime 16#fffff and counttomark
{ ( ) print ( ) cvs print }
repeat pop
( ) print systemdict length ( ) cvs print
( ) print countdictstack ( ) cvs print
( <) print count ( ) cvs print (>\n) print flush
}}
{{pop
}}
ifelse
def
currentdict /DELAYBIND known /DELAYBIND exch def
currentdict /DISKFONTS known /DISKFONTS exch def
currentdict /ESTACKPRINT known /ESTACKPRINT exch def
currentdict /FAKEFONTS known /FAKEFONTS exch def
currentdict /FIXEDMEDIA known /FIXEDMEDIA exch def
currentdict /FIXEDRESOLUTION known /FIXEDRESOLUTION exch def
currentdict /LOCALFONTS known /LOCALFONTS exch def
currentdict /NOBIND known /NOBIND exch def
/.bind /bind load def
NOBIND { /bind { } def } if
currentdict /NOCACHE known /NOCACHE exch def
currentdict /NOCIE known /NOCIE exch def
currentdict /NODISPLAY known not /DISPLAYING exch def
currentdict /NOFONTMAP known /NOFONTMAP exch def
currentdict /NOFONTPATH known /NOFONTPATH exch def
currentdict /NOGC known /NOGC exch def
currentdict /NOPAUSE known /NOPAUSE exch def
currentdict /NOPLATFONTS known /NOPLATFONTS exch def
currentdict /NOPROMPT known /NOPROMPT exch def
% The default value of ORIENT1 is true, not false.
currentdict /ORIENT1 known not { /ORIENT1 true def } if
currentdict /OSTACKPRINT known /OSTACKPRINT exch def
currentdict /OUTPUTFILE known % obsolete
{ /OutputFile /OUTPUTFILE load def
currentdict /OUTPUTFILE .undef
} if
currentdict /QUIET known /QUIET exch def
currentdict /SAFER known /SAFER exch def
currentdict /SHORTERRORS known /SHORTERRORS exch def
currentdict /WRITESYSTEMDICT known /WRITESYSTEMDICT exch def
% Acquire environment variables.
currentdict /DEVICE known not
{ (GS_DEVICE) getenv { /DEVICE exch def } if } if
(START) VMDEBUG
% Open the standard files, so they will be open at the outermost save level.
(%stdin) (r) file pop
(%stdout) (w) file pop
(%stderr) (w) file pop
% Define a procedure for skipping over an unneeded section of code.
% This avoids allocating space for the skipped procedures.
% We can't use readline, because that imposes a line length limit.
/.skipeof % <string> .skipeof -
{ currentfile exch 1 exch .subfiledecode flushfile
} bind def
% If we're delaying binding, remember everything that needs to be bound later.
DELAYBIND NOBIND not and
{ .currentglobal false .setglobal
userdict /.delaybind 1500 array put
.setglobal
userdict /.delaycount 0 put
% When we've done the delayed bind, we want to stop saving.
% Detect this by the disappearance of .delaybind.
/bind
{ userdict /.delaybind .knownget
{ .delaycount 2 index put
userdict /.delaycount .delaycount 1 add put
}
{ .bind
}
ifelse
} bind def
} if
% Define procedures to assist users who don't read the documentation.
userdict begin
/help
{ (Enter PostScript commands. '(filename) run' runs a file, 'quit' exits.\n)
print flush
} bind def
/? /help load def
end
% Define =string, which is used by some PostScript programs even though
% it isn't documented anywhere.
% Put it in userdict so that each context can have its own copy.
userdict /=string 256 string put
% Print the greeting.
/printgreeting
{ mark
product (Ghostscript) search
{ pop pop pop
(This software comes with NO WARRANTY: see the file PUBLIC for details.\n)
}
{ pop
}
ifelse
(\n) copyright
(\)\n) revisiondate 100 mod (-)
revisiondate 100 idiv 100 mod (-)
revisiondate 10000 idiv ( \()
revision 10 mod
revision 10 idiv 10 mod (.)
revision 100 idiv ( )
product
counttomark
{ (%stdout) (w) file exch false .writecvp
} repeat pop
} bind def
QUIET not { printgreeting flush } if
% Define a special version of def for making operator procedures.
/odef % <name> <proc> odef -
{ 1 index exch .makeoperator def
} .bind def
%**************** BACKWARD COMPATIBILITY
/getdeviceprops
{ null .getdeviceparams
} bind odef
/.putdeviceprops
{ null true counttomark 1 add 3 roll .putdeviceparams
dup type /booleantype ne
{ dup mark eq { /unknown /rangecheck } if
counttomark 4 add 1 roll cleartomark pop pop pop
/.putdeviceprops load exch signalerror
}
if
} bind odef
/.devicenamedict 1 dict dup /OutputDevice dup put def
/.devicename
{ //.devicenamedict .getdeviceparams exch pop exch pop
} bind odef
/max { .max } bind def
/min { .min } bind def
/.currentfilladjust { .currentfilladjust2 pop } bind odef
/.setfilladjust { dup .setfilladjust2 } bind odef
/.writecvs { false .writecvp } bind odef
% Define predefined procedures substituting for operators,
% in alphabetical order.
userdict /#copies 1 put
% Adobe implementations don't accept /[ or /], so we don't either.
([) cvn
/mark load def
(]) cvn
{counttomark array astore exch pop} odef
/abs {dup 0 lt {neg} if} odef
% .beginpage is an operator in Level 2.
/.beginpage { } odef
/copypage
{ 1 .endpage
{ .currentnumcopies false .outputpage
(>>copypage, press <return> to continue<<\n) .confirm
}
if .beginpage
} odef
% .currentnumcopies is redefined in Level 2.
/.currentnumcopies { #copies } odef
/setcolorscreen where { pop % not in all Level 1 configurations
/currentcolorscreen
{ .currenthalftone
{ { 60 exch 0 exch 3 copy 6 copy } % halftone - not possible
{ 3 copy 6 copy } % screen
{ } % colorscreen
}
exch get exec
} odef
} if
/currentscreen
{ .currenthalftone
{ { 60 exch 0 exch } % halftone - not possible
{ } % screen
{ 12 3 roll 9 { pop } repeat } % colorscreen
}
exch get exec
} odef
/.echo /echo load def
userdict /.echo.mode true put
/echo {dup /.echo.mode exch store .echo} odef
/eexec
{ 55665 //filterdict /eexecDecode get exec
cvx //systemdict begin stopped
% Only pop systemdict if it is still the top element,
% because this is apparently what Adobe interpreters do.
currentdict //systemdict eq { end } if
{ stop } if
} odef
% .endpage is an operator in Level 2.
/.endpage { 2 ne } odef
% erasepage mustn't use gsave/grestore, because we call it before
% the graphics state stack has been fully initialized.
/erasepage
{ /currentcolor where
{ pop currentcolor currentcolorspace { setcolorspace setcolor } }
{ /currentcmykcolor where
{ pop currentcmykcolor { setcmykcolor } }
{ currentrgbcolor { setrgbcolor } }
ifelse
}
ifelse 1 setgray .fillpage exec
} odef
/executive
{ { prompt
{ (%statementedit) (r) file } stopped
{ pop pop $error /errorname get /undefinedfilename eq
{ .clearerror exit } if % EOF
handleerror null % ioerror??
}
if
cvx execute
} loop
} odef
/filter
{ //filterdict 1 index .knownget
{ exch pop exec }
{ /filter load /undefined signalerror }
ifelse
} odef
/handleerror
{ errordict /handleerror get exec } bind def
/identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def
/identmatrix
{ //identmatrix exch copy } odef
/initgraphics
{ initmatrix newpath initclip
1 setlinewidth 0 setlinecap 0 setlinejoin
[] 0 setdash 0 setgray 10 setmiterlimit
} odef
/languagelevel 1 def % gs_lev2.ps may change this
/makeimagedevice { false makewordimagedevice } odef
/matrix { 6 array identmatrix } odef
/pathbbox { false .pathbbox } odef
/prompt { flush flushpage
(GS) print
count 0 ne { (<) print count =only } if
(>) print flush
} bind def
/pstack { 0 1 count 3 sub { index == } for } bind def
/putdeviceprops
{ .putdeviceprops { erasepage } if } odef
/quit { /quit load 0 .quit } odef
/run { dup type /filetype ne { (r) file } if
% We must close the file when execution terminates,
% regardless of the state of the stack,
% and then propagate an error, if any.
cvx .runexec
} odef
/setdevice
{ .setdevice { erasepage } if } odef
/showpage
{ 0 .endpage
{ .currentnumcopies true .outputpage
(>>showpage, press <return> to continue<<\n) .confirm
erasepage
}
if initgraphics .beginpage
} odef
% Code output by Adobe Illustrator relies on the fact that
% `stack' is a procedure, not an operator!!!
/stack { 0 1 count 3 sub { index = } for } bind def
/start { executive } def
/stop { true .stop } odef
% Internal uses of stopped that aren't going to do a stop if an error occurs
% should use .internalstopped to avoid setting newerror et al.
/stopped { false .stopped } odef
/.internalstopped { null .stopped null ne } bind def
/store { 1 index where { 3 1 roll put } { def } ifelse } odef
% When running in Level 1 mode, this interpreter is supposed to be
% compatible with PostScript "version" 54.0 (I think).
/version (54.0) def
% internaldict is defined in systemdict, but is allocated in local VM.
systemdict /internaldict .knownget not { 0 } if type /operatortype ne
{ .currentglobal false .setglobal
//systemdict /internaldict known not { /internaldict 5 dict def } if
/internaldict
[ /dup load 1183615869 /eq load
[ /pop load internaldict ] cvx
[ /internaldict /cvx load /invalidaccess /signalerror cvx ] cvx
/ifelse load
] cvx bind odef
.setglobal
} if
% Define some additional built-in procedures (beyond the ones defined by
% the PostScript Language Reference Manual).
% Warning: these are not guaranteed to stay the same from one release
% to the next!
/concatstrings
{ exch dup length 2 index length add string % str2 str1 new
dup dup 4 2 roll copy % str2 new new new1
length 4 -1 roll putinterval
} bind def
/copyarray
{ dup length array copy } bind def
% Copy a dictionary per the Level 2 spec even in Level 1.
/.copydict % <fromdict> <todict> .copydict <todict>
{ dup 3 -1 roll { put dup } forall pop } bind def
/copystring
{ dup length string copy } bind def
/finddevice
{ //systemdict /devicedict get exch get
dup 1 get null eq
{ % This is the first request for this type of device.
% Create a default instance now.
% Stack: [proto null]
.currentglobal true .setglobal exch
dup dup 0 get copydevice 1 exch put
exch .setglobal
}
if 1 get
} bind def
/.growdictlength % get size for growing a dictionary
{ length 3 mul 2 idiv 1 add
} bind def
/.growdict % grow a dictionary
{ dup .growdictlength .setmaxlength
} bind def
/.growput % put, grow the dictionary if needed
{ 2 index length 3 index maxlength eq
{ 3 copy pop known not { 2 index .growdict } if
} if
put
} bind def
/.packtomark
{ counttomark packedarray exch pop } bind def
/ppstack
{ 0 1 count 3 sub { index === } for } bind def
/runlibfile
{ findlibfile
{ exch pop run }
{ /undefinedfilename signalerror }
ifelse
} bind def
/selectdevice
{ finddevice setdevice .setdefaultscreen } bind def
/signalerror % <object> <errorname> signalerror -
{ errordict exch get exec } bind def
% Define the =[only] procedures. Also define =print,
% which is used by some PostScript programs even though
% it isn't documented anywhere.
/write=only
{ { .writecvs } .internalstopped
{ pop (--nostringval--) writestring
}
if
} bind def
/write=
{ 1 index exch write=only (\n) writestring
} bind def
/=only { (%stdout) (w) file exch write=only } bind def
/= { =only (\n) print } bind def
/=print /=only load def
% Temporarily define == as = for the sake of runlibfile0.
/== /= load def
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -