Professional Documents
Culture Documents
%
% 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 the side bearing and width information that begins a CharString.
% Arguments: charstring. Result: charstring sizethroughsbw.
/findsbw
{ dup parsesbw 4 { exch pop } repeat skipsbw
} bind def
/skipsbw % charstring sbwprefix -> sizethroughsbw
{ length 1 index length exch sub
2 copy get 12 eq { 2 } { 1 } ifelse add
} bind def
% Open the input files. We don't open the output file until
% we've done a minimal validity check on the input.
bdfname (r) file /bdfile exch def
/commentword ( ) def
% Read and process the properties. We only care about a few of them.
keyword (STARTPROPERTIES) eq
{ iarg
{ nextline
properties keyword known
{ FontInfo properties keyword get sarg readonly put
} if
} repeat
(ENDPROPERTIES) getline
nextline
} if
% Read the bitmap data. This reads the remainder of the file.
% We do this before processing the bitmaps so that we can compute
% the correct FontBBox first.
/chardata ccount dict def
ccount -1 1
{ (STARTCHAR) getline
/charname remarg def
(ENCODING) getline
/eindex iarg def
eindex dup 0 ge exch 255 le and
{ charname /charname StandardEncoding eindex get def
charname /.notdef eq eindex 0 gt and
{ /charname (A) eindex =string cvs concatstrings cvn def
}
if
(/) print charname =string cvs print (,) print print
}
{ (/) print charname print
}
ifelse
10 mod 1 eq { (\n) print flush } if
(SWIDTH) getline
/swx iarg pointsize mul 1000 div xres mul 72 div def
/swy iarg pointsize mul 1000 div xres mul 72 div def
(DWIDTH) getline % Ignore, use SWIDTH instead
(BBX) getline
/bbw iarg def /bbh iarg def /bbox iarg def /bboy iarg def
nextline
keyword (ATTRIBUTES) eq
{ nextline
} if
(BITMAP) checkline
(ENDCHAR) getline
(ENDFONT) getline
% The Type 1 font machinery really only works with a 1000 unit
% character coordinate system. Set this up here, by computing the factor
% to make the X entry in the FontMatrix come out at exactly 0.001.
/fontscale 1000 fbbh div yres mul xres div def
Font /FontBBox
[ fbbxo fontscale mul
fbbyo fontscale mul
fbbxe fontscale mul
fbbye fontscale mul
] cvx readonly put
Font /CharStrings charstrings readonly put
FontInfo /FullName known not
{ % Some programs insist on FullName being present.
FontInfo /FullName FontName dup length string cvs put
}
if
FontInfo /isFixedPitch isfixedwidth put
subrcount 0 gt
{ Private /Subrs subrs 0 subrcount getinterval readonly put
} if
} bind def
end % envBDF
% If the program was invoked from the command line, run it now.
[ shellarguments
{ counttomark 4 ge
{ dup 0 get
dup 48 ge exch 57 le and % last arg starts with a digit?
{ /StandardEncoding } % no encodingname
{ cvn } % have encodingname
ifelse
exch (.) search % next-to-last arg has . in it?
{ mark 4 1 roll % have xuid
{ cvi exch pop exch (.) search not { exit } if }
loop cvi ]
3 -1 roll cvi exch
}
{ cvi null % no xuid
}
ifelse
counttomark 5 roll
counttomark 6 sub array astore
7 -2 roll cvn 7 -3 roll % make sure fontname is a name
bdfafmtops
}
{ cleartomark
(Usage:\n bdftops xx.bdf [yy1.afm ...] zz.gsf fontname uniqueID [xuid]
[encodingname]\n) print flush
mark
}
ifelse
}
if pop