Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / modules / freetype2 / src / type1 / t1driver.c
blob3ca21dc1783db0a320cddca235fcddfc7eed3789
1 /***************************************************************************/
2 /* */
3 /* t1driver.c */
4 /* */
5 /* Type 1 driver interface (body). */
6 /* */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007 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 /***************************************************************************/
19 #include <ft2build.h>
20 #include "t1driver.h"
21 #include "t1gload.h"
22 #include "t1load.h"
24 #include "t1errors.h"
26 #ifndef T1_CONFIG_OPTION_NO_AFM
27 #include "t1afm.h"
28 #endif
30 #include FT_INTERNAL_DEBUG_H
31 #include FT_INTERNAL_STREAM_H
33 #include FT_SERVICE_MULTIPLE_MASTERS_H
34 #include FT_SERVICE_GLYPH_DICT_H
35 #include FT_SERVICE_XFREE86_NAME_H
36 #include FT_SERVICE_POSTSCRIPT_NAME_H
37 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
38 #include FT_SERVICE_POSTSCRIPT_INFO_H
39 #include FT_SERVICE_KERNING_H
42 /*************************************************************************/
43 /* */
44 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
45 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
46 /* messages during execution. */
47 /* */
48 #undef FT_COMPONENT
49 #define FT_COMPONENT trace_t1driver
52 * GLYPH DICT SERVICE
56 static FT_Error
57 t1_get_glyph_name( T1_Face face,
58 FT_UInt glyph_index,
59 FT_Pointer buffer,
60 FT_UInt buffer_max )
62 FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
64 return T1_Err_Ok;
68 static FT_UInt
69 t1_get_name_index( T1_Face face,
70 FT_String* glyph_name )
72 FT_Int i;
73 FT_String* gname;
76 for ( i = 0; i < face->type1.num_glyphs; i++ )
78 gname = face->type1.glyph_names[i];
80 if ( !ft_strcmp( glyph_name, gname ) )
81 return (FT_UInt)i;
84 return 0;
87 static const FT_Service_GlyphDictRec t1_service_glyph_dict =
89 (FT_GlyphDict_GetNameFunc) t1_get_glyph_name,
90 (FT_GlyphDict_NameIndexFunc)t1_get_name_index
95 * POSTSCRIPT NAME SERVICE
99 static const char*
100 t1_get_ps_name( T1_Face face )
102 return (const char*) face->type1.font_name;
105 static const FT_Service_PsFontNameRec t1_service_ps_name =
107 (FT_PsName_GetFunc)t1_get_ps_name
112 * MULTIPLE MASTERS SERVICE
116 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
117 static const FT_Service_MultiMastersRec t1_service_multi_masters =
119 (FT_Get_MM_Func) T1_Get_Multi_Master,
120 (FT_Set_MM_Design_Func) T1_Set_MM_Design,
121 (FT_Set_MM_Blend_Func) T1_Set_MM_Blend,
122 (FT_Get_MM_Var_Func) T1_Get_MM_Var,
123 (FT_Set_Var_Design_Func)T1_Set_Var_Design
125 #endif
129 * POSTSCRIPT INFO SERVICE
133 static FT_Error
134 t1_ps_get_font_info( FT_Face face,
135 PS_FontInfoRec* afont_info )
137 *afont_info = ((T1_Face)face)->type1.font_info;
138 return 0;
142 static FT_Int
143 t1_ps_has_glyph_names( FT_Face face )
145 FT_UNUSED( face );
146 return 1;
150 static FT_Error
151 t1_ps_get_font_private( FT_Face face,
152 PS_PrivateRec* afont_private )
154 *afont_private = ((T1_Face)face)->type1.private_dict;
155 return 0;
159 static const FT_Service_PsInfoRec t1_service_ps_info =
161 (PS_GetFontInfoFunc) t1_ps_get_font_info,
162 (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names,
163 (PS_GetFontPrivateFunc)t1_ps_get_font_private,
166 #ifndef T1_CONFIG_OPTION_NO_AFM
167 static const FT_Service_KerningRec t1_service_kerning =
169 T1_Get_Track_Kerning,
171 #endif
174 * SERVICE LIST
178 static const FT_ServiceDescRec t1_services[] =
180 { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t1_service_ps_name },
181 { FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict },
182 { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TYPE_1 },
183 { FT_SERVICE_ID_POSTSCRIPT_INFO, &t1_service_ps_info },
185 #ifndef T1_CONFIG_OPTION_NO_AFM
186 { FT_SERVICE_ID_KERNING, &t1_service_kerning },
187 #endif
189 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
190 { FT_SERVICE_ID_MULTI_MASTERS, &t1_service_multi_masters },
191 #endif
192 { NULL, NULL }
196 static FT_Module_Interface
197 Get_Interface( FT_Driver driver,
198 const FT_String* t1_interface )
200 FT_UNUSED( driver );
202 return ft_service_list_lookup( t1_services, t1_interface );
206 #ifndef T1_CONFIG_OPTION_NO_AFM
208 /*************************************************************************/
209 /* */
210 /* <Function> */
211 /* Get_Kerning */
212 /* */
213 /* <Description> */
214 /* A driver method used to return the kerning vector between two */
215 /* glyphs of the same face. */
216 /* */
217 /* <Input> */
218 /* face :: A handle to the source face object. */
219 /* */
220 /* left_glyph :: The index of the left glyph in the kern pair. */
221 /* */
222 /* right_glyph :: The index of the right glyph in the kern pair. */
223 /* */
224 /* <Output> */
225 /* kerning :: The kerning vector. This is in font units for */
226 /* scalable formats, and in pixels for fixed-sizes */
227 /* formats. */
228 /* */
229 /* <Return> */
230 /* FreeType error code. 0 means success. */
231 /* */
232 /* <Note> */
233 /* Only horizontal layouts (left-to-right & right-to-left) are */
234 /* supported by this function. Other layouts, or more sophisticated */
235 /* kernings are out of scope of this method (the basic driver */
236 /* interface is meant to be simple). */
237 /* */
238 /* They can be implemented by format-specific interfaces. */
239 /* */
240 static FT_Error
241 Get_Kerning( T1_Face face,
242 FT_UInt left_glyph,
243 FT_UInt right_glyph,
244 FT_Vector* kerning )
246 kerning->x = 0;
247 kerning->y = 0;
249 if ( face->afm_data )
250 T1_Get_Kerning( (AFM_FontInfo)face->afm_data,
251 left_glyph,
252 right_glyph,
253 kerning );
255 return T1_Err_Ok;
259 #endif /* T1_CONFIG_OPTION_NO_AFM */
262 FT_CALLBACK_TABLE_DEF
263 const FT_Driver_ClassRec t1_driver_class =
266 FT_MODULE_FONT_DRIVER |
267 FT_MODULE_DRIVER_SCALABLE |
268 FT_MODULE_DRIVER_HAS_HINTER,
270 sizeof( FT_DriverRec ),
272 "type1",
273 0x10000L,
274 0x20000L,
276 0, /* format interface */
278 (FT_Module_Constructor)T1_Driver_Init,
279 (FT_Module_Destructor) T1_Driver_Done,
280 (FT_Module_Requester) Get_Interface,
283 sizeof( T1_FaceRec ),
284 sizeof( T1_SizeRec ),
285 sizeof( T1_GlyphSlotRec ),
287 (FT_Face_InitFunc) T1_Face_Init,
288 (FT_Face_DoneFunc) T1_Face_Done,
289 (FT_Size_InitFunc) T1_Size_Init,
290 (FT_Size_DoneFunc) T1_Size_Done,
291 (FT_Slot_InitFunc) T1_GlyphSlot_Init,
292 (FT_Slot_DoneFunc) T1_GlyphSlot_Done,
294 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
295 ft_stub_set_char_sizes,
296 ft_stub_set_pixel_sizes,
297 #endif
298 (FT_Slot_LoadFunc) T1_Load_Glyph,
300 #ifdef T1_CONFIG_OPTION_NO_AFM
301 (FT_Face_GetKerningFunc) 0,
302 (FT_Face_AttachFunc) 0,
303 #else
304 (FT_Face_GetKerningFunc) Get_Kerning,
305 (FT_Face_AttachFunc) T1_Read_Metrics,
306 #endif
307 (FT_Face_GetAdvancesFunc) 0,
308 (FT_Size_RequestFunc) T1_Size_Request,
309 (FT_Size_SelectFunc) 0
313 /* END */