1 % Copyright (C) 2000 artofcode LLC. 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_cidtt.ps,v 1.9 2005/04/29 16:58:04 ray Exp $
17 % Redefine CIDFont category with an emulation with True Type fonts.
19 languagelevel 2 .setlanguagelevel
21 15 dict begin % a temporary dictionary for local binding.
23 %------------------Copy the FontEmulationProcs here : -------------------
25 /FontEmulationProcs /ProcSet findresource {
29 currentdict /super.complete_instance currentdict /complete_instance get put
31 %-------Auxiliary procedures for building CIDFontType 2 from TT file -----------
33 /GenerateCIDMap % <font> GenerateCIDMap <font>
35 % Obtain the maximal CID :
36 % This implementation doesn't check whether glyphs really present.
37 Decoding /CIDCount get /CIDCount exch def
38 % Prepare the CIDMap structure :
46 44000 string % 22000 2 mul string
47 CIDCount 44000 sub 2 mul string
49 CIDCount 22000 sub 2 mul string
54 Decoding TT_cmap SubstNWP GDBytes CIDMap .fillCIDMap
58 /load_sfnts % <FontDict> load_sfnts <FontDict>
59 { % Read the True Type file from the path /Path, and buld /sfnts,
60 % skipping glyf and loca.
61 dup /Path get % <font> (path)
63 (Loading a TT font from ) print dup print
64 ( to emulate a CID font ) print 1 index /CIDFontName get =only ( ... ) print
66 (r) file dup % <font> file file
67 3 1 roll % file <font> file
68 1 index /SubfontID .knownget not { 0 } if % file <font> file SubfontID
69 .load_tt_font_stripped exch copy % file <font>
73 dup 3 1 roll % <font> file <font>
74 exch /File exch put % <font>
75 dup dup /CIDSystemInfo get /Ordering get (.) % <font> () ()
76 2 index /Decoding get =string cvs % <font> () () ()
77 concatstrings concatstrings cvn /Decoding exch put % <font>
78 //ChooseDecoding exec % <font>
79 //GenerateCIDMap exec % <font>
82 %-----------TrueType-specific methods for category redefinition : -----------
84 /RefinePath % <FontDict> RefinePath <FontDict>
88 currentdict exch /Path exch put
92 (Can't find the font file ) print =
93 /findfont cvx /undefinedfilename signalerror
98 /complete_instance % <font_name> <FontDict> <Options> complete_FAPI_Font <font_name> <FontDict>
99 { 1 index /CIDFontType 2 put % Other types are not emulated yet.
100 //super.complete_instance exec
105 /IsMyRecord % <raw_record> -> <raw_record> bool
106 { dup type /dicttype eq { dup /FileType .knownget { /TrueType eq } { false } ifelse } { false } ifelse
109 /IsActive % <record> IsActive <bool>
113 /CIDFontRecordVirtualMethods //RecordVirtualMethodsStub dup length 3 add dict copy begin
114 /GetCSI //TranslateCSI def
115 /IsActive //IsActive def
116 /MakeInstance % <Name> <record> MakeInstance <Name> <Instance> <size>
117 { //CIDFontOptions //complete_instance exec
118 2 copy //GetSize exec
122 % Redefine the /CIDFont category :
124 /CategoryName /CIDFont def
125 /IsMapFileOptional true def
126 /VerifyMap { pop } bind def
127 /PreprocessRecord % <map> <Name> <raw_record> PreprocessRecord <map> <Name> <record> <bool>
128 { //IsMyRecord exec dup {
129 pop dup /RecordVirtualMethods //CIDFontRecordVirtualMethods put
135 /MappedCategoryRedefiner /ProcSet findresource /Redefine get exec
137 end % the temporary dictionary for local binding.