Professional Documents
Culture Documents
% font2pcl.ps
% Write out a font as a PCL bitmap font.
/origfont
{ { dup /OrigFont known not { exit } if /OrigFont get } loop
FontDirectory 1 index /FontName get .knownget
{ % Stack: origfont namedfont
1 index /FontType get 1 index /FontType get eq
{ 1 index /UniqueID .knownget
{ 1 index /UniqueID .knownget
{ eq { exch } if }
{ pop }
ifelse
}
if
}
if pop
}
if
} def
} def
/style.posture.keys
[ { (Italic) } { (Oblique) }
{ }
] def
/style.posture.values <010100> def
/style.appearance.width.keys
[ { (Ultra) (Compressed) }
{ (Extra) (Compressed) }
{ (Extra) (Condensed) }
{ (Extra) (Extended) }
{ (Extra) (Expanded) }
{ (Compressed) }
{ (Condensed) }
{ (Extended) }
{ (Expanded) }
{ }
] def
/style.appearance.width.values <04030207070201060600> def
/width.type.keys
[ { (Ultra) (Compressed) }
{ (Extra) (Compressed) }
{ (Extra) (Condensed) }
{ (Extra) (Expanded) }
{ (Compressed) }
{ (Condensed) }
{ (Expanded) }
{ }
] def
/width.type.values <fbfcfd03fdfe0200> def
/stroke.weight.keys
[ { (Ultra) (Thin) }
{ (Ultra) (Black) }
{ (Extra) (Thin) }
{ (Extra) (Light) }
{ (Extra) (Bold) }
{ (Extra) (Black) }
{ (Demi) (Light) }
{ (Demi) (Bold) }
{ (Semi) (Light) }
{ (Semi) (Bold) }
{ (Thin) }
{ (Light) }
{ (Bold) }
{ (Black) }
{ }
] def
/stroke.weight.values <f907fafc0406fe02ff01fbfd030500> def
/vendor.keys
[ { (Agfa) }
{ (Bitstream) }
{ (Linotype) }
{ (Monotype) }
{ (Adobe) }
{ }
] def
/vendor.default.index 4 def % might as well be Adobe
/old.vendor.values <020406080a00> def
/new.vendor.values <010203040500> def
/vendor.initials (CBLMA\000) def
% Convert and write a PCL font for the current font and transformation.
% Write the font header. We split this off only to avoid overflowing
% the limit on the maximum size of a procedure.
% Free variables: outfile uury u0y rw rh orientation uh ully
/writefontheader
{ outfile (\033\)s) writestring
outfile 64 WriteResolution? { 4 add } if
Copyright length add write==only
outfile (W) writestring
WriteResolution? { 20 68 } { 0 64 } ifelse
(Font Descriptor Size) wword
(Header Format) wbyte
1 (Font Type) wbyte
FullName style.posture.keys keysearch style.posture.values exch get
FullName style.appearance.width.keys keysearch
style.appearance.width.values exch get 4 mul add
PaintType 2 eq { 32 add } if
/style exch def
style -8 bitshift (Style MSB) wbyte
0 (Reserved) wbyte
/baseline uury 1 sub u0y sub def
baseline (Baseline Position) wword
rw (Cell Width) wword
rh (Cell Height) wword
orientation (Orientation) wbyte
FontInfo /isFixedPitch .knownget not { false } if
{ 0 } { 1 } ifelse (Spacing) wbyte
% Use loop/exit to fake a multiple-exit block.
{ Encoding StandardEncoding eq { 10 (J) exit } if
Encoding ISOLatin1Encoding eq { 11 (J) exit } if
Encoding SymbolEncoding eq { 19 (M) exit } if
Encoding DingbatsEncoding eq { 10 (L) exit } if
% (Warning: unknown Encoding, using ISOLatin1.\n) print flush
11 (J) exit
}
loop
0 get 64 sub exch 32 mul add (Symbol Set) wword
( ) stringwidth pop 0 dtransform add abs 4 mul
/pitch exch def
pitch cvi (Pitch) wword
uh 4 mul (Height) wword % Height
(x) charheight (x-Height) wword
FullName width.type.keys keysearch
width.type.values exch get (Width Type) wbyte
style 255 and (Style LSB) wbyte
FullName stroke.weight.keys keysearch
stroke.weight.values exch get (Stroke Weight) wbyte
FullName vendor.keys keysearch
dup vendor.initials exch get 0 eq
{ % No vendor in FullName, try Notice
pop Copyright vendor.keys keysearch
dup vendor.initials exch get 0 eq { pop vendor.default.index } if
}
if
/vendor.index exch def
0 (Typeface LSB) wbyte % punt
0 (Typeface MSB) wbyte % punt
0 (Serif Style) wbyte % punt
2 (Quality) wbyte
0 (Placement) wbyte
gsave FontMatrix concat rot neg rotate
/ulwidth
FontInfo /UnderlineThickness .knownget
{ 0 exch dtransform exch pop abs }
{ resolution 100 div }
ifelse def
FontInfo /UnderlinePosition .knownget
{ 0 exch transform exch pop negY ulwidth 2 div add }
{ ully ulwidth add }
ifelse u0y sub
round cvi 1 .max 255 .min (Underline Position) wbyte
ulwidth round cvi 1 .max 255 .min (Underline Thickness) wbyte
grestore
uh 1.2 mul 4 mul cvi (Text Height) wword
(average lowercase character) dup stringwidth
pop 0 dtransform add abs
exch length div 4 mul cvi (Text Width) wword
0
{ dup Encoding exch get /.notdef ne { exit } if
1 add
}
loop (First Code) wword
255
{ dup Encoding exch get /.notdef ne { exit } if
1 sub
}
loop (Last Code) wword
pitch dup cvi sub 256 mul cvi (Pitch Extended) wbyte
0 (Height Extended) wbyte
0 (Cap Height) wword % (default)
currentfont /UniqueID known { UniqueID } { 0 } ifelse
16#c1000000 add (Font Number (Adobe UniqueID)) wdword
FontName length 16 .max string
dup FontName exch cvs pop
outfile exch 0 16 getinterval writestring % Font Name
WriteResolution?
{ resolution dup (X Resolution) wword (Y Resolution) wword
}
if
outfile Copyright writestring % Copyright
} def
gsave
FontMatrix concat
0 0 transform
negY round cvi /r0y exch def
round cvi /r0x exch def
ixbbox
negY /rury exch def /rurx exch def
negY /rlly exch def /rllx exch def
/rminx rllx rurx .min def
/rminy rlly negY rury negY .min def
/rw rurx rllx sub abs def
/rh rury rlly sub abs def
gsave rot neg rotate
0 0 transform
negY round cvi /u0y exch def
round cvi /u0x exch def
ixbbox
negY /uury exch def /uurx exch def
negY /ully exch def /ullx exch def
/uw uurx ullx sub def
/uh uury ully sub def
grestore
DEBUG
{ (rmatrix: ) print matrix currentmatrix ==
(rFontBBox: ) print [rllx rlly rurx rury] ==
(uFontBBox: ) print [ullx ully uurx uury] ==
flush
} if
grestore
writefontheader
matrix currentmatrix
dup 4 rminx neg put
dup 5 rminy neg put
% Round the width up to a multiple of 8
% so we don't get garbage bits in the last byte of each row.
rw 7 add -8 and rh <ff 00> makeimagedevice
/cdevice exch def
nulldevice % prevent page device switching
cdevice setdevice
}
for
% Wrap up.
upper setcachelimit
outfile closefile
} def
%**************** Test
/PCLTEST where {
pop
/DEBUG true def
/CDEBUG true def
/VDEBUG true def
/Times-Roman findfont 10 scalefont setfont
(t.pcf) (w) file
300 72 div dup scale
300 writePCL
flush quit
} if