⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gs_res.ps

📁 GhostScript的源代码
💻 PS
📖 第 1 页 / 共 2 页
字号:
/.LocalInstances
	{ localinstancedict Category .knownget not { //.emptydict } if
	} bind
/.GetInstance
	{ currentglobal
	   { Instances exch .knownget }
	   { .LocalInstances 1 index .knownget
	      { exch pop true }
	      { Instances exch .knownget }
	     ifelse
	   }
	  ifelse
	} bind
/.CheckResource
	{ true
	} bind
/.DoLoadResource
	{ dup vmstatus pop exch pop exch
	  .LoadResource
	  vmstatus pop exch pop exch sub
	  1 index .GetInstance not
	   { pop dup /undefinedresource signalerror }	% didn't load
	  if
	  dup 1 1 put
	  2 3 -1 roll put
	} bind
/.LoadResource
	{ dup .ResourceFile
	   { exch pop currentglobal
	      { run }
	      { true setglobal { run } stopped false setglobal { stop } if }
	     ifelse
	   }
	   { dup /undefinedresource signalerror
	   }
	 ifelse
	} bind
/.ResourceFile
	{ currentdict /ResourceFileName known
	   { mark 1 index 100 string { ResourceFileName }
	     .internalstopped
	      { cleartomark false }
	      { exch pop findlibfile
		 { exch pop exch pop true }
		 { pop false }
		ifelse
	      }
	     ifelse
	   }
	   { false }
	  ifelse
	} bind

.dicttomark
/Category defineresource pop

% Fill in the rest of the Category category.
/Category /Category findresource dup
/Generic /Category findresource begin
 { /FindResource /ResourceForAll /ResourceStatus /UndefineResource
   /ResourceFileName /.ResourceFile /.LoadResource /.DoLoadResource
 }
 { dup load put dup } forall
pop readonly pop end

(END GENERIC) VMDEBUG

% Define the fixed categories.

mark
	% Non-Type categories with existing entries.
 /ColorSpaceFamily
   mark colorspacedict { pop } forall .packtomark
 /Emulator
   mark EMULATORS { cvn } forall .packtomark
 /Filter
   mark filterdict { pop } forall .packtomark
 /IODevice
	% Loop until the .getiodevice gets a rangecheck.
   errordict /rangecheck 2 copy get
   errordict /rangecheck { pop stop } put	% pop the command
   mark 0 { {dup .getiodevice exch 1 add} loop} .internalstopped
   pop pop pop .packtomark
   4 1 roll put
   .clearerror
	% Type categories listed in the Red Book.
 /ColorRenderingType
   { }	% These must be deferred, because optional features may add some.
 /FMapType
   { }	% These must be deferred, because optional features may add some.
 /FontType
   { }	% These must be deferred, because optional features may add some.
 /FormType
   { }	% These must be deferred, because optional features may add some.
 /HalftoneType
   {1 2 3 4 5}
 /ImageType
   { }	% Deferred, optional features may add some.
 /PatternType
   { }  % Deferred, optional features may add some.
	% Type categories added since the Red Book.
 /setsmoothness where {
   pop /ShadingType { }	% Deferred, optional features may add some.
 } if
counttomark 2 idiv
 { mark

		% Standard entries

		% We'd like to prohibit defineresource,
		% but because optional features may add entries, we can't.
		% We can at least require that the key and value match.
   /DefineResource
	{ currentglobal not
	   { /defineresource load /invalidaccess signalerror }
	   { 2 copy ne
	      { /defineresource load /rangecheck signalerror }
	      { dup Instances 4 -2 roll .growput }
	     ifelse
	   }
	  ifelse
	} bind
   /UndefineResource
	{ /undefineresource load /invalidaccess signalerror } bind
   /FindResource
	{ Instances 1 index .knownget
	   { exch pop }
	   { /findresource load /undefinedresource signalerror }
	  ifelse
	} bind
   /ResourceStatus
	{ Instances exch known { 0 0 true } { false } ifelse } bind
   /ResourceForAll
	/Generic /Category findresource /ResourceForAll get

		% Additional entries

   counttomark 2 add -1 roll
   dup length dict dup begin exch { dup def } forall end
		% We'd like to make the Instances readonly here,
		% but because optional features may add entries, we can't.
   /Instances exch
   /.LocalInstances	% used by ResourceForAll
	0 dict def

   .dicttomark /Category defineresource pop
 } repeat pop

(END FIXED) VMDEBUG

% Define the other built-in categories.

/.definecategory	% <name> -mark- <key1> ... <valuen> .definecategory -
 { counttomark 2 idiv 2 add		% Instances, Category
   /Generic /Category findresource dup maxlength 3 -1 roll add
   dict .copydict begin
   counttomark 2 idiv { def } repeat pop	% pop the mark
   currentdict end /Category defineresource pop
 } bind def

/ColorRendering mark /InstanceType /dicttype .definecategory
/ColorSpace mark /InstanceType /arraytype .definecategory
/Form mark /InstanceType /dicttype .definecategory
/Halftone mark /InstanceType /dicttype .definecategory
/Pattern mark /InstanceType /dicttype .definecategory
/ProcSet mark /InstanceType /dicttype .definecategory
% Added since the Red Book:
/ControlLanguage mark /InstanceType /dicttype .definecategory
/HWOptions mark /InstanceType /dicttype .definecategory
/Localization mark /InstanceType /dicttype .definecategory
/OutputDevice mark /InstanceType /dicttype .definecategory
/PDL mark /InstanceType /dicttype .definecategory
% CIDFont, CIDMap, and CMap are defined in gs_cidfn.ps
% FontSet is defined in gs_cff.ps
% IdiomSet, InkParams, and TrapParams are defined in gs_ll3.ps

(END MISC) VMDEBUG

% Define the Encoding category.

/Encoding mark

/InstanceType /arraytype

% Handle already-registered encodings, including lazily loaded encodings
% that aren't loaded yet.

/Instances mark
  EncodingDirectory
   { dup length 256 eq { [ exch readonly 0 -1 ] } { pop [null 2 -1] } ifelse
   } forall
.dicttomark

/.ResourceFileDict mark
  EncodingDirectory
   { dup length 256 eq { pop pop } { 0 get } ifelse
   } forall
.dicttomark

/ResourceFileName
 { .ResourceFileDict 2 index .knownget
    { exch copy exch pop }
    { /Generic /Category findresource /ResourceFileName get exec }
   ifelse
 } bind

.definecategory			% Encoding

% Make placeholders in level2dict for the redefined Encoding operators,
% so that they will be swapped properly when we switch language levels.

/.findencoding /.findencoding load def
/findencoding /findencoding load def
/.defineencoding /.defineencoding load def

(END ENCODING) VMDEBUG

% Define the Font category.

/Font mark

/InstanceType /dicttype

/DefineResource
	{ 2 copy //definefont exch pop
	  /Generic /Category findresource /DefineResource get exec
	} bind
/UndefineResource
	{ dup //undefinefont
	  /Generic /Category findresource /UndefineResource get exec
	} bind
/FindResource
	{ dup ResourceStatus
	   { pop 1 gt { .loadfont } { .GetInstance pop 0 get } ifelse }
	   { .loadfont }
	  ifelse
	} bind
/ResourceFileName
	{ /FontResourceDir getsystemparam .genericrfn
	} bind

/.loadfont
	{ dup vmstatus pop exch pop exch
	  //findfont exec exch		% findfont is a procedure....
	  vmstatus pop exch pop exch sub
		% stack: name font vmused
		% findfont has the prerogative of not calling definefont
		% in certain obscure cases of font substitution.
	  2 index .GetInstance
	   { dup 1 1 put
	     2 3 -1 roll put
	   }
	   { pop
	   }
	  ifelse exch pop
	} bind

/Instances FontDirectory length 2 mul dict

.definecategory			% Font

% Redefine font "operators".
/.definefontmap
 { /Font /Category findresource /Instances get
   dup 3 index known
    { pop
    }
    { 2 index
		% Make sure we create the array in global VM.
      .currentglobal true .setglobal
      [null 2 -1] exch .setglobal
      .growput
    }
   ifelse
   //.definefontmap exec
 } bind def

% Make sure the old definitions are still in systemdict so that
% they will get bound properly.
systemdict begin
  /.origdefinefont /definefont load def
  /.origundefinefont /undefinefont load def
  /.origfindfont /findfont load def
end
/definefont {
  /Font defineresource
} bind odef
/undefinefont {
  /Font undefineresource
} bind odef
% The Red Book requires that findfont be a procedure, not an operator,
% but it still needs to restore the stacks reliably if it fails.
/.findfontop {
  /Font findresource
} bind odef
/findfont {
  .findfontop
} bind def	% Must be a procedure, not an operator

% Remove initialization utilities.
currentdict /.definecategory .undef
currentdict /.emptydict .undef

end				% level2dict

% Convert deferred resources after we finally switch to Level 2.

/.fixresources {
	% Encoding resources
 EncodingDirectory
   { dup length 256 eq
      { /Encoding defineresource pop }
      { pop pop }
     ifelse
   } forall
  /.findencoding { /Encoding findresource } bind def
  /findencoding /.findencoding load def		% must be a procedure
  /.defineencoding { /Encoding defineresource pop } bind def
	% ColorRendering resources and ProcSet
  systemdict /ColorRendering .knownget {
    /ColorRendering exch /ProcSet defineresource pop
    systemdict /ColorRendering undef
    /Default currentcolorrendering /ColorRendering defineresource pop
  } if
	% ColorSpace resources
  systemdict /CIEsRGB .knownget {
    /sRGB exch /ColorSpace defineresource pop
    systemdict /CIEsRGB undef
  } if
	% FontType and FMapType resources
  buildfontdict { pop dup /FontType defineresource pop } forall
  mark
    buildfontdict 0 known { 2 3 4 5 6 7 8 } if
    buildfontdict 9 known { 9 } if
  counttomark { dup /FMapType defineresource pop } repeat pop
	% FormType resources
  .formtypes { pop dup /FormType defineresource pop } forall
	% ColorRenderingType resources
  .colorrenderingtypes {pop dup /ColorRenderingType defineresource pop} forall
	% ImageType resources
  .imagetypes { pop dup /ImageType defineresource pop } forall
	% PatternType resources
  .patterntypes { pop dup /PatternType defineresource pop } forall
	% Make the fixed resource categories immutable.
  /.shadingtypes where {
    pop .shadingtypes { pop dup /ShadingType defineresource pop } forall
  } if
  [ /ColorSpaceFamily /Emulator /Filter /IODevice /ColorRenderingType
    /FMapType /FontType /FormType /HalftoneType /ImageType /PatternType
    /.shadingtypes where { pop /ShadingType } if
  ] {
    /Category findresource
    dup /Instances get readonly pop
    .LocalInstances readonly pop
    readonly pop
  } forall
	% clean up
  systemdict /.fixresources undef
} bind def

⌨️ 快捷键说明

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