1 /***************************************************************************/
5 /* CID driver interface (body). */
7 /* Copyright 1996-2000 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 /***************************************************************************/
19 #ifdef FT_FLAT_COMPILE
26 #include <cid/cidriver.h>
27 #include <cid/cidgload.h>
32 #include <freetype/internal/ftdebug.h>
33 #include <freetype/internal/ftstream.h>
34 #include <freetype/internal/psnames.h>
36 #include <string.h> /* for strcmp() */
39 /*************************************************************************/
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. */
46 #define FT_COMPONENT trace_ciddriver
50 FT_Module_Interface
CID_Get_Interface( FT_Driver driver
,
51 const FT_String
* interface
)
54 FT_UNUSED( interface
);
60 #if 0 /* unimplemented yet */
63 FT_Error
cid_Get_Kerning( T1_Face face
,
74 afm
= (CID_AFM
*)face
->afm_data
;
76 CID_Get_Kerning( afm
, left_glyph
, right_glyph
, kerning
);
85 /*************************************************************************/
88 /* Cid_Get_Char_Index */
91 /* Uses a charmap to return a given character code's glyph index. */
94 /* charmap :: A handle to the source charmap object. */
96 /* charcode :: The character code. */
99 /* Glyph index. 0 means `undefined character code'. */
102 FT_UInt
CID_Get_Char_Index( FT_CharMap charmap
,
107 PSNames_Interface
* psnames
;
110 face
= (T1_Face
)charmap
->face
;
111 psnames
= (PSNames_Interface
*)face
->psnames
;
113 switch ( charmap
->encoding
)
115 /*******************************************************************/
117 /* Unicode encoding support */
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
);
124 /* the function returns 0xFFFF if the Unicode charcode has */
125 /* no corresponding glyph. */
126 if ( result
== 0xFFFF )
130 /*******************************************************************/
132 /* Custom Type 1 encoding */
134 case ft_encoding_adobe_custom
:
136 T1_Encoding
* encoding
= &face
->type1
.encoding
;
139 if ( charcode
>= encoding
->code_first
&&
140 charcode
<= encoding
->code_last
)
141 result
= encoding
->char_index
[charcode
];
145 /*******************************************************************/
147 /* Adobe Standard & Expert encoding support */
150 if ( charcode
< 256 )
154 const char* glyph_name
;
157 code
= psnames
->adobe_std_encoding
[charcode
];
158 if ( charmap
->encoding
== ft_encoding_adobe_expert
)
159 code
= psnames
->adobe_expert_encoding
[charcode
];
161 glyph_name
= psnames
->adobe_std_strings( code
);
165 for ( n
= 0; n
< face
->type1
.num_glyphs
; n
++ )
167 const char* gname
= face
->type1
.glyph_names
[n
];
170 if ( gname
&& gname
[0] == glyph_name
[0] &&
171 strcmp( gname
, glyph_name
) == 0 )
185 const FT_Driver_Class t1cid_driver_class
=
187 /* first of all, the FT_Module_Class fields */
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 */
197 (FT_Module_Constructor
)CID_Init_Driver
,
198 (FT_Module_Destructor
) CID_Done_Driver
,
199 (FT_Module_Requester
) CID_Get_Interface
202 /* then the other font drivers fields */
203 sizeof( CID_FaceRec
),
204 sizeof( CID_SizeRec
),
205 sizeof( CID_GlyphSlotRec
),
207 (FTDriver_initFace
) CID_Init_Face
,
208 (FTDriver_doneFace
) CID_Done_Face
,
210 (FTDriver_initSize
) 0,
211 (FTDriver_doneSize
) 0,
212 (FTDriver_initGlyphSlot
)0,
213 (FTDriver_doneGlyphSlot
)0,
215 (FTDriver_setCharSizes
) 0,
216 (FTDriver_setPixelSizes
)0,
218 (FTDriver_loadGlyph
) CID_Load_Glyph
,
219 (FTDriver_getCharIndex
) CID_Get_Char_Index
,
221 (FTDriver_getKerning
) 0,
222 (FTDriver_attachFile
) 0,
224 (FTDriver_getAdvances
) 0
228 #ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
231 /*************************************************************************/
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. */
242 /* It shouldn't be implemented in a static build, as each driver must */
243 /* have the same function as an exported entry point. */
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. */
250 EXPORT_FUNC( FT_Driver_Class
* ) getDriverClass( void )
252 return &t1cid_driver_class
;
256 #endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */