1
% Copyright (C) 2000 Artifex Software, Inc. All rights reserved.
3
% This software is provided AS-IS with no warranty, either express or
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.
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.
16
% $Id: gs_fntem.ps 8274 2007-10-09 00:06:24Z leonardo $
17
% A procset for Postscript font emulation
19
% The procedures must not depend on the presence of the
20
% procset dictionary on the dictionary stack.
22
languagelevel 2 .setlanguagelevel
24
%========================= Process xlatmap ====================
26
%% Replace 1 (xlatmap)
28
.dicttomark dup systemdict exch /.xlatmap_dict exch put
30
% Convert it into a plain text to simplify the processing in C :
31
% *(fontkind\0\0\ *(charmap\0decoding\0) ) \0
34
3 1 roll =string cvs concatstrings (\0\0) concatstrings
36
{ =string cvs concatstrings (\0) concatstrings
40
systemdict exch /.xlatmap exch put
42
/FontEmulationProcs 10 dict begin
44
%-------------------------------Font--------------------------------
47
/FontCommon % - font_common -
48
{ currentdict /PaintType known not {
51
currentdict /Encoding .knownget not {
54
dup type /nametype eq {
55
/Encoding findresource
60
/FontOptions 5 dict begin
61
/make_procs currentdict def
62
/NameKey /FontName def
63
/TypeKey /FontType def
66
{ /FontMatrix [0.001 0 0 0.001 0 0] def
67
/FontBBox [-128 -128 1024 1024] def % zfapi.ps refines it.
69
/CharStrings << /.notdef () >> def
74
{ /FontMatrix [1 0 0 1 0 0] def
75
/FontBBox [0 0 1 1] def % zfapi.ps refines it.
77
/sfnts [<00010000 0000 0000 0000 0000 0000>] def
78
/GlyphDirectory [] def
82
%fixme : more font types.
86
%---------------------------CIDFont---------------------------
88
/TranslateCSI % <record> TranslateCSI <CSI>
89
{ RESMPDEBUG { (fntem TranslateCSI beg ) = } if
93
/Ordering CSI aload pop
97
<< /Registry CSI 0 get
103
RESMPDEBUG { (fntem TranslateCSI end ) = } if
107
{ /CIDSystemInfo currentdict //TranslateCSI exec def
108
currentdict /CSI undef
109
/FontBBox [-128 -128 1024 1024] def % zfapi.ps refines it.
110
/CIDCount 1 def % ChooseDecoding will set a reasonable value.
113
% GFlyph substitution table for narrow, wide, proportional glyphs -
114
% used with TrueTypes.
116
currentpacking false setpacking
119
% Array format : orig_type, beg_CID, end_CID, subst_beg_CID, subst_type
120
% type = (n==narrow, w==wide, p==proportional).
128
w 842 842 7918 w % fixme: These substitutions require to shift the glyph origin.
185
/CIDFontOptions 5 dict begin
186
/make_procs currentdict def
187
/NameKey /CIDFontName def
188
/TypeKey /CIDFontType def
191
{ //CIDFontCommon exec
194
/FontName CIDFontName =string cvs (%) concatstrings cvn def
196
/FontMatrix [0.001 0 0 0.001 0 0 ] def
202
/GlyphDirectory [] def
208
{ //CIDFontCommon exec
209
/FontMatrix [1 0 0 1 0 0] def
214
{ //CIDFontCommon exec
215
/FontMatrix [1 0 0 1 0 0] def
218
/sfnts [<00010000 0000 0000 0000 0000 0000>] def
220
/CharStrings << /.notdef 0 >> def
225
/complete_instance % <font_name> <FontDict> <Options> complete_FAPI_Font <font_name> <FontDict>
229
dup type /nametype ne { cvn } if
231
currentglobal true setglobal
232
make_procs TypeKey load .knownget {
235
/complete_instance cvx /invalidfont signalerror
242
/GetFilePath % <scratch> <Name> <record> GetFilePath <filepath>
243
{ exch pop % (scratch) <record>
244
/Path get % (scratch) (path)
246
% What we make here it is not a complete PS resource.
247
% Unable to provide full conformity :
248
% the attempt to run this file may fail.
251
/GetSize % <Name> <record> GetSize <size>
252
{ pop pop -1 % Unknown size.
253
% fixme: probably we could provide an estimation size for some fonts.
256
/RecordVirtualMethodsStub 3 dict begin
257
/GetFilePath //GetFilePath def
258
/GetSize //GetSize def
261
% ---------------------- Decoding helpers ----------------------------
264
StandardEncoding /StandardEncoding
265
ISOLatin1Encoding /ISOLatin1Encoding
266
SymbolEncoding /SymbolEncoding
267
DingbatsEncoding /DingbatsEncoding
268
/resourceforall where {
270
EncodingDirectory exch .knownget not {
271
% A work around bug 688710 on Linux :
272
% findencoding can't load resource files until gs_init.ps executes .fixresources .
273
% It will happen after gs_init.ps runs INITFILES,
274
% from which the current file runs.
275
% Windows build has no such problem.
276
(.svn) anchorsearch {
277
% HACK : skip .svn or */* names, which are subdirectories.
283
cvn dup /Encoding findresource
290
} 1024 string /Encoding resourceforall
294
/ChooseDecoding % <font> ChooseDecoding <font>
295
{ { % A loop for 'exit' context.
296
dup /Decoding .knownget {
297
dup type /nametype eq {
298
1 index /CIDFontType known { /CIDDecoding } { /Decoding } ifelse
299
findresource 1 index exch /Decoding exch put
303
dup /CIDFontType known {
304
dup dup /Decoding get /CIDCount get /CIDCount exch put
308
dup /CIDFontType known {
309
% This is a hooked CID font, no need for Decoding.
312
% This works when the renderer can't choose character by name,
313
% and we cannot determine the charset.
314
% Probably this branch is to be removed after UFST problem is fixed.
315
dup /Encoding get % <<font>> encoding
316
dup type /nametype eq {
317
/Decoding findresource 1 index exch /Decoding exch put
322
/Decoding findresource 1 index exch /Decoding exch put
324
% unknown encoding, convert it to decoding :
325
dup length dict begin
327
0 1 currentdict length 1 sub
328
{ dup 2 index exch get
337
1 index exch /Decoding exch put
342
dup /CIDFontType known {
343
dup /SubstNWP .knownget not {
344
dup /CIDSystemInfo get /Ordering get cvn
346
dup type /nametype eq {
347
//SubstNWP exch .knownget not {
349
} if % <<font>> [SubstNWP]
351
1 index exch /SubstNWP exch put
355
/PrintFontRef % <string|name> <font> PrintFontRef <string|name> <font>
356
{ dup /FontName known { (Font ) } { (CIDFont ) } ifelse print
357
1 index =string cvs print
358
dup /FontName .knownget not {
360
} if % <string|name> <font> <fontname>
362
( \( aliased from ) print
363
=string cvs print ( \)) print
369
/GetFontType % <font> GetFontType int
370
{ dup /CIDFontType .knownget {
377
/FindInArray % <array> <elem> .array_find <bool>
379
exch { % false elem elem_i
380
1 index eq { % false elem
387
/ProvideUnicodeDecoding % <font> ProvideUnicodeDecoding <font>
389
% If the font is maintained by FAPI, or if it is TT-emulated CID font,
390
% it already has /Decoding. But its value isn't guaranteeed to
391
% be an Unicode decoding. Since we can't determine whether
392
% it is an Unicode decoding, we unconditionally load an appropriate Unicode decoding
393
% and attach it with /GlyphNames2Unicode entry.
395
% Another interesting case is when the font already has /GlyphNames2Unicode.
396
% The latter to be used instead. Note that /GlyphNames2Unicode
397
% appears only when type 32 fonts are disable (see .pdf_hook_DSC_Creator),
398
% but an automatic disabling is not implemented yet.
400
currentglobal true setglobal exch
401
dup /FontInfo known not {
402
dup /FontInfo 1 dict put
404
{ % A loop just for 'exit' context.
405
dup /FontInfo get /GlyphNames2Unicode known {
408
dup /CIDFontType known {
409
dup mark exch % bool <font> [ <font>
410
dup /CIDSystemInfo get /Ordering get (.Unicode) % bool <font> [ <font> () ()
411
concatstrings cvn % bool <font> [ <font> /Name
412
/CIDDecoding { findresource } stopped {
413
% Can't provide a decoding, giving up without creating /GlyphNames2Unicode.
415
} if % bool <font> [ <font> <D>
416
exch /FontInfo get exch % bool <font> [ <FI> <D>
417
/GlyphNames2Unicode exch
418
.forceput % FontInfo can be read-only.
422
dup /FontInfo get % bool <font> <FI>
423
/GlyphNames2Unicode /Unicode /Decoding findresource
424
.forceput % FontInfo can be read-only.
430
currentdict end /ProcSet defineresource pop