home *** CD-ROM | disk | FTP | other *** search
- % Copyright (C) 1990, 1991 Aladdin Enterprises. All rights reserved.
- % Distributed by Free Software Foundation, Inc.
- %
- % This file is part of Ghostscript.
- %
- % Ghostscript is distributed in the hope that it will be useful, but
- % WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
- % to anyone for the consequences of using it or for whether it serves any
- % particular purpose or works at all, unless he says so in writing. Refer
- % to the Ghostscript General Public License for full details.
- %
- % Everyone is granted permission to copy, modify and redistribute
- % Ghostscript, but only under the conditions described in the Ghostscript
- % General Public License. A copy of this license is supposed to have been
- % given to you along with Ghostscript so you can know your rights and
- % responsibilities. It should be in a file named COPYING. Among other
- % things, the copyright notice and this notice must be preserved on all
- % copies.
-
- % Font initialization for Ghostscript. Despite anything claimed below,
- % Ghostscript fonts are actually in the same format as Adobe Type 1 fonts,
- % except that the external form customarily does not use eexec encryption.
- % Someday there will be GNU documentation that describes this format.
- % Until then, you'll have to either get a copy of Adobe's book, or read
- % the Ghostscript code. The interpreter for Type 1 fonts, which reveals
- % most of their structure, is in the file gstype1.c.
-
-
- % Define the default font.
- /defaultfontname /Ugly def
-
-
- % Internal procedure to load the font name -> font file name map
- % if it isn't loaded already, and push it on the stack.
- /Fontmap
- { /FontFileMap where
- { /FontFileMap get }
- { (Fontmap) findlibfile not
- { (Can't find ) print print (!\n) print stop }
- if
-
- FontDirectory maxlength dict exch
- 2 dict begin
- mark exch 2 index exch
- /;
- { % The stack contains a mark, the dictionary, the font name,
- % the file name, and additional information about the font.
- counttomark 3 sub { pop } repeat put
- 1 index
- } bind def
- run
- end
- pop pop % pop the mark and the copy of the dictionary
- userdict exch /FontFileMap exch put
- FontFileMap
- }
- ifelse
- } bind def
-
-
- % Define definefont. This is a procedure built on an operator that
- % does all the error checking and key insertion.
- /definefont
- { 1 dict begin count /d exch def % save stack depth in case of error
- { .buildfont readonly } stopped
- { count d sub { pop } repeat end /invalidfont signalerror }
- { end dup FontDirectory 4 2 roll put }
- ifelse
- } odef
-
-
- % Define findfont so it tries to load a font if it's not found.
- /findfont
- {
- % If the key is a string, convert it to a name for lookup.
- dup type /stringtype eq { cvn } if
-
- % If the font isn't in FontDirectory already, load it.
- dup FontDirectory exch known
- { FontDirectory exch get
- }
- { dup % save the font name on the stack
-
- % Push the font name -> font file name map on the stack,
- % loading it if necessary.
- Fontmap
-
- % Read the file name from the map.
- % (The stack contains the font name and the font file map.)
- 1 index known not
- { QUIET not
- { (Substituting ) print defaultfontname cvx =only
- ( for unknown font ) print == flush
- } { pop } ifelse
- pop defaultfontname findfont
- }
- { FontFileMap exch get
-
- % If we can't find the file, substitute for the font.
- dup findlibfile
- { QUIET not
- { (Loading font file ) print exch print (... ) print flush }
- { exch pop }
- ifelse
- mark exch
- systemdict begin run end % run can take a file
- cleartomark
- QUIET not
- { vmstatus 3 { =only ( ) print } repeat
- (done.\n) print flush
- } if
- findfont
- }
- { pop 1 index defaultfontname eq
- { (Can't find default font!\n) print
- pop pop NullFont
- }
- { (Can't find font file ) print print
- (, substituting ) print defaultfontname cvx =only
- (.\n) print flush
- pop defaultfontname findfont
- }
- ifelse
- }
- ifelse
- }
- ifelse
-
- } ifelse
-
- } bind def
-
-
- % The CharStrings for a Ghostscript font are a dictionary in which
- % the key is the character name, and the value is a compressed
- % representation of a path, as produced by type1imagepath.
- % For detailed information, see the book
- % "Adobe Type 1 Font Format", published by Adobe Systems Inc.
-
- % Here is the BuildChar implementation
- % for Type 1 (Ghostscript standard) fonts.
- % The name Type1BuildChar is known to the interpreter.
-
- /Type1BuildChar
- { exch begin
- Encoding exch get
- dup CharStrings exch known not
- { QUIET not
- { (Substituting .notdef for ) print = flush
- } { pop } ifelse
- /.notdef
- } if
- CharStrings exch get
- PaintType 0 ne
- { 1 setmiterlimit 1 setlinejoin 1 setlinecap
- currentdict /StrokeWidth known { StrokeWidth } { 0 } ifelse
- setlinewidth }
- if
- type1addpath % does a fill or stroke
- end
- } bind def
-