]> git.saurik.com Git - wxWidgets.git/blob - src/freetype/cid/cidriver.c
Removed 'interface' pragma for gcc 2.96
[wxWidgets.git] / src / freetype / cid / cidriver.c
1 /***************************************************************************/
2 /* */
3 /* cidriver.c */
4 /* */
5 /* CID driver interface (body). */
6 /* */
7 /* Copyright 1996-2000 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
15 /* */
16 /***************************************************************************/
17
18
19 #ifdef FT_FLAT_COMPILE
20
21 #include "cidriver.h"
22 #include "cidgload.h"
23
24 #else
25
26 #include <cid/cidriver.h>
27 #include <cid/cidgload.h>
28
29 #endif
30
31
32 #include <freetype/internal/ftdebug.h>
33 #include <freetype/internal/ftstream.h>
34 #include <freetype/internal/psnames.h>
35
36 #include <string.h> /* for strcmp() */
37
38
39 /*************************************************************************/
40 /* */
41 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
42 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
43 /* messages during execution. */
44 /* */
45 #undef FT_COMPONENT
46 #define FT_COMPONENT trace_ciddriver
47
48
49 static
50 FT_Module_Interface CID_Get_Interface( FT_Driver driver,
51 const FT_String* interface )
52 {
53 FT_UNUSED( driver );
54 FT_UNUSED( interface );
55
56 return 0;
57 }
58
59
60 #if 0 /* unimplemented yet */
61
62 static
63 FT_Error cid_Get_Kerning( T1_Face face,
64 FT_UInt left_glyph,
65 FT_UInt right_glyph,
66 FT_Vector* kerning )
67 {
68 CID_AFM* afm;
69
70
71 kerning->x = 0;
72 kerning->y = 0;
73
74 afm = (CID_AFM*)face->afm_data;
75 if ( afm )
76 CID_Get_Kerning( afm, left_glyph, right_glyph, kerning );
77
78 return T1_Err_Ok;
79 }
80
81
82 #endif /* 0 */
83
84
85 /*************************************************************************/
86 /* */
87 /* <Function> */
88 /* Cid_Get_Char_Index */
89 /* */
90 /* <Description> */
91 /* Uses a charmap to return a given character code's glyph index. */
92 /* */
93 /* <Input> */
94 /* charmap :: A handle to the source charmap object. */
95 /* */
96 /* charcode :: The character code. */
97 /* */
98 /* <Return> */
99 /* Glyph index. 0 means `undefined character code'. */
100 /* */
101 static
102 FT_UInt CID_Get_Char_Index( FT_CharMap charmap,
103 FT_Long charcode )
104 {
105 T1_Face face;
106 FT_UInt result = 0;
107 PSNames_Interface* psnames;
108
109
110 face = (T1_Face)charmap->face;
111 psnames = (PSNames_Interface*)face->psnames;
112 if ( psnames )
113 switch ( charmap->encoding )
114 {
115 /*******************************************************************/
116 /* */
117 /* Unicode encoding support */
118 /* */
119 case ft_encoding_unicode:
120 /* use the `PSNames' module to synthetize the Unicode charmap */
121 result = psnames->lookup_unicode( &face->unicode_map,
122 (FT_ULong)charcode );
123
124 /* the function returns 0xFFFF if the Unicode charcode has */
125 /* no corresponding glyph. */
126 if ( result == 0xFFFF )
127 result = 0;
128 goto Exit;
129
130 /*******************************************************************/
131 /* */
132 /* Custom Type 1 encoding */
133 /* */
134 case ft_encoding_adobe_custom:
135 {
136 T1_Encoding* encoding = &face->type1.encoding;
137
138
139 if ( charcode >= encoding->code_first &&
140 charcode <= encoding->code_last )
141 result = encoding->char_index[charcode];
142 goto Exit;
143 }
144
145 /*******************************************************************/
146 /* */
147 /* Adobe Standard & Expert encoding support */
148 /* */
149 default:
150 if ( charcode < 256 )
151 {
152 FT_UInt code;
153 FT_Int n;
154 const char* glyph_name;
155
156
157 code = psnames->adobe_std_encoding[charcode];
158 if ( charmap->encoding == ft_encoding_adobe_expert )
159 code = psnames->adobe_expert_encoding[charcode];
160
161 glyph_name = psnames->adobe_std_strings( code );
162 if ( !glyph_name )
163 break;
164
165 for ( n = 0; n < face->type1.num_glyphs; n++ )
166 {
167 const char* gname = face->type1.glyph_names[n];
168
169
170 if ( gname && gname[0] == glyph_name[0] &&
171 strcmp( gname, glyph_name ) == 0 )
172 {
173 result = n;
174 break;
175 }
176 }
177 }
178 }
179
180 Exit:
181 return result;
182 }
183
184
185 const FT_Driver_Class t1cid_driver_class =
186 {
187 /* first of all, the FT_Module_Class fields */
188 {
189 ft_module_font_driver | ft_module_driver_scalable,
190 sizeof( FT_DriverRec ),
191 "t1cid", /* module name */
192 0x10000L, /* version 1.0 of driver */
193 0x20000L, /* requires FreeType 2.0 */
194
195 0,
196
197 (FT_Module_Constructor)CID_Init_Driver,
198 (FT_Module_Destructor) CID_Done_Driver,
199 (FT_Module_Requester) CID_Get_Interface
200 },
201
202 /* then the other font drivers fields */
203 sizeof( CID_FaceRec ),
204 sizeof( CID_SizeRec ),
205 sizeof( CID_GlyphSlotRec ),
206
207 (FTDriver_initFace) CID_Init_Face,
208 (FTDriver_doneFace) CID_Done_Face,
209
210 (FTDriver_initSize) 0,
211 (FTDriver_doneSize) 0,
212 (FTDriver_initGlyphSlot)0,
213 (FTDriver_doneGlyphSlot)0,
214
215 (FTDriver_setCharSizes) 0,
216 (FTDriver_setPixelSizes)0,
217
218 (FTDriver_loadGlyph) CID_Load_Glyph,
219 (FTDriver_getCharIndex) CID_Get_Char_Index,
220
221 (FTDriver_getKerning) 0,
222 (FTDriver_attachFile) 0,
223
224 (FTDriver_getAdvances) 0
225 };
226
227
228 #ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
229
230
231 /*************************************************************************/
232 /* */
233 /* <Function> */
234 /* getDriverClass */
235 /* */
236 /* <Description> */
237 /* This function is used when compiling the TrueType driver as a */
238 /* shared library (`.DLL' or `.so'). It will be used by the */
239 /* high-level library of FreeType to retrieve the address of the */
240 /* driver's generic interface. */
241 /* */
242 /* It shouldn't be implemented in a static build, as each driver must */
243 /* have the same function as an exported entry point. */
244 /* */
245 /* <Return> */
246 /* The address of the TrueType's driver generic interface. The */
247 /* format-specific interface can then be retrieved through the method */
248 /* interface->get_format_interface. */
249 /* */
250 EXPORT_FUNC( FT_Driver_Class* ) getDriverClass( void )
251 {
252 return &t1cid_driver_class;
253 }
254
255
256 #endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
257
258
259 /* END */