📄 gs_pdf.ps
字号:
/S_ { setstrokecolor /stroke fsexec } bdef
/S { S_ } 0 !
/f { setfillcolor /fill fsexec } 0 !
/f* { setfillcolor /eofill fsexec } 0 !
/n_ { newpath } bdef % don't allow n_ to get bound in
/n { n_ } 0 !
/s { closepath S_ } 0 !
/B_ { gsave setfillcolor fill grestore S_ } bdef
/B /B_ load 0 !
/b { closepath B_ } 0 !
/B*_ { gsave setfillcolor eofill grestore S_ } bdef
/B* /B*_ load 0 !
/b* { closepath B*_ } 0 !
% Clipping:
/Wdict 4 dict dup begin
/S_ { gsave setstrokecolor stroke grestore n_ } bdef
/f { gsave setfillcolor fill grestore n_ } 0 !
/f* { gsave setfillcolor eofill grestore n_ } 0 !
/n_ { end clip newpath } bdef
end readonly def
/W { //Wdict begin } 0 !
/W*dict 4 dict dup begin
/S_ { gsave setstrokecolor stroke grestore n_ } bdef
/f { gsave setfillcolor fill grestore n_ } 0 !
/f* { gsave setfillcolor eofill grestore n_ } 0 !
/n_ { end eoclip newpath } bdef
end readonly def
/W* { //W*dict begin } 0 !
% ---------------- Images ---------------- %
% We mustn't bind these now, since they reference Level 2 operators.
/Is % <imagedict> Is <imagedict> <datasource>
{ dup /DataSource get string /readstring cvx /currentfile cvx
% Stack: imagedict string -readstring- -currentfile-
3 index /FilterProc .knownget
{ dup dup 0 get /ASCIIHexDecode eq exch length 2 eq and
{ pop exch pop /readhexstring cvx exch }
{ exch exec exch exec }
ifelse
}
if 3 1 roll /pop cvx 4 packedarray cvx
} bdef
/EI { } def % placeholder, only needed when writing PostScript
% Note that ID* take a dictionary, not separate values;
% ColorSpace must be a name if it has no parameters;
% DataSource is the size of the row buffer in bytes;
% FilterProc is an optional procedure for constructing the decoding filter;
% and ImageMask is required, not optional.
/csimage
{ /setcolorspace where
{ pop dup /ColorSpace get csset setcolorspace pop image }
{ .colorspaceimage }
ifelse
} def % don't bind, because of Level 2
/ID % <imagedict> ID -
{ Is dup 3 -1 roll dup /ImageMask get
{ setfillcolor dup /Interpolate .knownget not { false } if
{ dup /DataSource 4 -1 roll put /imagemask cvx exec
}
{ { /Width /Height /Decode /ImageMatrix }
{ 1 index exch get exch }
forall pop exch 0 get 0 ne exch
5 -1 roll imagemask
}
ifelse
}
{ dup /ColorSpace get /DeviceGray eq
1 index /BitsPerComponent get 8 le and
1 index /Decode get dup 1 get 1 eq exch 0 get 0 eq and and
1 index /Interpolate .knownget not { false } if not and
{ { /Width /Height /BitsPerComponent /ImageMatrix }
{ 1 index exch get exch }
forall pop 5 -1 roll image
}
{ dup /DataSource 4 -1 roll put csimage
}
ifelse
}
ifelse
% If we were reading with readhexstring,
% skip the terminating > now.
% Stack: datasource
dup type /filetype ne % array or packedarray
{ dup 2 get /readhexstring eq
{ { dup 0 get exec read pop (>) 0 get eq { exit } if } loop
}
if pop
}
{ pop
}
ifelse EI
} 1 !
% IDx handles general images.
/IDx % <imagedict> IDx -
{ Is 1 index /DataSource 3 -1 roll put
csimage EI
} 1 !
% ---------------- Text control ---------------- %
/textbeginpage
{ /TextSpacing 0 def % 0 Tc
/TextLeading 0 def % 0 TL
/TextRenderingMode 0 def % 0 Tr
/TextRise 0 def % 0 Ts
/WordSpacing 0 def % 0 Tw
/TextHScaling 1.0 def % 100 Tz
/TextFont null def
/Show { showfirst } def
} bdef
% Contrary to the statement in the PDF manual, BT and ET *can* be nested,
% if the CharProc for a Type 3 font does a BT/ET itself.
% Since we always call the CharProc inside a q_/Q_, we simply ensure that
% the text state is saved and restored like the rest of the extended
% graphics state.
/settextmatrix
{ TextMatrix concat
TextHScaling 1 ne { TextHScaling 1 scale } if
TextRise 0 ne { 0 TextRise translate } if
} bdef
/settextstate { TextSaveMatrix setmatrix settextmatrix } bdef
/BT
{ currentdict /TextMatrix .knownget
{ identmatrix pop }
{ matrix /TextMatrix gput }
ifelse
currentdict /TextOrigin .knownget
{ dup 0 0 put 1 0 put }
{ [0 0] cvx /TextOrigin gput }
ifelse
{ showfirst } /Show gput
currentdict /TextSaveMatrix .knownget not
{ matrix dup /TextSaveMatrix gput }
if currentmatrix pop settextmatrix 0 0 moveto
TextFont dup null eq { pop } { setfont } ifelse
} bind 0 !
/ET
{ TextSaveMatrix setmatrix
} bind 0 !
/Tc_ { /TextSpacing gput { showfirst } /Show gput } bdef
/Tc { Tc_ } 1 !
/TL { /TextLeading gput } bind 1 !
/Tr { /TextRenderingMode gput { showfirst } /Show gput } bind 1 !
/Ts { /TextRise gput settextstate } bind 1 !
/Tw_ { /WordSpacing gput { showfirst } /Show gput } bdef
/Tw { Tw_ } 1 !
/Tz { 100 div /TextHScaling gput settextstate } bind 1 !
/Tf % <font> <scale> Tf -
{ dup 1 eq { pop } { scalefont } ifelse
dup setfont /TextFont gput
} 2 !
% Copy a font, removing its FID. If changed is true, also remove
% the UniqueID and XUID, if any. If the original dictionary doesn't have
% the keys being removed, don't copy it.
/.copyfontdict % <font> <changed> .copyfontdict <dict>
{ 1 index /FID known
1 index { 2 index /UniqueID known or 2 index /XUID known or } if
{ % We add 1 to the length just in case the original
% didn't have a FID.
exch dup length 1 add dict exch
{ % Stack: changed newfont key value
1 index /FID eq 4 index
{ 2 index /UniqueID eq or 2 index /XUID eq or }
if not { 3 copy put } if pop pop
}
forall exch
}
if pop
} bdef
% Insert a new Encoding or Metrics into a font if necessary.
% Return a possibly updated font, and a flag to indicate whether
% the font was actually copied.
/.updatefont % <font> <Encoding|null> <Metrics|null> .updatefont
% <font'> <copied>
{ 2 index 4 1 roll
dup null ne
{ 3 -1 roll true .copyfontdict dup /Metrics 4 -1 roll put exch }
{ pop }
ifelse
dup null ne 1 index 3 index /Encoding get ne and
{ exch false .copyfontdict dup /Encoding 4 -1 roll put }
{ pop }
ifelse exch 1 index ne
} bdef
% ---------------- Text positioning ---------------- %
/Td_
{ TextOrigin exch 4 -1 roll add 3 1 roll add
2 copy /TextOrigin load astore pop moveto
} bdef
/Td { Td_ } 2 !
/TD { dup neg /TextLeading gput Td_ } 2 !
/T*_ { 0 TextLeading neg Td_ } bdef
/T* { T*_ } 0 !
/Tm
{ TextMatrix astore pop settextstate
0 0 /TextOrigin load astore pop
0 0 moveto
} 6 !
% ---------------- Text painting ---------------- %
/textrenderingprocs [ % (0 is handled specially)
{ tf } { tS } { tB } { tn }
% We don't know what the clipping modes mean....
4 copy
] readonly def
/setshowstate
{ WordSpacing 0 eq TextSpacing 0 eq and
{ TextRenderingMode 0 eq
{ { setfillcolor show } }
{ { false charpath textrenderingprocs TextRenderingMode get exec } }
ifelse
}
{ TextRenderingMode 0 eq
{ WordSpacing 0 eq
{ { setfillcolor TextSpacing exch 0 exch ashow } }
{ TextSpacing 0 eq
{ { setfillcolor WordSpacing exch 0 exch 32 exch widthshow } }
{ { setfillcolor WordSpacing exch TextSpacing exch 0 32 4 2 roll 0 exch awidthshow } }
ifelse
}
ifelse
}
{ { WordSpacing TextSpacing 2 index
% Implement the combination of t3 and false charpath.
% Stack: xword xchar string
0 1 2 index length 1 sub
{ 2 copy 1 getinterval false charpath
% Stack: xword xchar string i
4 copy get 32 eq { add } { exch pop } ifelse 0 rmoveto
pop
}
for pop pop pop pop
textrenderingprocs TextRenderingMode get exec
}
}
ifelse
}
ifelse /Show gput
} bdef
/showfirst { setshowstate Show } def
/Tj { Show } 1 !
/' { T*_ Show } 1 !
/" { exch Tc_ exch Tw_ T*_ Show } 3 !
% TJ expects a mark followed by arguments, not an array.
/TJ
{ counttomark -1 1
{ -1 roll dup type /stringtype eq
{ Show }
{ neg 1000 div 0 rmoveto }
ifelse
}
for pop
% Adobe implementations don't accept /[, so we don't either.
} ([) cvn !
/tf { setfillcolor currentpoint fill moveto } bdef
/tn { currentpoint newpath moveto } bdef
% For stroking characters, temporarily restore the graphics CTM so that
% the line width will be transformed properly.
/Tmatrix matrix def
/tS
{ setstrokecolor
currentpoint //Tmatrix currentmatrix TextSaveMatrix setmatrix stroke
setmatrix moveto
} bdef
/tB { gsave tf grestore tS } bdef
end readonly put % GS_PDF_ProcSet
setglobal
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -