2 |
- |
1 |
% Copyright (C) 2000 artofcode LLC. 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_cidtt.ps,v 1.9 2005/04/29 16:58:04 ray Exp $
|
|
|
17 |
% Redefine CIDFont category with an emulation with True Type fonts.
|
|
|
18 |
|
|
|
19 |
languagelevel 2 .setlanguagelevel
|
|
|
20 |
|
|
|
21 |
15 dict begin % a temporary dictionary for local binding.
|
|
|
22 |
|
|
|
23 |
%------------------Copy the FontEmulationProcs here : -------------------
|
|
|
24 |
|
|
|
25 |
/FontEmulationProcs /ProcSet findresource {
|
|
|
26 |
def
|
|
|
27 |
} forall
|
|
|
28 |
|
|
|
29 |
currentdict /super.complete_instance currentdict /complete_instance get put
|
|
|
30 |
|
|
|
31 |
%-------Auxiliary procedures for building CIDFontType 2 from TT file -----------
|
|
|
32 |
|
|
|
33 |
/GenerateCIDMap % <font> GenerateCIDMap <font>
|
|
|
34 |
{ begin
|
|
|
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 :
|
|
|
39 |
/CIDMap [
|
|
|
40 |
CIDCount 22000 le {
|
|
|
41 |
CIDCount 2 mul string
|
|
|
42 |
} {
|
|
|
43 |
44000 string
|
|
|
44 |
CIDCount 44000 gt {
|
|
|
45 |
% need three strings
|
|
|
46 |
44000 string % 22000 2 mul string
|
|
|
47 |
CIDCount 44000 sub 2 mul string
|
|
|
48 |
} {
|
|
|
49 |
CIDCount 22000 sub 2 mul string
|
|
|
50 |
} ifelse
|
|
|
51 |
} ifelse
|
|
|
52 |
] def
|
|
|
53 |
% Now fill it :
|
|
|
54 |
Decoding TT_cmap SubstNWP GDBytes CIDMap .fillCIDMap
|
|
|
55 |
currentdict end
|
|
|
56 |
} bind def
|
|
|
57 |
|
|
|
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)
|
|
|
62 |
QUIET not {
|
|
|
63 |
(Loading a TT font from ) print dup print
|
|
|
64 |
( to emulate a CID font ) print 1 index /CIDFontName get =only ( ... ) print
|
|
|
65 |
} if
|
|
|
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>
|
|
|
70 |
QUIET not {
|
|
|
71 |
(Done.) =
|
|
|
72 |
} if
|
|
|
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>
|
|
|
80 |
} bind def
|
|
|
81 |
|
|
|
82 |
%-----------TrueType-specific methods for category redefinition : -----------
|
|
|
83 |
|
|
|
84 |
/RefinePath % <FontDict> RefinePath <FontDict>
|
|
|
85 |
{ dup begin
|
|
|
86 |
Path .libfile {
|
|
|
87 |
dup .filename {
|
|
|
88 |
currentdict exch /Path exch put
|
|
|
89 |
} if
|
|
|
90 |
closefile
|
|
|
91 |
} {
|
|
|
92 |
(Can't find the font file ) print =
|
|
|
93 |
/findfont cvx /undefinedfilename signalerror
|
|
|
94 |
} ifelse
|
|
|
95 |
end
|
|
|
96 |
} bind def
|
|
|
97 |
|
|
|
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
|
|
|
101 |
//RefinePath exec
|
|
|
102 |
//load_sfnts exec
|
|
|
103 |
} bind def
|
|
|
104 |
|
|
|
105 |
/IsMyRecord % <raw_record> -> <raw_record> bool
|
|
|
106 |
{ dup type /dicttype eq { dup /FileType .knownget { /TrueType eq } { false } ifelse } { false } ifelse
|
|
|
107 |
} bind def
|
|
|
108 |
|
|
|
109 |
/IsActive % <record> IsActive <bool>
|
|
|
110 |
{ pop true
|
|
|
111 |
} bind def
|
|
|
112 |
|
|
|
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
|
|
|
119 |
} bind def
|
|
|
120 |
currentdict end def
|
|
|
121 |
|
|
|
122 |
% Redefine the /CIDFont category :
|
|
|
123 |
4 dict begin
|
|
|
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
|
|
|
130 |
true
|
|
|
131 |
} if
|
|
|
132 |
} bind def
|
|
|
133 |
currentdict end
|
|
|
134 |
|
|
|
135 |
/MappedCategoryRedefiner /ProcSet findresource /Redefine get exec
|
|
|
136 |
|
|
|
137 |
end % the temporary dictionary for local binding.
|
|
|
138 |
|
|
|
139 |
.setlanguagelevel
|