Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / modules / freetype2 / src / truetype / ttobjs.c
blob801559fe49981317b44e26b3da1ac94e09267963
1 /***************************************************************************/
2 /* */
3 /* ttobjs.c */
4 /* */
5 /* Objects manager (body). */
6 /* */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 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 FT_INTERNAL_DEBUG_H
21 #include FT_INTERNAL_CALC_H
22 #include FT_INTERNAL_STREAM_H
23 #include FT_TRUETYPE_IDS_H
24 #include FT_TRUETYPE_TAGS_H
25 #include FT_INTERNAL_SFNT_H
27 #include "ttgload.h"
28 #include "ttpload.h"
30 #include "tterrors.h"
32 #ifdef TT_USE_BYTECODE_INTERPRETER
33 #include "ttinterp.h"
34 #endif
36 #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
37 #include FT_TRUETYPE_UNPATENTED_H
38 #endif
40 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
41 #include "ttgxvar.h"
42 #endif
44 /*************************************************************************/
45 /* */
46 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
47 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
48 /* messages during execution. */
49 /* */
50 #undef FT_COMPONENT
51 #define FT_COMPONENT trace_ttobjs
54 #ifdef TT_USE_BYTECODE_INTERPRETER
56 /*************************************************************************/
57 /* */
58 /* GLYPH ZONE FUNCTIONS */
59 /* */
60 /*************************************************************************/
63 /*************************************************************************/
64 /* */
65 /* <Function> */
66 /* tt_glyphzone_done */
67 /* */
68 /* <Description> */
69 /* Deallocate a glyph zone. */
70 /* */
71 /* <Input> */
72 /* zone :: A pointer to the target glyph zone. */
73 /* */
74 FT_LOCAL_DEF( void )
75 tt_glyphzone_done( TT_GlyphZone zone )
77 FT_Memory memory = zone->memory;
80 if ( memory )
82 FT_FREE( zone->contours );
83 FT_FREE( zone->tags );
84 FT_FREE( zone->cur );
85 FT_FREE( zone->org );
86 FT_FREE( zone->orus );
88 zone->max_points = zone->n_points = 0;
89 zone->max_contours = zone->n_contours = 0;
90 zone->memory = NULL;
95 /*************************************************************************/
96 /* */
97 /* <Function> */
98 /* tt_glyphzone_new */
99 /* */
100 /* <Description> */
101 /* Allocate a new glyph zone. */
102 /* */
103 /* <Input> */
104 /* memory :: A handle to the current memory object. */
105 /* */
106 /* maxPoints :: The capacity of glyph zone in points. */
107 /* */
108 /* maxContours :: The capacity of glyph zone in contours. */
109 /* */
110 /* <Output> */
111 /* zone :: A pointer to the target glyph zone record. */
112 /* */
113 /* <Return> */
114 /* FreeType error code. 0 means success. */
115 /* */
116 FT_LOCAL_DEF( FT_Error )
117 tt_glyphzone_new( FT_Memory memory,
118 FT_UShort maxPoints,
119 FT_Short maxContours,
120 TT_GlyphZone zone )
122 FT_Error error;
125 FT_MEM_ZERO( zone, sizeof ( *zone ) );
126 zone->memory = memory;
128 if ( FT_NEW_ARRAY( zone->org, maxPoints ) ||
129 FT_NEW_ARRAY( zone->cur, maxPoints ) ||
130 FT_NEW_ARRAY( zone->orus, maxPoints ) ||
131 FT_NEW_ARRAY( zone->tags, maxPoints ) ||
132 FT_NEW_ARRAY( zone->contours, maxContours ) )
134 tt_glyphzone_done( zone );
136 else
138 zone->max_points = maxPoints;
139 zone->max_contours = maxContours;
142 return error;
144 #endif /* TT_USE_BYTECODE_INTERPRETER */
147 /*************************************************************************/
148 /* */
149 /* <Function> */
150 /* tt_face_init */
151 /* */
152 /* <Description> */
153 /* Initialize a given TrueType face object. */
154 /* */
155 /* <Input> */
156 /* stream :: The source font stream. */
157 /* */
158 /* face_index :: The index of the font face in the resource. */
159 /* */
160 /* num_params :: Number of additional generic parameters. Ignored. */
161 /* */
162 /* params :: Additional generic parameters. Ignored. */
163 /* */
164 /* <InOut> */
165 /* face :: The newly built face object. */
166 /* */
167 /* <Return> */
168 /* FreeType error code. 0 means success. */
169 /* */
170 FT_LOCAL_DEF( FT_Error )
171 tt_face_init( FT_Stream stream,
172 FT_Face ttface, /* TT_Face */
173 FT_Int face_index,
174 FT_Int num_params,
175 FT_Parameter* params )
177 FT_Error error;
178 FT_Library library;
179 SFNT_Service sfnt;
180 TT_Face face = (TT_Face)ttface;
183 library = face->root.driver->root.library;
184 sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
185 if ( !sfnt )
186 goto Bad_Format;
188 /* create input stream from resource */
189 if ( FT_STREAM_SEEK( 0 ) )
190 goto Exit;
192 /* check that we have a valid TrueType file */
193 error = sfnt->init_face( stream, face, face_index, num_params, params );
194 if ( error )
195 goto Exit;
197 /* We must also be able to accept Mac/GX fonts, as well as OT ones. */
198 /* The 0x00020000 tag is completely undocumented; some fonts from */
199 /* Arphic made for Chinese Windows 3.1 have this. */
200 if ( face->format_tag != 0x00010000L && /* MS fonts */
201 face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */
202 face->format_tag != TTAG_true ) /* Mac fonts */
204 FT_TRACE2(( "[not a valid TTF font]\n" ));
205 goto Bad_Format;
208 #ifdef TT_USE_BYTECODE_INTERPRETER
209 face->root.face_flags |= FT_FACE_FLAG_HINTER;
210 #endif
212 /* If we are performing a simple font format check, exit immediately. */
213 if ( face_index < 0 )
214 return TT_Err_Ok;
216 /* Load font directory */
217 error = sfnt->load_face( stream, face, face_index, num_params, params );
218 if ( error )
219 goto Exit;
221 error = tt_face_load_hdmx( face, stream );
222 if ( error )
223 goto Exit;
225 if ( face->root.face_flags & FT_FACE_FLAG_SCALABLE )
228 #ifdef FT_CONFIG_OPTION_INCREMENTAL
230 if ( !face->root.internal->incremental_interface )
231 error = tt_face_load_loca( face, stream );
232 if ( !error )
233 error = tt_face_load_cvt( face, stream );
234 if ( !error )
235 error = tt_face_load_fpgm( face, stream );
236 if ( !error )
237 error = tt_face_load_prep( face, stream );
239 #else
241 if ( !error )
242 error = tt_face_load_loca( face, stream );
243 if ( !error )
244 error = tt_face_load_cvt( face, stream );
245 if ( !error )
246 error = tt_face_load_fpgm( face, stream );
247 if ( !error )
248 error = tt_face_load_prep( face, stream );
250 #endif
254 #if defined( TT_CONFIG_OPTION_UNPATENTED_HINTING ) && \
255 !defined( TT_CONFIG_OPTION_BYTECODE_INTERPRETER )
258 FT_Bool unpatented_hinting;
259 int i;
262 /* Determine whether unpatented hinting is to be used for this face. */
263 unpatented_hinting = FT_BOOL
264 ( library->debug_hooks[FT_DEBUG_HOOK_UNPATENTED_HINTING] != NULL );
266 for ( i = 0; i < num_params && !face->unpatented_hinting; i++ )
267 if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING )
268 unpatented_hinting = TRUE;
270 /* Compare the face with a list of well-known `tricky' fonts. */
271 /* This list shall be expanded as we find more of them. */
272 if ( !unpatented_hinting )
274 static const char* const trick_names[] =
276 "DFKaiSho-SB", /* dfkaisb.ttf */
277 "DFKai-SB", /* kaiu.ttf */
278 "HuaTianSongTi?", /* htst3.ttf */
279 "MingLiU", /* mingliu.ttf & mingliu.ttc */
280 "PMingLiU", /* mingliu.ttc */
281 "MingLi43", /* mingli.ttf */
282 NULL
284 int nn;
287 /* Note that we only check the face name at the moment; it might */
288 /* be worth to do more checks for a few special cases. */
289 for ( nn = 0; trick_names[nn] != NULL; nn++ )
291 if ( ttface->family_name &&
292 ft_strstr( ttface->family_name, trick_names[nn] ) )
294 unpatented_hinting = 1;
295 break;
300 ttface->internal->ignore_unpatented_hinter =
301 FT_BOOL( !unpatented_hinting );
304 #endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING &&
305 !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
307 /* initialize standard glyph loading routines */
308 TT_Init_Glyph_Loading( face );
310 Exit:
311 return error;
313 Bad_Format:
314 error = TT_Err_Unknown_File_Format;
315 goto Exit;
319 /*************************************************************************/
320 /* */
321 /* <Function> */
322 /* tt_face_done */
323 /* */
324 /* <Description> */
325 /* Finalize a given face object. */
326 /* */
327 /* <Input> */
328 /* face :: A pointer to the face object to destroy. */
329 /* */
330 FT_LOCAL_DEF( void )
331 tt_face_done( FT_Face ttface ) /* TT_Face */
333 TT_Face face = (TT_Face)ttface;
334 FT_Memory memory = face->root.memory;
335 FT_Stream stream = face->root.stream;
337 SFNT_Service sfnt = (SFNT_Service)face->sfnt;
340 /* for `extended TrueType formats' (i.e. compressed versions) */
341 if ( face->extra.finalizer )
342 face->extra.finalizer( face->extra.data );
344 if ( sfnt )
345 sfnt->done_face( face );
347 /* freeing the locations table */
348 tt_face_done_loca( face );
350 tt_face_free_hdmx( face );
352 /* freeing the CVT */
353 FT_FREE( face->cvt );
354 face->cvt_size = 0;
356 /* freeing the programs */
357 FT_FRAME_RELEASE( face->font_program );
358 FT_FRAME_RELEASE( face->cvt_program );
359 face->font_program_size = 0;
360 face->cvt_program_size = 0;
362 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
363 tt_done_blend( memory, face->blend );
364 face->blend = NULL;
365 #endif
369 /*************************************************************************/
370 /* */
371 /* SIZE FUNCTIONS */
372 /* */
373 /*************************************************************************/
375 #ifdef TT_USE_BYTECODE_INTERPRETER
377 /*************************************************************************/
378 /* */
379 /* <Function> */
380 /* tt_size_run_fpgm */
381 /* */
382 /* <Description> */
383 /* Run the font program. */
384 /* */
385 /* <Input> */
386 /* size :: A handle to the size object. */
387 /* */
388 /* <Return> */
389 /* FreeType error code. 0 means success. */
390 /* */
391 FT_LOCAL_DEF( FT_Error )
392 tt_size_run_fpgm( TT_Size size )
394 TT_Face face = (TT_Face)size->root.face;
395 TT_ExecContext exec;
396 FT_Error error;
399 /* debugging instances have their own context */
400 if ( size->debug )
401 exec = size->context;
402 else
403 exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
405 if ( !exec )
406 return TT_Err_Could_Not_Find_Context;
408 TT_Load_Context( exec, face, size );
410 exec->callTop = 0;
411 exec->top = 0;
413 exec->period = 64;
414 exec->phase = 0;
415 exec->threshold = 0;
417 exec->instruction_trap = FALSE;
418 exec->F_dot_P = 0x10000L;
421 FT_Size_Metrics* metrics = &exec->metrics;
422 TT_Size_Metrics* tt_metrics = &exec->tt_metrics;
425 metrics->x_ppem = 0;
426 metrics->y_ppem = 0;
427 metrics->x_scale = 0;
428 metrics->y_scale = 0;
430 tt_metrics->ppem = 0;
431 tt_metrics->scale = 0;
432 tt_metrics->ratio = 0x10000L;
435 /* allow font program execution */
436 TT_Set_CodeRange( exec,
437 tt_coderange_font,
438 face->font_program,
439 face->font_program_size );
441 /* disable CVT and glyph programs coderange */
442 TT_Clear_CodeRange( exec, tt_coderange_cvt );
443 TT_Clear_CodeRange( exec, tt_coderange_glyph );
445 if ( face->font_program_size > 0 )
447 error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
449 if ( !error )
450 error = face->interpreter( exec );
452 else
453 error = TT_Err_Ok;
455 if ( !error )
456 TT_Save_Context( exec, size );
458 return error;
462 /*************************************************************************/
463 /* */
464 /* <Function> */
465 /* tt_size_run_prep */
466 /* */
467 /* <Description> */
468 /* Run the control value program. */
469 /* */
470 /* <Input> */
471 /* size :: A handle to the size object. */
472 /* */
473 /* <Return> */
474 /* FreeType error code. 0 means success. */
475 /* */
476 FT_LOCAL_DEF( FT_Error )
477 tt_size_run_prep( TT_Size size )
479 TT_Face face = (TT_Face)size->root.face;
480 TT_ExecContext exec;
481 FT_Error error;
484 /* debugging instances have their own context */
485 if ( size->debug )
486 exec = size->context;
487 else
488 exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
490 if ( !exec )
491 return TT_Err_Could_Not_Find_Context;
493 TT_Load_Context( exec, face, size );
495 exec->callTop = 0;
496 exec->top = 0;
498 exec->instruction_trap = FALSE;
500 TT_Set_CodeRange( exec,
501 tt_coderange_cvt,
502 face->cvt_program,
503 face->cvt_program_size );
505 TT_Clear_CodeRange( exec, tt_coderange_glyph );
507 if ( face->cvt_program_size > 0 )
509 error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
511 if ( !error && !size->debug )
512 error = face->interpreter( exec );
514 else
515 error = TT_Err_Ok;
517 /* save as default graphics state */
518 size->GS = exec->GS;
520 TT_Save_Context( exec, size );
522 return error;
525 #endif /* TT_USE_BYTECODE_INTERPRETER */
528 #ifdef TT_USE_BYTECODE_INTERPRETER
530 static void
531 tt_size_done_bytecode( FT_Size ftsize )
533 TT_Size size = (TT_Size)ftsize;
534 TT_Face face = (TT_Face)ftsize->face;
535 FT_Memory memory = face->root.memory;
538 if ( size->debug )
540 /* the debug context must be deleted by the debugger itself */
541 size->context = NULL;
542 size->debug = FALSE;
545 FT_FREE( size->cvt );
546 size->cvt_size = 0;
548 /* free storage area */
549 FT_FREE( size->storage );
550 size->storage_size = 0;
552 /* twilight zone */
553 tt_glyphzone_done( &size->twilight );
555 FT_FREE( size->function_defs );
556 FT_FREE( size->instruction_defs );
558 size->num_function_defs = 0;
559 size->max_function_defs = 0;
560 size->num_instruction_defs = 0;
561 size->max_instruction_defs = 0;
563 size->max_func = 0;
564 size->max_ins = 0;
566 size->bytecode_ready = 0;
567 size->cvt_ready = 0;
571 /* Initialize bytecode-related fields in the size object. */
572 /* We do this only if bytecode interpretation is really needed. */
573 static FT_Error
574 tt_size_init_bytecode( FT_Size ftsize )
576 FT_Error error;
577 TT_Size size = (TT_Size)ftsize;
578 TT_Face face = (TT_Face)ftsize->face;
579 FT_Memory memory = face->root.memory;
580 FT_Int i;
582 FT_UShort n_twilight;
583 TT_MaxProfile* maxp = &face->max_profile;
586 size->bytecode_ready = 1;
587 size->cvt_ready = 0;
589 size->max_function_defs = maxp->maxFunctionDefs;
590 size->max_instruction_defs = maxp->maxInstructionDefs;
592 size->num_function_defs = 0;
593 size->num_instruction_defs = 0;
595 size->max_func = 0;
596 size->max_ins = 0;
598 size->cvt_size = face->cvt_size;
599 size->storage_size = maxp->maxStorage;
601 /* Set default metrics */
603 FT_Size_Metrics* metrics = &size->metrics;
604 TT_Size_Metrics* metrics2 = &size->ttmetrics;
606 metrics->x_ppem = 0;
607 metrics->y_ppem = 0;
609 metrics2->rotated = FALSE;
610 metrics2->stretched = FALSE;
612 /* set default compensation (all 0) */
613 for ( i = 0; i < 4; i++ )
614 metrics2->compensations[i] = 0;
617 /* allocate function defs, instruction defs, cvt, and storage area */
618 if ( FT_NEW_ARRAY( size->function_defs, size->max_function_defs ) ||
619 FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) ||
620 FT_NEW_ARRAY( size->cvt, size->cvt_size ) ||
621 FT_NEW_ARRAY( size->storage, size->storage_size ) )
622 goto Exit;
624 /* reserve twilight zone */
625 n_twilight = maxp->maxTwilightPoints;
627 /* there are 4 phantom points (do we need this?) */
628 n_twilight += 4;
630 error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight );
631 if ( error )
632 goto Exit;
634 size->twilight.n_points = n_twilight;
636 size->GS = tt_default_graphics_state;
638 /* set `face->interpreter' according to the debug hook present */
640 FT_Library library = face->root.driver->root.library;
643 face->interpreter = (TT_Interpreter)
644 library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE];
645 if ( !face->interpreter )
646 face->interpreter = (TT_Interpreter)TT_RunIns;
649 /* Fine, now run the font program! */
650 error = tt_size_run_fpgm( size );
652 Exit:
653 if ( error )
654 tt_size_done_bytecode( ftsize );
656 return error;
660 FT_LOCAL_DEF( FT_Error )
661 tt_size_ready_bytecode( TT_Size size )
663 FT_Error error = TT_Err_Ok;
666 if ( !size->bytecode_ready )
668 error = tt_size_init_bytecode( (FT_Size)size );
669 if ( error )
670 goto Exit;
673 /* rescale CVT when needed */
674 if ( !size->cvt_ready )
676 FT_UInt i;
677 TT_Face face = (TT_Face) size->root.face;
680 /* Scale the cvt values to the new ppem. */
681 /* We use by default the y ppem to scale the CVT. */
682 for ( i = 0; i < size->cvt_size; i++ )
683 size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
685 /* all twilight points are originally zero */
686 for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ )
688 size->twilight.org[i].x = 0;
689 size->twilight.org[i].y = 0;
690 size->twilight.cur[i].x = 0;
691 size->twilight.cur[i].y = 0;
694 /* clear storage area */
695 for ( i = 0; i < (FT_UInt)size->storage_size; i++ )
696 size->storage[i] = 0;
698 size->GS = tt_default_graphics_state;
700 error = tt_size_run_prep( size );
701 if ( !error )
702 size->cvt_ready = 1;
705 Exit:
706 return error;
709 #endif /* TT_USE_BYTECODE_INTERPRETER */
712 /*************************************************************************/
713 /* */
714 /* <Function> */
715 /* tt_size_init */
716 /* */
717 /* <Description> */
718 /* Initialize a new TrueType size object. */
719 /* */
720 /* <InOut> */
721 /* size :: A handle to the size object. */
722 /* */
723 /* <Return> */
724 /* FreeType error code. 0 means success. */
725 /* */
726 FT_LOCAL_DEF( FT_Error )
727 tt_size_init( FT_Size ttsize ) /* TT_Size */
729 TT_Size size = (TT_Size)ttsize;
730 FT_Error error = TT_Err_Ok;
732 #ifdef TT_USE_BYTECODE_INTERPRETER
733 size->bytecode_ready = 0;
734 size->cvt_ready = 0;
735 #endif
737 size->ttmetrics.valid = FALSE;
738 size->strike_index = 0xFFFFFFFFUL;
740 return error;
744 /*************************************************************************/
745 /* */
746 /* <Function> */
747 /* tt_size_done */
748 /* */
749 /* <Description> */
750 /* The TrueType size object finalizer. */
751 /* */
752 /* <Input> */
753 /* size :: A handle to the target size object. */
754 /* */
755 FT_LOCAL_DEF( void )
756 tt_size_done( FT_Size ttsize ) /* TT_Size */
758 TT_Size size = (TT_Size)ttsize;
761 #ifdef TT_USE_BYTECODE_INTERPRETER
762 if ( size->bytecode_ready )
763 tt_size_done_bytecode( ttsize );
764 #endif
766 size->ttmetrics.valid = FALSE;
770 /*************************************************************************/
771 /* */
772 /* <Function> */
773 /* tt_size_reset */
774 /* */
775 /* <Description> */
776 /* Reset a TrueType size when resolutions and character dimensions */
777 /* have been changed. */
778 /* */
779 /* <Input> */
780 /* size :: A handle to the target size object. */
781 /* */
782 FT_LOCAL_DEF( FT_Error )
783 tt_size_reset( TT_Size size )
785 TT_Face face;
786 FT_Error error = TT_Err_Ok;
787 FT_Size_Metrics* metrics;
790 size->ttmetrics.valid = FALSE;
792 face = (TT_Face)size->root.face;
794 metrics = &size->metrics;
796 /* copy the result from base layer */
797 *metrics = size->root.metrics;
799 if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
800 return TT_Err_Invalid_PPem;
802 /* This bit flag, if set, indicates that the ppems must be */
803 /* rounded to integers. Nearly all TrueType fonts have this bit */
804 /* set, as hinting won't work really well otherwise. */
805 /* */
806 if ( face->header.Flags & 8 )
808 metrics->x_scale = FT_DivFix( metrics->x_ppem << 6,
809 face->root.units_per_EM );
810 metrics->y_scale = FT_DivFix( metrics->y_ppem << 6,
811 face->root.units_per_EM );
813 metrics->ascender =
814 FT_PIX_ROUND( FT_MulFix( face->root.ascender, metrics->y_scale ) );
815 metrics->descender =
816 FT_PIX_ROUND( FT_MulFix( face->root.descender, metrics->y_scale ) );
817 metrics->height =
818 FT_PIX_ROUND( FT_MulFix( face->root.height, metrics->y_scale ) );
819 metrics->max_advance =
820 FT_PIX_ROUND( FT_MulFix( face->root.max_advance_width,
821 metrics->x_scale ) );
824 /* compute new transformation */
825 if ( metrics->x_ppem >= metrics->y_ppem )
827 size->ttmetrics.scale = metrics->x_scale;
828 size->ttmetrics.ppem = metrics->x_ppem;
829 size->ttmetrics.x_ratio = 0x10000L;
830 size->ttmetrics.y_ratio = FT_MulDiv( metrics->y_ppem,
831 0x10000L,
832 metrics->x_ppem );
834 else
836 size->ttmetrics.scale = metrics->y_scale;
837 size->ttmetrics.ppem = metrics->y_ppem;
838 size->ttmetrics.x_ratio = FT_MulDiv( metrics->x_ppem,
839 0x10000L,
840 metrics->y_ppem );
841 size->ttmetrics.y_ratio = 0x10000L;
844 #ifdef TT_USE_BYTECODE_INTERPRETER
845 size->cvt_ready = 0;
846 #endif /* TT_USE_BYTECODE_INTERPRETER */
848 if ( !error )
849 size->ttmetrics.valid = TRUE;
851 return error;
855 /*************************************************************************/
856 /* */
857 /* <Function> */
858 /* tt_driver_init */
859 /* */
860 /* <Description> */
861 /* Initialize a given TrueType driver object. */
862 /* */
863 /* <Input> */
864 /* driver :: A handle to the target driver object. */
865 /* */
866 /* <Return> */
867 /* FreeType error code. 0 means success. */
868 /* */
869 FT_LOCAL_DEF( FT_Error )
870 tt_driver_init( FT_Module ttdriver ) /* TT_Driver */
873 #ifdef TT_USE_BYTECODE_INTERPRETER
875 TT_Driver driver = (TT_Driver)ttdriver;
878 if ( !TT_New_Context( driver ) )
879 return TT_Err_Could_Not_Find_Context;
881 #else
883 FT_UNUSED( ttdriver );
885 #endif
887 return TT_Err_Ok;
891 /*************************************************************************/
892 /* */
893 /* <Function> */
894 /* tt_driver_done */
895 /* */
896 /* <Description> */
897 /* Finalize a given TrueType driver. */
898 /* */
899 /* <Input> */
900 /* driver :: A handle to the target TrueType driver. */
901 /* */
902 FT_LOCAL_DEF( void )
903 tt_driver_done( FT_Module ttdriver ) /* TT_Driver */
905 #ifdef TT_USE_BYTECODE_INTERPRETER
906 TT_Driver driver = (TT_Driver)ttdriver;
909 /* destroy the execution context */
910 if ( driver->context )
912 TT_Done_Context( driver->context );
913 driver->context = NULL;
915 #else
916 FT_UNUSED( ttdriver );
917 #endif
922 /*************************************************************************/
923 /* */
924 /* <Function> */
925 /* tt_slot_init */
926 /* */
927 /* <Description> */
928 /* Initialize a new slot object. */
929 /* */
930 /* <InOut> */
931 /* slot :: A handle to the slot object. */
932 /* */
933 /* <Return> */
934 /* FreeType error code. 0 means success. */
935 /* */
936 FT_LOCAL_DEF( FT_Error )
937 tt_slot_init( FT_GlyphSlot slot )
939 return FT_GlyphLoader_CreateExtra( slot->internal->loader );
943 /* END */