home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1996 September
/
PCWK996.iso
/
sharewar
/
95
/
narzedzi
/
ambra
/
ambr32a1.exe
/
FILE
/
ARCHIVE.Z
/
ACROBAT
/
VIEWER32.EXE
/
PSPROCSET
/
6
< prev
next >
Wrap
Text File
|
1996-02-22
|
9KB
|
421 lines
%%BeginFile: pdftext.prc
%%Copyright: Copyright 1987-1994 Adobe Systems Incorporated. All Rights Reserved.
% text operators for PDF
PDF /PDFText 51 dict dup begin put
% initialization
/initialize { /TZ isdefined? not { PDFText begin } if } bd
/terminate { currentdict PDFText eq { end } if } bd
% copy all the values but the FID and UniqueID into the font dict
% use this for paint changes but not for encoding (cache issues)
% font must be current dict
/CopyFont {
{ % forall
1 index /FID ne 2 index /UniqueID ne and
{ def } { pop pop } ifelse
} forall
} bd
% [ number value stream [ array for encoding modification ] modifyEncoding ==> [ modified array ]
/modEnc {
/_enc xdd % the encoding dict
/_icode 0 dd % next code point
counttomark 1 sub -1 0 % loop over every item above mark
{ % for
index % get bottom object
dup type /nametype eq
{
_enc _icode 3 -1 roll put % insert name at _icode
_icode 1 add % increment
}
if
/_icode xdd
} for
cleartomark
_enc % return the modified encoding
} bd
% [ 256 glyph-nums translateEncoding ==> new Encoding array
% for each glyph-num, get glyph-name at that code point in Encoding array
% create new Encoding array by replacing number with name
/trEnc {
/_enc xdd % the encoding dict
255 -1 0 {
exch dup -1 eq % index glyph-num
{ pop /.notdef }
{ Encoding exch get }
ifelse % index glyph-name
_enc 3 1 roll put
} for
pop % mark
_enc % return the modified encoding
} bd
% Define a PDF encoding
% (encoding pairs) enc-num TE -
/TE {
/_i xdd
StandardEncoding 256 array copy modEnc
_pdfEncodings exch _i exch put
} bd
% re-define font
% expected arguments
% for 'normal fonts :
% [ /F1/Helvetica-Bold defaultEncoding TZ
% for cartographic, pictographic, and expert fonts :
% [ ... number value stream ... /F1/Symbol defaultEncoding TZ
/TZ
{
% platform dependent coding flag
/_usePDFEncoding xdd
% substitute Helvetica if font not available
%dup findfont dup /FontName known
% {
% % substitute if FontName is Courier and original is not
% dup /FontName get /Courier eq 3 -1 roll /Courier ne and
% { pop /Helvetica findfont }
% if
% }
% { exch pop }
%ifelse
% never mind (don't substitute) -- too confusing for users
findfont
% create a new dictionary with length
% equal to original dictionary length + 2
% copy all the key/value pairs except FID
% call makeblended font with the weight values if _wv is an array
dup length 2 add dict
begin
% copy all the values but the FID into the new dictionary
{
1 index /FID ne { def } { pop pop } ifelse
} forall
% define FontName
/FontName exch def
% if a known encoding is specified, use that
% if a modified encoding is needed, apply mods
% else it's a substitute encoding
_usePDFEncoding 0 ge
{ % known encoding
/Encoding _pdfEncodings _usePDFEncoding get def
pop % mark
}
{
_usePDFEncoding -1 eq
{ % custom or original encoding
counttomark 0 eq
{ pop } % mark
{ % custom encoding to be done
Encoding 256 array copy
modEnc /Encoding exch def
}
ifelse
}
{ % translation
256 array
trEnc /Encoding exch def
}
ifelse
}
ifelse
FontName currentdict
end
% register the new font
definefont pop
}
bd
% marking operators
% like awidthshow but don't draw anything
/swj { % cx cy fillchar ax ay string swj x y
dup 4 1 roll
dup length exch stringwidth
exch 5 -1 roll 3 index mul add
4 1 roll 3 1 roll mul add
6 2 roll /_cnt 0 dd
{1 index eq {/_cnt _cnt 1 add dd} if} forall pop
exch _cnt mul exch _cnt mul 2 index add 4 1 roll 2 index add 4 1 roll pop pop
} bd
% like awidthshow but stroke instead of fill
/jss { % cx cy fillchar ax ay string matrix jss -
4 1 roll
{ % cx cy fillchar matrix ax ay char 0 0 {proc} -
2 npop
(0) exch 2 copy 0 exch put
gsave
32 eq
{
exch 6 index 6 index 6 index 5 -1 roll widthshow
currentpoint
}
{
false charpath currentpoint
4 index setmatrix stroke
}
ifelse
grestore
moveto
2 copy rmoveto
} exch cshow
6 npop
} def
% like awidthshow but add char to current path instead of fill
/jsp % cx cy fillchar ax ay string jsp -
{
{ % cx cy fillchar ax ay char 0 0 {proc} -
2 npop
(0) exch 2 copy 0 exch put
32 eq
{ exch 5 index 5 index 5 index 5 -1 roll widthshow }
{ false charpath }
ifelse
2 copy rmoveto
} exch cshow
5 npop
} bd
% text painting operators
% set up for awidthshow
% string trj cx cy fillchar ax ay string
/trj { _cx 0 32 _ax 0 6 5 roll } bd
% awidthshow (fill)
% string pjsf -
/pjsf { trj sfc awidthshow } bd
% awidthshow (stroke)
% string pjss -
/pjss { trj _ctm ssc jss } bd
% awidthshow (clip)
% string pjsc -
/pjsc { trj jsp } bd
% define a version of Tj for the 8 Tr modes
% show justified text
% textString Tj -
/_Tjdef [
% 0 fill
/pjsf load
% 1 stroke
/pjss load
{ % 2 fill and stroke
dup
currentpoint 3 2 roll
pjsf
newpath moveto
pjss
} bind
{ % 3 invisible
trj swj rmoveto
} bind
{ % 4 fill and clip
dup currentpoint 4 2 roll gsave
pjsf
grestore 3 1 roll moveto
pjsc
} bind
{ % 5 stroke and clip
dup currentpoint 4 2 roll
currentpoint gsave newpath moveto
pjss
grestore 3 1 roll moveto
pjsc
} bind
{ % 6 fill stroke and clip
dup currentpoint 4 2 roll gsave
dup currentpoint 3 2 roll
pjsf
newpath moveto
pjss
grestore 3 1 roll moveto
pjsc
} bind
% 7 clip
/pjsc load
] def
% begin/end text
/BT % begin text % - BT -
{
/_inT true dd
_ctm currentmatrix pop matrix _tm copy pop
0 _rise translate _hs 1 scale
0 0 moveto
} bd
/ET % end text % - ET -
{
/_inT false dd
_tr 3 gt {clip} if
_ctm setmatrix newpath
} bd
% Render mode % render Tr -
/Tr {
_inT { _tr 3 le {currentpoint newpath moveto} if } if
dup /_tr xdd
_Tjdef exch get /Tj xdd
} bd
% Text matrix operators
% internal set text matrix % - iTm - (uses _tm as implicit argument)
/iTm { _ctm setmatrix _tm concat 0 _rise translate _hs 1 scale } bd
% set text matrix % a b c d tx ty Tm -
/Tm { _tm astore pop iTm 0 0 moveto } bd
% translate text matrix % tx ty Td -
/Td { _mtx translate _tm _tm concatmatrix pop iTm 0 0 moveto } bd
% translate text matrix, set leading % tx ty TD -
/TD { dup /_ld xdd Td } bd
% Attributes
% set font name and size % fontname size Tf -
/Tf {
dup 1000 div /_fScl xdd
exch findfont exch scalefont setfont
} bd
% set leading % leading TL -
/TL { neg /_ld xdd } bd
% set computed word spacing % wordSpace Tw
/Tw { /_cx xdd } bd
% set computed char spacing % charSpace Tc -
/Tc { /_ax xdd } bd
% set super/subscripting (rise) % rise Ts -
/Ts { /_rise xdd currentpoint iTm moveto } bd
% set horizontal scaling % scalePercent Tz -
/Tz { 100 div /_hs xdd iTm } bd
% Text Bodies
% kern % autoKern kernValue Tk -
% autoKern = 0 -> manual kern, = 1 -> auto kern
% kernValue = kern value in em/1000 space
/Tk { exch pop _fScl mul neg 0 rmoveto } bd
% carriage return & line feed % - T* -
/T* { 0 _ld Td } bd
% short-hand for CRLF & show text % - ' -
/' { 0 0 3 -1 roll " } bd
% short-hand for CRLF & show justified text % wordSpace charSpace string " -
/" { exch Tc exch Tw T* Tj } bd
/TJ { % string-based xshow % [ strings & kern offsets ] TJ
{
dup type /stringtype eq
{ Tj }
{ 0 exch Tk }
ifelse
} forall
} bd
% print a discretionary hyphen % - T- -
/T- { _hy Tj } bd
% Type 3 support
/d0/setcharwidth ld
% Don't allow color changes if setcachedevice
/d1 { setcachedevice /sfc{}dd /ssc{}dd } bd
/nND {{/.notdef} repeat} bd % int nND -
/T3Defs { % def shared BuildChar & BuildGlyph
/BuildChar
{
1 index /Encoding get exch get
1 index /BuildGlyph get exec
}
def
/BuildGlyph { % fontdict /name BuildGlyph -
exch begin
GlyphProcs exch get exec
end
} def
} bd
/MakeBold { % newname oldname -
findfont dup dup length 2 add dict
begin
CopyFont
/PaintType 2 def
/StrokeWidth .03 0 FontMatrix idtransform pop def
/dummybold currentdict
end
definefont % newname painttype2font
8 dict begin
/_basefont exch def
/_basefonto exch def
/FontType 3 def
/FontMatrix[1 0 0 1 0 0]def
/FontBBox[0 0 1 1]def
/Encoding StandardEncoding def
/BuildChar
{
exch begin
_basefont setfont
( )dup 0 4 -1 roll put
dup stringwidth
1 index 0 ne { exch .03 add exch }if
setcharwidth
0 0 moveto
gsave
dup show
grestore
_basefonto setfont
show
end
}bd
currentdict
end
definefont pop
}bd
/MakeItalic { % newname oldname -
findfont _italMtx makefont
dup length dict
begin
CopyFont
% newname
currentdict
end
definefont pop
}bd
/MakeBoldItalic { % newname oldname -
/dummybold exch
MakeBold
/dummybold
MakeItalic
}bd
currentdict readonly pop end
%%EndFile