📄 pdf_font.ps
字号:
{ buffer type1readdata
}
ifelse
} bdef
% Read the next block of the encrypted portion.
/type1trailer
(0000000000000000000000000000000000000000000000000000000000000000\n\
0000000000000000000000000000000000000000000000000000000000000000\n\
0000000000000000000000000000000000000000000000000000000000000000\n\
0000000000000000000000000000000000000000000000000000000000000000\n\
0000000000000000000000000000000000000000000000000000000000000000\n\
0000000000000000000000000000000000000000000000000000000000000000\n\
0000000000000000000000000000000000000000000000000000000000000000\n\
0000000000000000000000000000000000000000000000000000000000000000\n\
cleartomark\n)
readonly def
/type1read2 % <left> type1read2 <string> <left'>
{ DEBUG { (read2 ) print } if
dup 0 eq
{ pop sectionstr 0 2 put
stream /Length3 oget
dup 0 eq
{ DEBUG { (trailer ) print } if
type1trailer exch
}
{ type1read3
}
ifelse
}
{ buffer2 type1readdata exch
buffer /ASCIIHexEncode filter dup 3 -1 roll writestring closefile
buffer (>) search pop exch pop exch pop exch
}
ifelse
} bdef
% Read the next block of the final text portion.
% When finished, this procedure returns an empty string.
/type1read3 % <left> type1read3 <string> <left'>
{ DEBUG { (read3 ) print } if
buffer type1readdata
} bdef
% ---------------- Type 3 fonts ---------------- %
/.notdefEncoding 256 { /.notdef } repeat 256 packedarray def
/buildType3 % <Type3-font-resource> buildType3 <font>
{ 8 dict begin
/FontType 3 def
/Resources 1 index /Resources knownoget { oforce } { 0 dict } ifelse def
/FontBBox 1 index /FontBBox get cvx def
/FontMatrix 1 index /FontMatrix oget def
/CharProcs 1 index /CharProcs oget def
/FontName 1 index /Name get genfontname def
/Encoding .notdefEncoding 2 index getencoding def
/BuildGlyph {
% Stack: font glyphname
1 index /CharProcs get exch oget
PDFfile fileposition exch
false resolvestream
% Stack: font filepos stream
% Don't let setgcolor set the color inside the BuildGlyph
% procedure, because this causes an /undefined error.
q null /FillColor gput null /StrokeColor gput
2 index /Resources get exch pdfopdict .pdfruncontext
Q
PDFfile exch setfileposition pop
} bdef
FontName currentdict end definefont exch pop
} bdef
% ---------------- TrueType fonts ---------------- %
/TTfonts mark
/Arial /Helvetica
/Arial,Italic /Helvetica-Oblique
/Arial,Bold /Helvetica-Bold
/Arial,BoldItalic /Helvetica-BoldOblique
/TimesNewRoman /Times-Roman
/TimesNewRoman,Italic /Times-Italic
/TimesNewRoman,Bold /Times-Bold
/TimesNewRoman,BoldItalic /Times-BoldItalic
.dicttomark readonly def
/buildTrueType % <TrueType-font-resource> buildTrueType <font>
{ dup /BaseFont get
dup TTfonts exch .knownget { exch pop } if pdffindfont
} bdef
% Read an embedded TrueType font.
/readtruetype % <font-resource> <stream-dict> readtruetype <font>
{ % This is much simpler than readtype1, because we don't
% have to deal with the tripartite .PFB format.
PDFfile fileposition 3 1 roll
true resolvestream readfontfilter .loadttfont
dup /FontName get exch definefont exch pop
PDFfile 3 -1 roll setfileposition
} bdef
% ---------------- Type 0 fonts ---------------- %
% Predefine the known CMaps, but only create them on demand.
/knownCMaps mark
/Identity-H { /Identity-H 0 makeIdentityCMap }
/Identity-V { /Identity-V 1 makeIdentityCMap }
.dicttomark def
/makeIdentityCMap { % <cmapname> <wmode> .makeIdentityCMap -
.currentglobal true .setglobal 3 1 roll
/CIDInit /ProcSet findresource begin
12 dict begin
/WMode exch def
/CMapName exch def
begincmap
/CIDSystemInfo 3 dict dup begin
/Registry (Adobe) def
/Ordering (Japan1) def
/Supplement 0 def
end def
%/CMapName ... def
/CMapVersion 1 def
/CMapType 1 def
%/WMode ... def
2 begincodespacerange
<0001> <00ff>
<0100> <ffff>
endcodespacerange
2 begincidrange
<0001> <00ff> 1
<0100> <ffff> 256
endcidrange
endcmap
CMapName currentdict /CMap defineresource
knownCMaps CMapName 2 index put
end % CMap
end % CIDInit ProcSet
exch .setglobal
} bdef
/buildType0 % <Type0-font-resource> buildType0 <font>
{ 10 dict begin
/FontType 0 def
/FontMatrix 1 index /FontMatrix knownoget not { matrix } if def
/FontName 1 index /BaseFont get def
/FMapType 9 def
/Encoding [
0 1 4 index /DescendantFonts oget length 1 sub { } for
] def
/FDepVector [
2 index /DescendantFonts oget { exec resourcefont } forall
] def
/CMap 1 index /Encoding oget
dup type /nametype eq {
dup /CMap resourcestatus {
pop pop /CMap findresource
} {
knownCMaps 1 index .knownget
{ exch pop exec } { /undefined signalerror } ifelse
} ifelse
} {
resolvestream
} ifelse
def
FontName currentdict end definefont exch pop
} bdef
% ---------------- CIDFontType0/2 fonts ---------------- %
% Insert metrics into a CIDFont, by saving the PDF W, W2, DW, and DW2
% arrays and using a (currently very inefficient) CDevProc.
/addCIDmetrics { % <CIDFont-resource> addCIDmetrics <fontdict>
dup /BaseFont get /CIDFont findresource
dup length 5 add dict .copydict
dup /FID undef
dup /UniqueID undef
dup /XUID undef
% Insert the widths into the font.
{W W2 DW DW2} {
% Stack: pdfresource newfont key
2 index 1 index .knownget {
2 index 3 1 roll put
} {
pop
} ifelse
} forall
dup /CDevProc 1 index /CIDWProc load /exec load 3 packedarray cvx put
exch pop
} bdef
% Apply the [D]W[2] metrics to a character before displaying.
/CIDWProc { % <w0x> <w0y> <llx> <lly> <urx> <ury>
% <w1x> <w1y> <vx> <vy> <cid> <font> CIDWproc
% <w0x'> ... <vy'>
begin
% Look up and apply [D]W
10 index
currentdict /DW .knownget { 1000 div exch pop } if
currentdict /W .knownget {
% Search the W array for the CID.
% ****** NOT IMPLEMENTED YET ******
pop
} if
0 13 2 roll 11 -2 roll pop pop
% Look up and apply [D]W2
% ****** NOT IMPLEMENTED YET ******
pop end
} bdef
/buildCIDType0 { % <CIDFontType0-font-resource> buildCIDType0 <font>
addCIDmetrics dup /CIDFontName get exch /CIDFont defineresource
} bdef
/buildCIDType2 { % <CIDFontType2-font-resource> buildCIDType2 <font>
addCIDmetrics
%****** Handle CIDToGIDMap ******
dup /BaseFont get exch /CIDFont defineresource
} bdef
% ---------------- Other embedded fonts ---------------- %
/fontloadprocs mark
/Type1C /readType1C cvx
.dicttomark readonly def
% Read an embedded compressed font.
/readType1C % <font-resource> <stream-dict> readType1C <font>
{ PDFfile fileposition 3 1 roll
dup true resolvestream dup readfontfilter
% Stack: pos resource streamdict stream filter
3 index /FontDescriptor oget /FontName oget
1 index FRD
closefile closefile pop
PDFfile 3 -1 roll setfileposition
/FontDescriptor oget /FontName oget findfont
} bdef
% ---------------- Font lookup ---------------- %
/fonttypeprocs mark % <font-resource> -proc- <font>
/Type0 /buildType0 cvx
/Type1 /buildType1 cvx
/MMType1 1 index
/Type3 /buildType3 cvx
/TrueType /buildTrueType cvx
/CIDFontType0 /buildCIDType0 cvx
/CIDFontType2 /buildCIDType2 cvx
.dicttomark readonly def
/resourcefont % <font-resource> resourcefont <font>
{ dup /PSFont .knownget
{ /FID .knownget { type /fonttype eq } { false } ifelse }
{ false }
ifelse
{ /PSFont get
}
{ dup dup /FontDescriptor knownoget
{ % Stack: font-res font-res font-desc
dup /FontFile knownoget
{ exch pop 1 index 3 1 roll readtype1 adjustfont true }
{ dup /FontFile2 knownoget
{ exch pop 1 index 3 1 roll readtruetype adjustfont true }
{ /FontFile3 knownoget
{ 1 index exch dup /Subtype get fontloadprocs exch get exec adjustfont true }
{ false }
ifelse
}
ifelse
}
ifelse
}
{ false }
ifelse
% Stack: font-res font-res false
% -or-: font-res font true
not
{ dup /Subtype get fonttypeprocs exch get exec }
if
2 copy /PSFont exch put
exch pop
}
ifelse
} bdef
drawopdict begin
/d0 /setcharwidth load def
/d1 /setcachedevice load def
/Tf
{ 1 index Page /Font rget not { 1 index /undefinedfont signalerror } if
resourcefont exch Tf pop
} bdef
end
end % pdfdict
end % GS_PDF_ProcSet
.setglobal
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -