1 /***************************************************************************/
5 /* CID driver interface (body). */
7 /* Copyright 1996-2001 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16 /***************************************************************************/
22 #include FT_INTERNAL_DEBUG_H
23 #include FT_INTERNAL_STREAM_H
24 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
28 #include <string.h> /* for strcmp() */
31 /*************************************************************************/
33 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
34 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
35 /* messages during execution. */
38 #define FT_COMPONENT trace_ciddriver
43 cid_get_postscript_name( CID_Face face )
45 return (const char*)face->cid.cid_font_name;
49 static FT_Module_Interface
50 CID_Get_Interface( FT_Driver driver,
51 const FT_String* interface )
54 FT_UNUSED( interface );
56 if ( strcmp( (const char*)interface, "postscript_name" ) == 0 )
57 return (FT_Module_Interface)cid_get_postscript_name;
63 #if 0 /* unimplemented yet */
66 cid_Get_Kerning( T1_Face face,
77 afm = (CID_AFM*)face->afm_data;
79 CID_Get_Kerning( afm, left_glyph, right_glyph, kerning );
88 /*************************************************************************/
91 /* Cid_Get_Char_Index */
94 /* Uses a charmap to return a given character code's glyph index. */
97 /* charmap :: A handle to the source charmap object. */
99 /* charcode :: The character code. */
102 /* Glyph index. 0 means `undefined character code'. */
105 CID_Get_Char_Index( FT_CharMap charmap,
110 PSNames_Interface* psnames;
113 face = (T1_Face)charmap->face;
114 psnames = (PSNames_Interface*)face->psnames;
116 switch ( charmap->encoding )
118 /*******************************************************************/
120 /* Unicode encoding support */
122 case ft_encoding_unicode:
123 /* use the `PSNames' module to synthetize the Unicode charmap */
124 result = psnames->lookup_unicode( &face->unicode_map,
125 (FT_ULong)charcode );
127 /* the function returns 0xFFFF if the Unicode charcode has */
128 /* no corresponding glyph. */
129 if ( result == 0xFFFF )
133 /*******************************************************************/
135 /* Custom Type 1 encoding */
137 case ft_encoding_adobe_custom:
139 T1_Encoding* encoding = &face->type1.encoding;
142 if ( charcode >= encoding->code_first &&
143 charcode <= encoding->code_last )
144 result = encoding->char_index[charcode];
148 /*******************************************************************/
150 /* Adobe Standard & Expert encoding support */
153 if ( charcode < 256 )
157 const char* glyph_name;
160 code = psnames->adobe_std_encoding[charcode];
161 if ( charmap->encoding == ft_encoding_adobe_expert )
162 code = psnames->adobe_expert_encoding[charcode];
164 glyph_name = psnames->adobe_std_strings( code );
168 for ( n = 0; n < face->type1.num_glyphs; n++ )
170 const char* gname = face->type1.glyph_names[n];
173 if ( gname && gname[0] == glyph_name[0] &&
174 strcmp( gname, glyph_name ) == 0 )
189 FT_CALLBACK_TABLE_DEF
190 const FT_Driver_Class t1cid_driver_class =
192 /* first of all, the FT_Module_Class fields */
194 ft_module_font_driver | ft_module_driver_scalable,
195 sizeof( FT_DriverRec ),
196 "t1cid", /* module name */
197 0x10000L, /* version 1.0 of driver */
198 0x20000L, /* requires FreeType 2.0 */
202 (FT_Module_Constructor)CID_Init_Driver,
203 (FT_Module_Destructor) CID_Done_Driver,
204 (FT_Module_Requester) CID_Get_Interface
207 /* then the other font drivers fields */
208 sizeof( CID_FaceRec ),
209 sizeof( CID_SizeRec ),
210 sizeof( CID_GlyphSlotRec ),
212 (FTDriver_initFace) CID_Init_Face,
213 (FTDriver_doneFace) CID_Done_Face,
215 (FTDriver_initSize) 0,
216 (FTDriver_doneSize) 0,
217 (FTDriver_initGlyphSlot)0,
218 (FTDriver_doneGlyphSlot)0,
220 (FTDriver_setCharSizes) 0,
221 (FTDriver_setPixelSizes)0,
223 (FTDriver_loadGlyph) CID_Load_Glyph,
224 (FTDriver_getCharIndex) CID_Get_Char_Index,
226 (FTDriver_getKerning) 0,
227 (FTDriver_attachFile) 0,
229 (FTDriver_getAdvances) 0
233 #ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
236 /*************************************************************************/
242 /* This function is used when compiling the TrueType driver as a */
243 /* shared library (`.DLL' or `.so'). It will be used by the */
244 /* high-level library of FreeType to retrieve the address of the */
245 /* driver's generic interface. */
247 /* It shouldn't be implemented in a static build, as each driver must */
248 /* have the same function as an exported entry point. */
251 /* The address of the TrueType's driver generic interface. The */
252 /* format-specific interface can then be retrieved through the method */
253 /* interface->get_format_interface. */
255 FT_EXPORT_DEF( const FT_Driver_Class* )
256 getDriverClass( void )
258 return &t1cid_driver_class;
262 #endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */