• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /***************************************************************************/
2 /*                                                                         */
3 /*  afpic.c                                                                */
4 /*                                                                         */
5 /*    The FreeType position independent code services for autofit module.  */
6 /*                                                                         */
7 /*  Copyright 2009, 2010 by                                                */
8 /*  Oran Agra and Mickey Gabel.                                            */
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 /***************************************************************************/
17 
18 
19 #include <ft2build.h>
20 #include FT_FREETYPE_H
21 #include FT_INTERNAL_OBJECTS_H
22 #include "afpic.h"
23 
24 #ifdef FT_CONFIG_OPTION_PIC
25 
26   /* forward declaration of PIC init functions from afmodule.c */
27   void FT_Init_Class_af_autofitter_service( FT_Library, FT_AutoHinter_ServiceRec*);
28 
29   /* forward declaration of PIC init functions from script classes */
30 #include "aflatin.h"
31 #include "aflatin2.h"
32 #include "afcjk.h"
33 #include "afdummy.h"
34 #include "afindic.h"
35 
36   void
autofit_module_class_pic_free(FT_Library library)37   autofit_module_class_pic_free( FT_Library library )
38   {
39     FT_PIC_Container* pic_container = &library->pic_container;
40     FT_Memory memory = library->memory;
41     if ( pic_container->autofit )
42     {
43       FT_FREE( pic_container->autofit );
44       pic_container->autofit = NULL;
45     }
46   }
47 
48 
49   FT_Error
autofit_module_class_pic_init(FT_Library library)50   autofit_module_class_pic_init( FT_Library  library )
51   {
52     FT_PIC_Container*  pic_container = &library->pic_container;
53     FT_UInt            ss;
54     FT_Error           error         = AF_Err_Ok;
55     AFModulePIC*       container;
56     FT_Memory          memory        = library->memory;
57 
58 
59     /* allocate pointer, clear and set global container pointer */
60     if ( FT_ALLOC ( container, sizeof ( *container ) ) )
61       return error;
62     FT_MEM_SET( container, 0, sizeof ( *container ) );
63     pic_container->autofit = container;
64 
65     /* initialize pointer table - this is how the module usually expects this data */
66     for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
67     {
68       container->af_script_classes[ss] = &container->af_script_classes_rec[ss];
69     }
70     container->af_script_classes[AF_SCRIPT_CLASSES_COUNT-1] = NULL;
71 
72     /* add call to initialization function when you add new scripts */
73     ss = 0;
74     FT_Init_Class_af_dummy_script_class(&container->af_script_classes_rec[ss++]);
75 #ifdef FT_OPTION_AUTOFIT2
76     FT_Init_Class_af_latin2_script_class(&container->af_script_classes_rec[ss++]);
77 #endif
78     FT_Init_Class_af_latin_script_class(&container->af_script_classes_rec[ss++]);
79     FT_Init_Class_af_cjk_script_class(&container->af_script_classes_rec[ss++]);
80     FT_Init_Class_af_indic_script_class(&container->af_script_classes_rec[ss++]);
81 
82     FT_Init_Class_af_autofitter_service(library, &container->af_autofitter_service);
83 
84 /*Exit:*/
85     if(error)
86       autofit_module_class_pic_free(library);
87     return error;
88   }
89 
90 
91 #endif /* FT_CONFIG_OPTION_PIC */
92 
93 
94 /* END */
95