📄 gs_init.ps
字号:
{ = }
ifelse
}
{ pop
}
ifelse
position null ne
{ (Current file position is ) print position = }
if
} bind def
% Define a procedure for clearing the error indication.
/.clearerror
{ $error /newerror false put
$error /errorname null put
$error /errorinfo .undef
0 .setoserrno
} bind def
% Define $error. This must be in local VM.
.currentglobal false .setglobal
/$error 40 dict .forcedef % $error is local, systemdict is global
% newerror, errorname, command, errorinfo,
% ostack, estack, dstack, recordstacks,
% binary, globalmode,
% .inerror, .nosetlocal, position,
% plus extra space for badly designed error handers.
$error begin
/newerror false def
/recordstacks true def
/binary false def
/globalmode .currentglobal def
/.inerror false def
/.nosetlocal true def
/position null def
end
% Define errordict similarly. It has one entry per error name,
% plus handleerror.
/errordict ErrorNames length 1 add dict
.forcedef % errordict is local, systemdict is global
.setglobal % contents of errordict are global
errordict begin
ErrorNames
{ mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx def
} forall
% The handlers for interrupt and timeout are special; there is no
% 'current object', so they push their own name.
{ /interrupt /timeout }
{ mark 1 index dup systemdict /.errorhandler get /exec load .packtomark cvx def
} forall
/handleerror
{ /.printerror .systemvar exec
} bind def
end
% Define the [write]==[only] procedures.
/.dict 26 dict dup
begin def
/.cvp {1 index exch .writecvs} bind def
/.nop {exch pop .p} bind def
/.p {1 index exch writestring} bind def
/.p1 {2 index exch writestring} bind def
/.p2 {3 index exch writestring} bind def
/.print
{ dup type .dict exch .knownget
{ dup type /stringtype eq { .nop } { exec } ifelse }
{ (-) .p1 type .cvp (-) .p }
ifelse
} bind def
/.pstring
{ { dup dup 32 lt exch 127 ge or
{ (\\) .p1 2 copy -6 bitshift 48 add write
2 copy -3 bitshift 7 and 48 add write
7 and 48 add
}
{ dup dup -2 and 40 eq exch 92 eq or {(\\) .p1} if
}
ifelse 1 index exch write
}
forall
} bind def
/booleantype /.cvp load def
/conditiontype (-condition-) def
/devicetype (-device-) def
/dicttype (-dict-) def
/filetype (-file-) def
/fonttype (-fontID-) def
/gstatetype (-gstate-) def
/integertype /.cvp load def
/locktype (-lock-) def
/marktype (-mark-) def
/nulltype (null) def
/realtype {1 index exch true .writecvp} bind def
/savetype (-save-) def
/nametype
{dup xcheck not {(/) .p1} if
1 index exch .writecvs} bind def
/arraytype
{dup rcheck
{() exch dup xcheck
{({) .p2
{exch .p1
1 index exch .print pop ( )} forall
(})}
{([) .p2
{exch .p1
1 index exch .print pop ( )} forall
(])}
ifelse exch pop .p}
{(-array-) .nop}
ifelse} bind def
/operatortype
{(--) .p1 .cvp (--) .p} bind def
/packedarraytype
{ dup rcheck
{ arraytype }
{ (-packedarray-) .nop }
ifelse
} bind def
/stringtype
{ dup rcheck
{ (\() .p1 dup length 200 le
{ .pstring }
{ 0 200 getinterval .pstring (...) .p }
ifelse (\)) .p
}
{ (-string-) .nop
}
ifelse
} bind def
{//.dict begin .print pop end}
bind
end
/write==only exch 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
% Define [write]===[only], an extension that prints dictionaries
% in readable form and doesn't truncate strings.
/.dict /write==only load 0 get dup length dict .copydict dup
begin def
/dicttype
{ dup rcheck
{ (<< ) .p1
{ 2 index 3 -1 roll .print pop ( ) .p1
1 index exch .print pop ( ) .p
}
forall (>>) .p
}
{ (-dict-) .nop
}
ifelse
} bind def
/stringtype
{ dup rcheck
{ (\() .p1 .pstring (\)) .p }
{ (-string-) .nop }
ifelse
} bind def
{//.dict begin .print pop end}
bind
end
/write===only exch 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
(END PROCS) VMDEBUG
% Define the font directory.
/FontDirectory false .setglobal 100 dict true .setglobal
.forcedef % FontDirectory is local, systemdict is global
% Define the encoding dictionary.
/EncodingDirectory 10 dict def % enough for Level 2 + PDF standard encodings
% Define .findencoding. (This is redefined in Level 2.)
/.findencoding
{ //EncodingDirectory exch get exec
} bind def
/.defineencoding
{ //EncodingDirectory 3 1 roll put
} bind def
% If we've got the composite font extensions, define findencoding.
% To satisfy the Genoa FTS, findencoding must be a procedure, not an operator.
/rootfont where { pop /findencoding { .findencoding } def } if
% Define .registerencoding.
% NOTE: the name registeredencodings is known to (initialized by and shared
% with) the interpreter.
/.registerencoding { % <index> <array> .registerencoding -
% Check that the array is indexable.
% (It might still be a string, but then the .namestring will fail.)
dup 0 0 getinterval pop
% Check that all the elements of the array are names.
dup { .namestring pop } forall
% Do the store.
//registeredencodings 2 index 2 index readonly put pop pop
} bind odef
systemdict /registeredencodings .undef
% Load StandardEncoding.
%% Replace 1 (gs_std_e.ps)
(gs_std_e.ps) dup runlibfile VMDEBUG
% Load ISOLatin1Encoding.
%% Replace 1 (gs_iso_e.ps)
(gs_iso_e.ps) dup runlibfile VMDEBUG
% Define stubs for the Symbol and Dingbats encodings.
% Note that the first element of the procedure must be the file name,
% since gs_lev2.ps extracts it to set up the Encoding resource category.
/SymbolEncoding { /SymbolEncoding .findencoding } bind def
%% Replace 3 (gs_sym_e.ps)
EncodingDirectory /SymbolEncoding
{ (gs_sym_e.ps) //systemdict begin runlibfile SymbolEncoding end }
bind put
/DingbatsEncoding { /DingbatsEncoding .findencoding } bind def
%% Replace 3 (gs_dbt_e.ps)
EncodingDirectory /DingbatsEncoding
{ (gs_dbt_e.ps) //systemdict begin runlibfile DingbatsEncoding end }
bind put
(END FONTDIR/ENCS) VMDEBUG
% Construct a dictionary of all available devices.
% These are (read-only) device prototypes that can't be
% installed or have their parameters changed. For this reason,
% the value in the dictionary is actually a 2-element writable array,
% to allow us to create a default instance of the prototype on demand.
% Loop until the .getdevice gets a rangecheck.
errordict /rangecheck 2 copy get
errordict /rangecheck { pop stop } put % pop the command
0 { {dup .getdevice exch 1 add} loop} .internalstopped pop
1 add dict /devicedict 1 index def
begin % 2nd copy of count is on stack
{ dup .devicename exch
dup wcheck { dup } { null } ifelse 2 array astore def
} repeat
end
put % errordict /rangecheck
.clearerror
/devicenames devicedict { pop } forall devicedict length packedarray def
% Determine the default device.
/defaultdevice DISPLAYING
{ systemdict /DEVICE .knownget
{ devicedict 1 index known not
{ (Unknown device: ) print =
flush /defaultdevice cvx 1 .quit
}
if
}
{ 0 .getdevice .devicename
}
ifelse
}
{ /nullpage
}
ifelse
/.defaultdevicename 1 index def
finddevice % make a copy
def
devicedict /Default devicedict .defaultdevicename get put
(END DEVS) VMDEBUG
% Define statusdict, for the benefit of programs
% that think they are running on a LaserWriter or similar printer.
%% Replace 1 (gs_statd.ps)
(gs_statd.ps) runlibfile
(END STATD) VMDEBUG
% Load the standard font environment.
%% Replace 1 (gs_fonts.ps)
(gs_fonts.ps) runlibfile
(END GS_FONTS) VMDEBUG
% Load the initialization files for optional features.
%% Replace 4 INITFILES
systemdict /INITFILES known
{ INITFILES { dup runlibfile VMDEBUG } forall
}
if
% If Level 2 (or higher) functionality is implemented, enable it now.
/.setlanguagelevel where {
pop 2 .setlanguagelevel
% If the resource machinery is loaded, fix up some things now.
/.fixresources where { pop .fixresources } if
} if
/ll3dict where {
pop 3 .setlanguagelevel
} if
(END INITFILES) VMDEBUG
% Create a null font. This is the initial font.
8 dict dup begin
/FontMatrix [ 1 0 0 1 0 0 ] readonly def
/FontType 3 def
/FontName () def
/Encoding StandardEncoding def
/FontBBox { 0 0 0 0 } readonly def % executable is bogus, but customary ...
/BuildChar { pop pop 0 0 setcharwidth } bind def
/PaintType 0 def % shouldn't be needed!
end
/NullFont exch definefont setfont
% Define NullFont as the font.
/NullFont currentfont def
% Load initial fonts from FONTPATH directories, Fontmap file,
% and/or .getccfont as appropriate.
.loadinitialfonts
% Remove NullFont from FontDirectory, so it can't be accessed by mistake.
/undefinefont where {
pop /NullFont undefinefont
} {
FontDirectory /NullFont .undef
} ifelse
(END FONTS) VMDEBUG
% Restore the real definition of runlibfile.
/runlibfile /.runlibfile load def
currentdict /.runlibfile .undef
% Bind all the operators defined as procedures.
/.bindoperators % binds operators in currentdict
{ % Temporarily disable the typecheck error.
errordict /typecheck 2 copy get
errordict /typecheck { pop } put % pop the command
currentdict
{ dup type /operatortype eq
{ % This might be a real operator, so bind might cause a typecheck,
% but we've made the error a no-op temporarily.
.bind % do a real bind even if NOBIND is set
}
if pop pop
} forall
put
} def
NOBIND DELAYBIND or not { .bindoperators } if
% Establish a default environment.
defaultdevice
% The following line used to skip setting of page size and resolution if
% NODISPLAY was selected. We think this was only to save time and memory,
% and it is a bad idea because it prevents setting the resolution in this
% situation, which pstoedit (among other programs) relies on.
%DISPLAYING not { setdevice (%END DISPLAYING) .skipeof } if
systemdict /DEVICEWIDTH known
systemdict /DEVICEHEIGHT known or
systemdict /DEVICEWIDTHPOINTS known or
systemdict /DEVICEHEIGHTPOINTS known or
systemdict /DEVICEXRESOLUTION known or
systemdict /DEVICEYRESOLUTION known or
systemdict /PAPERSIZE known or
not { (%END DEVICE) .skipeof } if
% Let DEVICE{WIDTH,HEIGHT}[POINTS] override PAPERSIZE.
systemdict /PAPERSIZE known
systemdict /DEVICEWIDTH known not and
systemdict /DEVICEHEIGHT known not and
systemdict /DEVICEWIDTHPOINTS known not and
systemdict /DEVICEHEIGHTPOINTS known not and
{ % Convert the paper size to device dimensions.
true statusdict /.pagetypenames get
{ PAPERSIZE eq
{ PAPERSIZE load
dup 0 get /DEVICEWIDTHPOINTS exch def
1 get /DEVICEHEIGHTPOINTS exch def
pop false exit
}
if
}
forall
{ (Unknown paper size: ) print PAPERSIZE ==only (.\n) print
}
if
}
if
% Adjust the device parameters per the command line.
% It is possible to specify resolution, pixel size, and page size;
% since any two of these determine the third, conflicts are possible.
% We simply pass them to .setdeviceparams and let it sort things out.
mark /HWResolution null /HWSize null /PageSize null .dicttomark
.getdeviceparams .dicttomark begin
mark
% Check for resolution.
/DEVICEXRESOLUTION where dup
{ exch pop HWResolution 0 DEVICEXRESOLUTION put }
if
/DEVICEYRESOLUTION where dup
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -