Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
%    Copyright (C) 1994, 2000 Aladdin Enterprises.  All rights reserved.
2
% 
3
% This software is provided AS-IS with no warranty, either express or
4
% implied.
5
% 
6
% This software is distributed under license and may not be copied,
7
% modified or distributed except as expressly authorized under the terms
8
% of the license contained in the file LICENSE in this distribution.
9
% 
10
% For more information about licensing, please refer to
11
% http://www.ghostscript.com/licensing/. For information on
12
% commercial licensing, go to http://www.artifex.com/licensing/ or
13
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
% San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
 
16
% $Id: gs_type1.ps,v 1.16 2004/12/15 23:21:33 igor Exp $
17
% Type 1 font support code.
18
 
19
% The standard representation for PostScript compatible fonts is described
20
% in the book "Adobe Type 1 Font Format", published by Adobe Systems Inc.
21
 
22
% Define an augmented version of .buildfont1 that inserts UnderlinePosition
23
% and UnderlineThickness entries in FontInfo if they aren't there already,
24
% and FontBBox isn't degenerate.
25
% (This works around the incorrect assumption, made by many word processors,
26
% that these entries are present in the built-in fonts.)
27
/.buildfont1
28
 {
29
   dup .fontbbox {
30
     pop pop pop pop
31
     dup /FontInfo known not
32
      { .growfontdict dup /FontInfo 2 dict put }
33
     if
34
     dup dup /FontInfo get dup dup
35
     /UnderlinePosition known exch /UnderlineThickness known and
36
      { pop pop		% entries already present
37
      }
38
      { dup length 2 add dict .copydict
39
        dup /UnderlinePosition known not
40
         { dup /UnderlinePosition 3 index /FontBBox get
41
           1 get 2 div put 			% 1/2 the font descent
42
         }
43
        if
44
        dup /UnderlineThickness known not
45
         { dup /UnderlineThickness 3 index /FontBBox get
46
           dup 3 get exch 1 get sub 20 div put 	% 1/20 the font height
47
         }
48
        if
49
        1 index /FontInfo get wcheck not { readonly } if
50
        /FontInfo exch put
51
      }
52
     ifelse
53
   } if
54
   //.buildfont1
55
 } bind def
56
% If the diskfont feature isn't included, define a dummy .loadfontdict.
57
/.loadfontdict where
58
 { pop }
59
 { /.loadfontdict 0 dict readonly def }
60
ifelse
61
/.loadfontfile		% <file> .loadfontfile -
62
 { mark exch
63
   DISKFONTS { .loadfontdict begin } if
64
	% In order to load fonts reliably, we should push systemdict
65
	% here.  However, Ed Taft says that Adobe implementations
66
	% push userdict and nothing else!
67
	% We really would just like systemdict on the stack,
68
	% but fonts produced by Fontographer require a writable dictionary.
69
	% However, we can't use any of the other well-known dictionaries
70
	% (such as userdict), since the whole point of pushing systemdict
71
	% is to make sure that nothing important has been redefined.
72
   userdict begin
73
	% We can't just use `run', because we want to check for .PFB files.
74
   currentpacking
75
    { false setpacking .loadfont1 true setpacking }
76
    { .loadfont1 }
77
   ifelse end
78
    { stop } if
79
   DISKFONTS { end } if
80
   cleartomark
81
 } bind def
82
 % container for CloseSource flag (default true to prevent buildup of file handles)
83
 /closesourcedict mark
84
   /CloseSource true
85
 .dicttomark readonly def
86
/.loadfont1 {		% <file> .loadfont1 <errorflag>
87
  {	% We would like to use `false /PFBDecode filter',
88
	% but this occasionally produces a whitespace character as
89
	% the first of an eexec section, so we can't do it.
90
	% Also, since the real input file never reaches EOF if we are using
91
	% a PFBDecode filter (the filter stops just after reading the last
92
	% character), we must explicitly close the real file in this case.
93
	% Since the file might leave garbage on the operand stack,
94
	% we have to create a procedure to close the file reliably.
95
    dup read not { -1 } if
96
    2 copy unread 16#80 eq {
97
	dup //closesourcedict //true /PFBDecode filter cvx
98
	exch .currentresourcefile eq {
99
	  dup /.execasresource .systemvar
100
	} {
101
	  {exec}
102
	} ifelse
103
	2 index cvlit
104
	/closefile .systemvar 3 .execn
105
      } {
106
	cvx exec
107
    } ifelse
108
  } stopped
109
} bind def
110
% undefine a dict that is only used internally, and is immediately bound
111
currentdict /closesourcedict .undef
112
 
113
% Here are the BuildChar and BuildGlyph implementation for Type 1 fonts.
114
% The names %Type1BuildChar and %Type1BuildGlyph are known to the interpreter.
115
% The real work is done in an operator:
116
%	<font> <code|name> <name> <charstring> .type1execchar -
117
 
118
(%Type1BuildChar)  cvn {	% <font> <code> %Type1BuildChar -
119
  1 index /Encoding get 1 index get .type1build .type1execchar
120
} bind def
121
(%Type1BuildGlyph) cvn {	% <font> <name> %Type1BuildGlyph -
122
  dup .type1build .type1execchar
123
} bind def
124
% Note: this procedure is used for both Type 1 and Type 2 fonts.
125
/.type1build {		% <font> <code|name> <name> .type1build
126
			%   <font> <code|name> <name> <charstring>
127
  2 index begin
128
    dup CharStrings exch .knownget not {
129
      2 copy eq { exch pop /.notdef exch } if
130
       QUIET not
131
	{ (Substituting .notdef for ) print
132
	  =string cvs print ( in the font ) print
133
	  1 index /FontName get = flush
134
	}
135
	{ pop }
136
       ifelse
137
       /.notdef CharStrings /.notdef get
138
    } if
139
  end
140
} bind def
141
 
142
1183615869 internaldict begin
143
% CCRun is an undocumented procedure provided for Type 4 and Type 0 fonts.
144
% Apparently there are two different argument lists for CCRun.
145
% Handling the one with the extra Private dictionary requires fabricating
146
% a Type 1 font on the fly, since we aren't currently prepared to parse the
147
% dictionary any other way.
148
/CCRun {	% <font> <code|name> <charstring> CCRun -
149
		% <font> <code|name> <charstring> <Private> CCRun -
150
  dup type /dicttype eq {
151
    dup 4 index /Private .knownget { ne } { pop true } ifelse {
152
		% The Private dictionary was supplied, and is different
153
		% from the Private dictionary of the font.  Fabricate a
154
		% Type 1 font with this Private dictionary.  Most of the
155
		% font entries are arbitrary or not needed.
156
      .currentglobal false .setglobal 10 dict exch .setglobal begin
157
	/Private exch def
158
	/FontType 1 def
159
	/FontMatrix 3 index /FontMatrix get def
160
	/Encoding 3 index /Encoding .knownget not { StandardEncoding } if def
161
	/FontBBox 3 index /FontBBox .knownget not { {0 0 0 0} } if def
162
	/PaintType 0 def
163
	/CharStrings 1 dict dup /.notdef () put def
164
      3 -1 roll pop () currentdict end .buildfont1 exch pop 3 1 roll
165
    } {
166
      pop
167
    } ifelse
168
  } if
169
  1 index dup type /integertype eq {
170
    3 index /Encoding get exch get
171
  } if exch .type1execchar
172
} bind def
173
 
174
% setweightvector is an undocumented procedure that force writes
175
% weight vector to the font. Do extra checks for safety.
176
/setweightvector { % <font> <vector> setweightvector -
177
  dup type dup /arraytype ne exch /packedarraytype ne and
178
  2 index type /dicttype ne or {
179
    /setweightvector cvx /typecheck signalerror
180
  } if
181
  1 index /FontType known not {
182
    /setweightvector cvx /invalidfont signalerror
183
  } if
184
  dup gcheck 2 index gcheck not and {
185
    /setweightvector cvx /invalidaccess signalerror
186
  } if
187
  2 copy /WeightVector exch .forceput
188
  .setweightvector
189
} .bind executeonly def 
190
end
191
 
192
% Register the font types for definefont.
193
buildfontdict 1 /.buildfont1 cvx put
194
buildfontdict 4 /.buildfont4 cvx put
195
 
196
% Add Type 2 support if applicable.
197
/.buildfont2 where not { (%END2) .skipeof } if
198
pop
199
(%Type2BuildChar)  cvn {	% <font> <code> %Type2BuildChar -
200
  1 index /Encoding get 1 index get .type1build .type2execchar
201
} bind def
202
(%Type2BuildGlyph) cvn {	% <font> <name> %Type2BuildGlyph -
203
  dup .type1build .type2execchar
204
} bind def
205
buildfontdict 2 /.buildfont2 cvx put
206
%END2