Beruflich Dokumente
Kultur Dokumente
%
% This software is provided AS-IS with no warranty, either express or
% implied.
%
% This software is distributed under license and may not be copied,
% modified or distributed except as expressly authorized under the terms
% of the license contained in the file LICENSE in this distribution.
%
% For more information about licensing, please refer to
% http://www.ghostscript.com/licensing/. For information on
% commercial licensing, go to http://www.artifex.com/licensing/ or
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
% San Rafael, CA 94903, U.S.A., +1(415)492-9861.
% Find a font (except for embedded ones), and adjust its encoding if necessary.
/.pdfdfndict mark
/defaultfontname /Helvetica
.dicttomark readonly def
/pdffindfont { % <font-resource> <fontname> pdffindfont <font>
% If the font isn't available, synthesize one based on
% its descriptor.
dup /Font resourcestatus {
pop pop pdfcachefont
} {
1 index /FontDescriptor knownoget {
% Stack: font-res fontname fontdesc
dup /Flags oget
dup 16#40 and -6 bitshift % 1, oblique/italic
1 index 16#40000 and -17 bitshift add % 2, bold
exch 16#2 and 2 bitshift add % 8, serif
% We should look at the fixed flag, too.
% Stack: font-res fontname fontdesc properties
% The state dictionary for the embedded Type 1 font reading procedure
% has the following keys and values:
% data - stream (filter)
% buffer, buffer2 - string
% hexify - procedure to convert buffer to hex if needed
% leftstr - string containing (non-negative) integer
% sectionstr - string containing a character 0 .. 3
% stream - (stream) dictionary
% proc - procedure of the form {-dict- type1read}
% pfbhdr - string containing 16#80 if PFB, 0 otherwise
% When the procedure is executing, this dictionary is current.
% leftstr and sectionstr are strings so that we can change their values
% reliably in case the font executes a restore!
% We also have to do something special about embedded fonts that
% execute definefont more than once -- that is the function of topFontDict.
% Read the initial byte to see if we need to skip a 6 byte PFB header
/type1read0 { % <left> type1read0 <string> <left'>
sectionstr 0 1 put % either way we go to the next stage
pfbhdr type1readdata
1 index 0 get 16#80 eq {
( **** Warning: Embedded Type1 font in PFB format is not valid PDF.\n)
pdfformaterror
PDFDEBUG { (skipping PFB header) = flush } if
exch pop buffer 0 5 getinterval type1readdata exch
dup 4 get 256 mul 1 index 3 get add 256 mul
1 index 2 get add 256 mul 1 index 1 get add
PDFDEBUG { (PFB segment length = ) print dup = } if
exch pop % discard the string keeping the PFB segment length
2 copy ne {
( **** Warning: Type 1 PFB segment length and Length 1 value do not
match.\n)
pdfformaterror
exch % keep the PFB length instead
} if
pop
buffer type1readdata % go ahead and read a block
}
if % if not PFB, return pfbhdr string (first char of file, usually %).
} bdef
/TTfonts mark
/Arial /Helvetica
/Arial,Italic /Helvetica-Oblique
/Arial,Bold /Helvetica-Bold
/Arial,BoldItalic /Helvetica-BoldOblique
/CourierNew /Courier
/CourierNew,Bold /Courier-Bold
/TimesNewRoman /Times-Roman
/TimesNewRoman,Italic /Times-Italic
/TimesNewRoman,Bold /Times-Bold
/TimesNewRoman,BoldItalic /Times-BoldItalic
.dicttomark readonly def
% Insert metrics into a CIDFont, by saving the PDF W, W2, DW, and DW2
% arrays and using a (currently very inefficient) CDevProc.
% For detail, refer "PDF Reference" 2nd ed., p314 "5.6.3 CIDFonts".
% It notes default DW is 0, but Acrobat Reader uses 1000 as default.
% If DW is 0, currentpoint does not move by default in rendering text
% horizontally, the result is unreadable. You can check it by Acrobat.
1 index /W .knownget {
dup 2 index /W 3 -1 roll put
.pdfMakeInternalW 1 index /.internalW 3 -1 roll put
} if
dup /CDevProc 1 index /CIDWProc load /exec load 3 packedarray cvx put
exch pop
} bdef
7 dict
begin
/itemSize exch def
/M exch def % original /W or /W2
/Msize M length def
/Mi { M i get } def % W[i]
/Mi1 { M i 1 add get } def % W[i + 1]
/putMTXEntry <<
/arraytype {
[
[Mi Mi Mi1 length itemSize idiv add 1 sub]
true
[
0 itemSize Mi1 length 1 sub {
[ exch 1 1 index itemSize add 1 sub { Mi1 exch get } for ]
} for
]
]
/i i 2 add def
}
/integertype {
[
[Mi Mi1]
false
[[ i 2 add 1 i 1 add itemSize add { M exch get } for ]]
]
/i i 3 add def
}
>> def
/i 0 def
exch
{
{
dup 0 get {} forall % Stack: <cid> <entry> <cid_0> <cid_1>
3 index lt { pop pop false exit } if
2 index exch sub dup 0 lt { pop pop false exit } if
1 index 1 get not { pop 0 } if
exch 2 get exch get true exit
} loop
{ exit } if
} forall
dup type /arraytype eq { exch pop true } { pop false } ifelse
} def
{
currentdict /DW .knownget not { % no DW
.pdfDefaultDW exit % replace <w0x> by defaultDW
} if
exit
} loop
FontType 11 eq {
1000 div % <w0x'> (normalized W)
} if
0 % <w0y'>
% Stack: <w0x> <w0y> <llx> <lly> <urx> <ury> <cid> <w0x'> <w0y'>
9 -2 roll pop pop % discard <w0x> <w0y>
7 2 roll % put <w0x'> <w0y'>
} loop
% Stack: <w0x'> <w0y'> <llx> <lly> <urx> <ury> <w1x'> { [<vy'> <w1y'>] |
[<w1y'> <vx'> <vy'>] }
dup length 2 eq { % this is DW2
FontType 11 eq {{1000 div}} {{}} ifelse forall exch
8 index 2 div % <vx'> = <w0x'> / 2
exch
}{ % assume W2
FontType 11 eq {{1000 div}} {{}} ifelse forall
} ifelse
end % recover currentdict
} def
/makeboldfont {
16 dict begin
/strokewidth exch def
/basecidfont exch def
/FontMatrix [ 1 0 0 1 0 0 ] def
currentdict
end
dup /CIDFontName get exch /CIDFont defineresource
} bind def
/fontloadprocs mark
/Type1C /readType1C cvx
/CIDFontType0C /readCIDFontType0C cvx
.dicttomark readonly def
/adjustfonttypes mark
/Type1 //adjustfont
/MMType1 //adjustfont
/TrueType //adjustfont
/CIDFontType0 //adjustCIDType0
/CIDFontType2 //adjustCIDType2
.dicttomark readonly def
drawopdict begin
/d0 {
.adjustcharwidth setcharwidth
} bdef
/d1 {
4 index 0 ne {
% invalid wy parameter for d1 in Type3 font (must be 0)
% Even though the PDF 1.4 specification states that this must be 0,
% Distiller sometimes creates Type3 fonts with non-zero wy. We set
% it to 0 since this is apparently what Acrobat Reader 4 and 5 do,
% but if the specification is ever changed to allow non-zero wy, this
% will not work.
5 -1 roll pop 0 5 1 roll % set wy to 0
} if
end % pdfdict
end % GS_PDF_ProcSet
.setglobal