blob: 30d9dcc8fe5bd5d29ee592ace7f4757b088f40a9 [file] [log] [blame]
Werner Lemberg8c90c222002-06-08 06:47:18 +00001/***************************************************************************/
2/* */
3/* t42objs.c */
4/* */
5/* Type 42 objects manager (body). */
6/* */
Werner Lembergf1c2b912006-01-13 14:53:28 +00007/* Copyright 2002, 2003, 2004, 2005, 2006 by Roberto Alameda. */
Werner Lemberg8c90c222002-06-08 06:47:18 +00008/* */
9/* This file is part of the FreeType project, and may only be used, */
10/* modified, and distributed under the terms of the FreeType project */
11/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
12/* this file you indicate that you have read the license and */
13/* understand and accept it fully. */
14/* */
15/***************************************************************************/
16
17
David Turner9f95bab2002-06-07 07:23:06 +000018#include "t42objs.h"
19#include "t42parse.h"
Werner Lemberg8c90c222002-06-08 06:47:18 +000020#include "t42error.h"
David Turner9f95bab2002-06-07 07:23:06 +000021#include FT_INTERNAL_DEBUG_H
22#include FT_INTERNAL_STREAM_H
23#include FT_LIST_H
24
Werner Lemberg8c90c222002-06-08 06:47:18 +000025
David Turner9f95bab2002-06-07 07:23:06 +000026#undef FT_COMPONENT
27#define FT_COMPONENT trace_t42
28
29
30 static FT_Error
31 T42_Open_Face( T42_Face face )
32 {
33 T42_LoaderRec loader;
34 T42_Parser parser;
35 T1_Font type1 = &face->type1;
36 FT_Memory memory = face->root.memory;
37 FT_Error error;
38
39 PSAux_Service psaux = (PSAux_Service)face->psaux;
40
41
42 t42_loader_init( &loader, face );
43
44 parser = &loader.parser;
45
46 if ( FT_ALLOC( face->ttf_data, 12 ) )
47 goto Exit;
48
49 error = t42_parser_init( parser,
50 face->root.stream,
51 memory,
52 psaux);
53 if ( error )
54 goto Exit;
55
Werner Lemberge3f41982003-10-16 15:48:39 +000056 error = t42_parse_dict( face, &loader,
57 parser->base_dict, parser->base_len );
David Turner9f95bab2002-06-07 07:23:06 +000058
59 if ( type1->font_type != 42 )
60 {
Werner Lemberg8c90c222002-06-08 06:47:18 +000061 error = T42_Err_Unknown_File_Format;
David Turner9f95bab2002-06-07 07:23:06 +000062 goto Exit;
63 }
64
65 /* now, propagate the charstrings and glyphnames tables */
66 /* to the Type1 data */
67 type1->num_glyphs = loader.num_glyphs;
68
Werner Lemberge3f41982003-10-16 15:48:39 +000069 if ( !loader.charstrings.init )
70 {
David Turner9f95bab2002-06-07 07:23:06 +000071 FT_ERROR(( "T42_Open_Face: no charstrings array in face!\n" ));
Werner Lemberg8c90c222002-06-08 06:47:18 +000072 error = T42_Err_Invalid_File_Format;
David Turner9f95bab2002-06-07 07:23:06 +000073 }
74
Werner Lemberg8c90c222002-06-08 06:47:18 +000075 loader.charstrings.init = 0;
David Turner9f95bab2002-06-07 07:23:06 +000076 type1->charstrings_block = loader.charstrings.block;
77 type1->charstrings = loader.charstrings.elements;
78 type1->charstrings_len = loader.charstrings.lengths;
79
80 /* we copy the glyph names `block' and `elements' fields; */
81 /* the `lengths' field must be released later */
Werner Lemberg8c90c222002-06-08 06:47:18 +000082 type1->glyph_names_block = loader.glyph_names.block;
83 type1->glyph_names = (FT_String**)loader.glyph_names.elements;
David Turner9f95bab2002-06-07 07:23:06 +000084 loader.glyph_names.block = 0;
85 loader.glyph_names.elements = 0;
86
87 /* we must now build type1.encoding when we have a custom array */
88 if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
89 {
90 FT_Int charcode, idx, min_char, max_char;
91 FT_Byte* char_name;
92 FT_Byte* glyph_name;
93
94
95 /* OK, we do the following: for each element in the encoding */
96 /* table, look up the index of the glyph having the same name */
97 /* as defined in the CharStrings array. */
98 /* The index is then stored in type1.encoding.char_index, and */
99 /* the name in type1.encoding.char_name */
100
101 min_char = +32000;
102 max_char = -32000;
103
104 charcode = 0;
105 for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
106 {
107 type1->encoding.char_index[charcode] = 0;
108 type1->encoding.char_name [charcode] = (char *)".notdef";
109
110 char_name = loader.encoding_table.elements[charcode];
111 if ( char_name )
112 for ( idx = 0; idx < type1->num_glyphs; idx++ )
113 {
114 glyph_name = (FT_Byte*)type1->glyph_names[idx];
115 if ( ft_strcmp( (const char*)char_name,
116 (const char*)glyph_name ) == 0 )
117 {
118 type1->encoding.char_index[charcode] = (FT_UShort)idx;
119 type1->encoding.char_name [charcode] = (char*)glyph_name;
120
121 /* Change min/max encoded char only if glyph name is */
122 /* not /.notdef */
123 if ( ft_strcmp( (const char*)".notdef",
124 (const char*)glyph_name ) != 0 )
125 {
Werner Lemberge3f41982003-10-16 15:48:39 +0000126 if ( charcode < min_char )
127 min_char = charcode;
128 if ( charcode > max_char )
129 max_char = charcode;
David Turner9f95bab2002-06-07 07:23:06 +0000130 }
131 break;
132 }
133 }
134 }
135 type1->encoding.code_first = min_char;
136 type1->encoding.code_last = max_char;
137 type1->encoding.num_chars = loader.num_chars;
138 }
139
140 Exit:
141 t42_loader_done( &loader );
142 return error;
143 }
144
145
146 /***************** Driver Functions *************/
147
148
149 FT_LOCAL_DEF( FT_Error )
150 T42_Face_Init( FT_Stream stream,
151 T42_Face face,
152 FT_Int face_index,
153 FT_Int num_params,
Werner Lemberg68e9f922002-09-27 11:09:23 +0000154 FT_Parameter* params )
David Turner9f95bab2002-06-07 07:23:06 +0000155 {
Werner Lemberge3f41982003-10-16 15:48:39 +0000156 FT_Error error;
David Turner77605952003-10-29 21:43:52 +0000157 FT_Service_PsCMaps psnames;
Werner Lemberge3f41982003-10-16 15:48:39 +0000158 PSAux_Service psaux;
159 FT_Face root = (FT_Face)&face->root;
160 T1_Font type1 = &face->type1;
161 PS_FontInfo info = &type1->font_info;
David Turner9f95bab2002-06-07 07:23:06 +0000162
163 FT_UNUSED( num_params );
164 FT_UNUSED( params );
165 FT_UNUSED( face_index );
166 FT_UNUSED( stream );
167
168
169 face->ttf_face = NULL;
170 face->root.num_faces = 1;
171
David Turner77605952003-10-29 21:43:52 +0000172 FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
David Turnerb72d8a82003-09-29 20:33:37 +0000173 face->psnames = psnames;
David Turner9f95bab2002-06-07 07:23:06 +0000174
175 face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
176 "psaux" );
177 psaux = (PSAux_Service)face->psaux;
178
179 /* open the tokenizer, this will also check the font format */
180 error = T42_Open_Face( face );
181 if ( error )
182 goto Exit;
183
184 /* if we just wanted to check the format, leave successfully now */
185 if ( face_index < 0 )
186 goto Exit;
187
188 /* check the face index */
189 if ( face_index != 0 )
190 {
191 FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
Werner Lemberg8c90c222002-06-08 06:47:18 +0000192 error = T42_Err_Invalid_Argument;
David Turner9f95bab2002-06-07 07:23:06 +0000193 goto Exit;
194 }
195
Werner Lemberge3f41982003-10-16 15:48:39 +0000196 /* Now load the font program into the face object */
David Turner9f95bab2002-06-07 07:23:06 +0000197
198 /* Init the face object fields */
199 /* Now set up root face fields */
200
Werner Lemberg65ba7242003-05-30 09:12:50 +0000201 root->num_glyphs = type1->num_glyphs;
David Turner9f95bab2002-06-07 07:23:06 +0000202 root->num_charmaps = 0;
Werner Lemberg8c90c222002-06-08 06:47:18 +0000203 root->face_index = face_index;
David Turner9f95bab2002-06-07 07:23:06 +0000204
Werner Lemberg7734a1f2005-10-05 15:18:29 +0000205 root->face_flags = FT_FACE_FLAG_SCALABLE |
206 FT_FACE_FLAG_HORIZONTAL |
207 FT_FACE_FLAG_GLYPH_NAMES;
David Turner9f95bab2002-06-07 07:23:06 +0000208
Werner Lemberg64f1ba92003-07-25 22:09:53 +0000209 if ( info->is_fixed_pitch )
David Turner9f95bab2002-06-07 07:23:06 +0000210 root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
211
Werner Lemberg7734a1f2005-10-05 15:18:29 +0000212#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
213 root->face_flags |= FT_FACE_FLAG_HINTER;
214#endif
215
David Turner9f95bab2002-06-07 07:23:06 +0000216 /* XXX: TODO -- add kerning with .afm support */
217
218 /* get style name -- be careful, some broken fonts only */
219 /* have a `/FontName' dictionary entry! */
Werner Lemberg65ba7242003-05-30 09:12:50 +0000220 root->family_name = info->family_name;
Werner Lembergfdc042b2003-06-12 04:59:07 +0000221 /* assume "Regular" style if we don't know better */
222 root->style_name = (char *)"Regular";
David Turner9f95bab2002-06-07 07:23:06 +0000223 if ( root->family_name )
224 {
Werner Lemberg65ba7242003-05-30 09:12:50 +0000225 char* full = info->full_name;
David Turner9f95bab2002-06-07 07:23:06 +0000226 char* family = root->family_name;
227
228
229 if ( full )
230 {
Werner Lembergfdc042b2003-06-12 04:59:07 +0000231 while ( *full )
David Turner9f95bab2002-06-07 07:23:06 +0000232 {
Werner Lembergfdc042b2003-06-12 04:59:07 +0000233 if ( *full == *family )
234 {
235 family++;
236 full++;
237 }
238 else
239 {
240 if ( *full == ' ' || *full == '-' )
241 full++;
242 else if ( *family == ' ' || *family == '-' )
243 family++;
244 else
245 {
246 if ( !*family )
247 root->style_name = full;
248 break;
249 }
250 }
David Turner9f95bab2002-06-07 07:23:06 +0000251 }
David Turner9f95bab2002-06-07 07:23:06 +0000252 }
David Turner9f95bab2002-06-07 07:23:06 +0000253 }
254 else
255 {
256 /* do we have a `/FontName'? */
Werner Lemberg65ba7242003-05-30 09:12:50 +0000257 if ( type1->font_name )
Werner Lemberg65ba7242003-05-30 09:12:50 +0000258 root->family_name = type1->font_name;
David Turner9f95bab2002-06-07 07:23:06 +0000259 }
260
261 /* no embedded bitmap support */
262 root->num_fixed_sizes = 0;
263 root->available_sizes = 0;
264
265 /* Load the TTF font embedded in the T42 font */
Werner Lemberg2a0903a2005-12-03 08:13:43 +0000266 {
267 FT_Open_Args args;
268
269
270 args.flags = FT_OPEN_MEMORY;
271 args.memory_base = face->ttf_data;
272 args.memory_size = face->ttf_size;
273
274 if ( num_params )
275 {
276 args.flags |= FT_OPEN_PARAMS;
277 args.num_params = num_params;
278 args.params = params;
279 }
280
281 error = FT_Open_Face( FT_FACE_LIBRARY( face ),
282 &args, 0, &face->ttf_face );
283 }
284
David Turner9f95bab2002-06-07 07:23:06 +0000285 if ( error )
286 goto Exit;
287
David Turnera1e45652002-06-11 20:35:58 +0000288 FT_Done_Size( face->ttf_face->size );
289
David Turner9f95bab2002-06-07 07:23:06 +0000290 /* Ignore info in FontInfo dictionary and use the info from the */
291 /* loaded TTF font. The PostScript interpreter also ignores it. */
292 root->bbox = face->ttf_face->bbox;
293 root->units_per_EM = face->ttf_face->units_per_EM;
294
295 root->ascender = face->ttf_face->ascender;
296 root->descender = face->ttf_face->descender;
297 root->height = face->ttf_face->height;
298
Werner Lemberg8c90c222002-06-08 06:47:18 +0000299 root->max_advance_width = face->ttf_face->max_advance_width;
David Turner9f95bab2002-06-07 07:23:06 +0000300 root->max_advance_height = face->ttf_face->max_advance_height;
301
Werner Lemberg9472e232004-02-14 19:21:37 +0000302 root->underline_position = (FT_Short)info->underline_position;
303 root->underline_thickness = (FT_Short)info->underline_thickness;
David Turner9f95bab2002-06-07 07:23:06 +0000304
David Turner9f95bab2002-06-07 07:23:06 +0000305 /* compute style flags */
306 root->style_flags = 0;
Werner Lemberg64f1ba92003-07-25 22:09:53 +0000307 if ( info->italic_angle )
David Turner9f95bab2002-06-07 07:23:06 +0000308 root->style_flags |= FT_STYLE_FLAG_ITALIC;
309
310 if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD )
311 root->style_flags |= FT_STYLE_FLAG_BOLD;
312
313 if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL )
314 root->face_flags |= FT_FACE_FLAG_VERTICAL;
315
David Turner9f95bab2002-06-07 07:23:06 +0000316 {
317 if ( psnames && psaux )
318 {
319 FT_CharMapRec charmap;
320 T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
321 FT_CMap_Class clazz;
322
323
324 charmap.face = root;
325
326 /* first of all, try to synthetize a Unicode charmap */
327 charmap.platform_id = 3;
328 charmap.encoding_id = 1;
David Turnerb08fe2d2002-08-27 20:20:29 +0000329 charmap.encoding = FT_ENCODING_UNICODE;
David Turner9f95bab2002-06-07 07:23:06 +0000330
331 FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
332
333 /* now, generate an Adobe Standard encoding when appropriate */
334 charmap.platform_id = 7;
335 clazz = NULL;
336
Werner Lemberg65ba7242003-05-30 09:12:50 +0000337 switch ( type1->encoding_type )
David Turner9f95bab2002-06-07 07:23:06 +0000338 {
339 case T1_ENCODING_TYPE_STANDARD:
David Turnerb08fe2d2002-08-27 20:20:29 +0000340 charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
David Turner9f95bab2002-06-07 07:23:06 +0000341 charmap.encoding_id = 0;
342 clazz = cmap_classes->standard;
343 break;
344
345 case T1_ENCODING_TYPE_EXPERT:
David Turnerb08fe2d2002-08-27 20:20:29 +0000346 charmap.encoding = FT_ENCODING_ADOBE_EXPERT;
David Turner9f95bab2002-06-07 07:23:06 +0000347 charmap.encoding_id = 1;
348 clazz = cmap_classes->expert;
349 break;
350
351 case T1_ENCODING_TYPE_ARRAY:
David Turnerb08fe2d2002-08-27 20:20:29 +0000352 charmap.encoding = FT_ENCODING_ADOBE_CUSTOM;
David Turner9f95bab2002-06-07 07:23:06 +0000353 charmap.encoding_id = 2;
354 clazz = cmap_classes->custom;
355 break;
356
357 case T1_ENCODING_TYPE_ISOLATIN1:
David Turnerb08fe2d2002-08-27 20:20:29 +0000358 charmap.encoding = FT_ENCODING_ADOBE_LATIN_1;
David Turner9f95bab2002-06-07 07:23:06 +0000359 charmap.encoding_id = 3;
360 clazz = cmap_classes->unicode;
361 break;
362
363 default:
364 ;
365 }
366
367 if ( clazz )
368 FT_CMap_New( clazz, NULL, &charmap, NULL );
369
David Turnerfed59b72002-07-17 22:51:06 +0000370#if 0
Werner Lemberg8c90c222002-06-08 06:47:18 +0000371 /* Select default charmap */
Werner Lemberge3f41982003-10-16 15:48:39 +0000372 if ( root->num_charmaps )
Werner Lemberg8c90c222002-06-08 06:47:18 +0000373 root->charmap = root->charmaps[0];
David Turnerfed59b72002-07-17 22:51:06 +0000374#endif
David Turner9f95bab2002-06-07 07:23:06 +0000375 }
376 }
David Turner9f95bab2002-06-07 07:23:06 +0000377 Exit:
378 return error;
379 }
380
381
382 FT_LOCAL_DEF( void )
383 T42_Face_Done( T42_Face face )
384 {
385 T1_Font type1;
386 PS_FontInfo info;
387 FT_Memory memory;
388
389
390 if ( face )
391 {
Werner Lemberg8c90c222002-06-08 06:47:18 +0000392 type1 = &face->type1;
David Turner9f95bab2002-06-07 07:23:06 +0000393 info = &type1->font_info;
394 memory = face->root.memory;
395
396 /* delete internal ttf face prior to freeing face->ttf_data */
397 if ( face->ttf_face )
398 FT_Done_Face( face->ttf_face );
399
400 /* release font info strings */
401 FT_FREE( info->version );
402 FT_FREE( info->notice );
403 FT_FREE( info->full_name );
404 FT_FREE( info->family_name );
405 FT_FREE( info->weight );
406
407 /* release top dictionary */
408 FT_FREE( type1->charstrings_len );
409 FT_FREE( type1->charstrings );
410 FT_FREE( type1->glyph_names );
411
412 FT_FREE( type1->charstrings_block );
413 FT_FREE( type1->glyph_names_block );
414
415 FT_FREE( type1->encoding.char_index );
416 FT_FREE( type1->encoding.char_name );
417 FT_FREE( type1->font_name );
418
419 FT_FREE( face->ttf_data );
420
421#if 0
422 /* release afm data if present */
423 if ( face->afm_data )
424 T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
425#endif
426
427 /* release unicode map, if any */
428 FT_FREE( face->unicode_map.maps );
429 face->unicode_map.num_maps = 0;
430
431 face->root.family_name = 0;
432 face->root.style_name = 0;
433 }
434 }
435
Werner Lemberg8c90c222002-06-08 06:47:18 +0000436
David Turner9f95bab2002-06-07 07:23:06 +0000437 /*************************************************************************/
438 /* */
439 /* <Function> */
440 /* T42_Driver_Init */
441 /* */
442 /* <Description> */
443 /* Initializes a given Type 42 driver object. */
444 /* */
445 /* <Input> */
446 /* driver :: A handle to the target driver object. */
447 /* */
448 /* <Return> */
449 /* FreeType error code. 0 means success. */
450 /* */
451 FT_LOCAL_DEF( FT_Error )
452 T42_Driver_Init( T42_Driver driver )
453 {
454 FT_Module ttmodule;
455
456
457 ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" );
458 driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
459
Werner Lemberg8c90c222002-06-08 06:47:18 +0000460 return T42_Err_Ok;
David Turner9f95bab2002-06-07 07:23:06 +0000461 }
462
463
464 FT_LOCAL_DEF( void )
465 T42_Driver_Done( T42_Driver driver )
466 {
467 FT_UNUSED( driver );
468 }
469
470
David Turner9f95bab2002-06-07 07:23:06 +0000471 FT_LOCAL_DEF( FT_Error )
472 T42_Size_Init( T42_Size size )
473 {
474 FT_Face face = size->root.face;
475 T42_Face t42face = (T42_Face)face;
476 FT_Size ttsize;
Werner Lemberg8c90c222002-06-08 06:47:18 +0000477 FT_Error error = T42_Err_Ok;
David Turner9f95bab2002-06-07 07:23:06 +0000478
479
480 error = FT_New_Size( t42face->ttf_face, &ttsize );
481 size->ttsize = ttsize;
482
David Turnera1e45652002-06-11 20:35:58 +0000483 FT_Activate_Size( ttsize );
484
David Turner9f95bab2002-06-07 07:23:06 +0000485 return error;
486 }
487
488
Wu, Chia-I (吳佳一)fa7d6ab2006-01-13 12:21:31 +0000489 FT_LOCAL_DEF( FT_Error )
490 T42_Size_Request( T42_Size size,
491 FT_Size_Request req )
492 {
Werner Lembergf1c2b912006-01-13 14:53:28 +0000493 T42_Face face = (T42_Face)size->root.face;
Wu, Chia-I (吳佳一)bcc438b2006-01-23 14:12:40 +0000494 FT_Error error;
Wu, Chia-I (吳佳一)fa7d6ab2006-01-13 12:21:31 +0000495
496
497 FT_Activate_Size( size->ttsize );
498
Wu, Chia-I (吳佳一)bcc438b2006-01-23 14:12:40 +0000499 error = FT_Request_Size( face->ttf_face, req );
500 if ( !error )
501 ( (FT_Size)size )->metrics = face->ttf_face->size->metrics;
502
503 return error;
Wu, Chia-I (吳佳一)fa7d6ab2006-01-13 12:21:31 +0000504 }
505
506
507 FT_LOCAL_DEF( FT_Error )
508 T42_Size_Select( T42_Size size,
Wu, Chia-I (吳佳一)bcc438b2006-01-23 14:12:40 +0000509 FT_ULong strike_index )
Wu, Chia-I (吳佳一)fa7d6ab2006-01-13 12:21:31 +0000510 {
Werner Lembergf1c2b912006-01-13 14:53:28 +0000511 T42_Face face = (T42_Face)size->root.face;
Wu, Chia-I (吳佳一)bcc438b2006-01-23 14:12:40 +0000512 FT_Error error;
Wu, Chia-I (吳佳一)fa7d6ab2006-01-13 12:21:31 +0000513
514
515 FT_Activate_Size( size->ttsize );
516
Wu, Chia-I (吳佳一)bcc438b2006-01-23 14:12:40 +0000517 error = FT_Select_Size( face->ttf_face, strike_index );
518 if ( !error )
519 ( (FT_Size)size )->metrics = face->ttf_face->size->metrics;
520
521 return error;
522
Wu, Chia-I (吳佳一)fa7d6ab2006-01-13 12:21:31 +0000523 }
524
525
David Turner9f95bab2002-06-07 07:23:06 +0000526 FT_LOCAL_DEF( void )
527 T42_Size_Done( T42_Size size )
528 {
529 FT_Face face = size->root.face;
530 T42_Face t42face = (T42_Face)face;
531 FT_ListNode node;
532
533
534 node = FT_List_Find( &t42face->ttf_face->sizes_list, size->ttsize );
535 if ( node )
536 {
537 FT_Done_Size( size->ttsize );
538 size->ttsize = NULL;
539 }
540 }
541
542
543 FT_LOCAL_DEF( FT_Error )
544 T42_GlyphSlot_Init( T42_GlyphSlot slot )
545 {
546 FT_Face face = slot->root.face;
547 T42_Face t42face = (T42_Face)face;
548 FT_GlyphSlot ttslot;
Werner Lemberg8c90c222002-06-08 06:47:18 +0000549 FT_Error error = T42_Err_Ok;
David Turner9f95bab2002-06-07 07:23:06 +0000550
551
552 if ( face->glyph == NULL )
553 {
554 /* First glyph slot for this face */
555 slot->ttslot = t42face->ttf_face->glyph;
556 }
557 else
558 {
559 error = FT_New_GlyphSlot( t42face->ttf_face, &ttslot );
560 slot->ttslot = ttslot;
561 }
562
563 return error;
564 }
565
566
567 FT_LOCAL_DEF( void )
568 T42_GlyphSlot_Done( T42_GlyphSlot slot )
569 {
Werner Lembergb9ee7372005-05-20 21:52:19 +0000570 FT_Done_GlyphSlot( slot->ttslot );
David Turner9f95bab2002-06-07 07:23:06 +0000571 }
572
573
David Turner9f95bab2002-06-07 07:23:06 +0000574 static void
David Turner66cbc202003-03-20 07:04:40 +0000575 t42_glyphslot_clear( FT_GlyphSlot slot )
David Turner9f95bab2002-06-07 07:23:06 +0000576 {
577 /* free bitmap if needed */
David Turner66cbc202003-03-20 07:04:40 +0000578 ft_glyphslot_free_bitmap( slot );
David Turner9f95bab2002-06-07 07:23:06 +0000579
580 /* clear all public fields in the glyph slot */
David Turnera1e45652002-06-11 20:35:58 +0000581 FT_ZERO( &slot->metrics );
582 FT_ZERO( &slot->outline );
583 FT_ZERO( &slot->bitmap );
David Turner9f95bab2002-06-07 07:23:06 +0000584
585 slot->bitmap_left = 0;
586 slot->bitmap_top = 0;
587 slot->num_subglyphs = 0;
588 slot->subglyphs = 0;
589 slot->control_data = 0;
590 slot->control_len = 0;
591 slot->other = 0;
David Turnerb08fe2d2002-08-27 20:20:29 +0000592 slot->format = FT_GLYPH_FORMAT_NONE;
David Turner9f95bab2002-06-07 07:23:06 +0000593
594 slot->linearHoriAdvance = 0;
595 slot->linearVertAdvance = 0;
596 }
597
598
599 FT_LOCAL_DEF( FT_Error )
600 T42_GlyphSlot_Load( FT_GlyphSlot glyph,
601 FT_Size size,
Werner Lemberge3f41982003-10-16 15:48:39 +0000602 FT_UInt glyph_index,
Werner Lemberg68e9f922002-09-27 11:09:23 +0000603 FT_Int32 load_flags )
David Turner9f95bab2002-06-07 07:23:06 +0000604 {
605 FT_Error error;
606 T42_GlyphSlot t42slot = (T42_GlyphSlot)glyph;
607 T42_Size t42size = (T42_Size)size;
608 FT_Driver_Class ttclazz = ((T42_Driver)glyph->face->driver)->ttclazz;
609
Werner Lembergbd8e3242002-06-12 08:43:58 +0000610
David Turner66cbc202003-03-20 07:04:40 +0000611 t42_glyphslot_clear( t42slot->ttslot );
David Turner9f95bab2002-06-07 07:23:06 +0000612 error = ttclazz->load_glyph( t42slot->ttslot,
613 t42size->ttsize,
614 glyph_index,
615 load_flags | FT_LOAD_NO_BITMAP );
616
617 if ( !error )
618 {
619 glyph->metrics = t42slot->ttslot->metrics;
620
621 glyph->linearHoriAdvance = t42slot->ttslot->linearHoriAdvance;
622 glyph->linearVertAdvance = t42slot->ttslot->linearVertAdvance;
623
624 glyph->format = t42slot->ttslot->format;
625 glyph->outline = t42slot->ttslot->outline;
626
627 glyph->bitmap = t42slot->ttslot->bitmap;
628 glyph->bitmap_left = t42slot->ttslot->bitmap_left;
629 glyph->bitmap_top = t42slot->ttslot->bitmap_top;
David Turnerd1214ac2002-07-17 21:14:23 +0000630
David Turnera1e45652002-06-11 20:35:58 +0000631 glyph->num_subglyphs = t42slot->ttslot->num_subglyphs;
632 glyph->subglyphs = t42slot->ttslot->subglyphs;
David Turnerd1214ac2002-07-17 21:14:23 +0000633
David Turnera1e45652002-06-11 20:35:58 +0000634 glyph->control_data = t42slot->ttslot->control_data;
635 glyph->control_len = t42slot->ttslot->control_len;
David Turner9f95bab2002-06-07 07:23:06 +0000636 }
637
638 return error;
639 }
640
641
Werner Lemberg8c90c222002-06-08 06:47:18 +0000642/* END */