OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* afpic.c */ | 3 /* afpic.c */ |
4 /* */ | 4 /* */ |
5 /* The FreeType position independent code services for autofit module. */ | 5 /* The FreeType position independent code services for autofit module. */ |
6 /* */ | 6 /* */ |
7 /* Copyright 2009, 2010, 2011 by */ | 7 /* Copyright 2009-2013 by */ |
8 /* Oran Agra and Mickey Gabel. */ | 8 /* Oran Agra and Mickey Gabel. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 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 */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
18 | 18 |
19 #include <ft2build.h> | 19 #include <ft2build.h> |
20 #include FT_FREETYPE_H | 20 #include FT_FREETYPE_H |
21 #include FT_INTERNAL_OBJECTS_H | 21 #include FT_INTERNAL_OBJECTS_H |
22 #include "afpic.h" | 22 #include "afpic.h" |
23 #include "aferrors.h" | 23 #include "aferrors.h" |
24 | 24 |
| 25 |
25 #ifdef FT_CONFIG_OPTION_PIC | 26 #ifdef FT_CONFIG_OPTION_PIC |
26 | 27 |
27 /* forward declaration of PIC init functions from afmodule.c */ | 28 /* forward declaration of PIC init functions from afmodule.c */ |
28 void FT_Init_Class_af_autofitter_service( | 29 FT_Error |
29 FT_Library library, | 30 FT_Create_Class_af_services( FT_Library library, |
30 FT_AutoHinter_ServiceRec* clazz ); | 31 FT_ServiceDescRec** output_class ); |
| 32 |
| 33 void |
| 34 FT_Destroy_Class_af_services( FT_Library library, |
| 35 FT_ServiceDescRec* clazz ); |
| 36 |
| 37 void |
| 38 FT_Init_Class_af_service_properties( FT_Service_PropertiesRec* clazz ); |
| 39 |
| 40 void FT_Init_Class_af_autofitter_interface( |
| 41 FT_Library library, |
| 42 FT_AutoHinter_InterfaceRec* clazz ); |
| 43 |
31 | 44 |
32 /* forward declaration of PIC init functions from script classes */ | 45 /* forward declaration of PIC init functions from script classes */ |
33 #include "aflatin.h" | 46 #include "aflatin.h" |
34 #ifdef FT_OPTION_AUTOFIT2 | 47 #ifdef FT_OPTION_AUTOFIT2 |
35 #include "aflatin2.h" | 48 #include "aflatin2.h" |
36 #endif | 49 #endif |
37 #include "afcjk.h" | 50 #include "afcjk.h" |
38 #include "afdummy.h" | 51 #include "afdummy.h" |
39 #include "afindic.h" | 52 #include "afindic.h" |
40 | 53 |
| 54 |
41 void | 55 void |
42 autofit_module_class_pic_free( FT_Library library ) | 56 autofit_module_class_pic_free( FT_Library library ) |
43 { | 57 { |
44 FT_PIC_Container* pic_container = &library->pic_container; | 58 FT_PIC_Container* pic_container = &library->pic_container; |
45 FT_Memory memory = library->memory; | 59 FT_Memory memory = library->memory; |
46 | 60 |
47 | 61 |
48 if ( pic_container->autofit ) | 62 if ( pic_container->autofit ) |
49 { | 63 { |
50 FT_FREE( pic_container->autofit ); | 64 AFModulePIC* container = (AFModulePIC*)pic_container->autofit; |
| 65 |
| 66 |
| 67 if ( container->af_services ) |
| 68 FT_Destroy_Class_af_services( library, |
| 69 container->af_services ); |
| 70 container->af_services = NULL; |
| 71 |
| 72 FT_FREE( container ); |
51 pic_container->autofit = NULL; | 73 pic_container->autofit = NULL; |
52 } | 74 } |
53 } | 75 } |
54 | 76 |
55 | 77 |
56 FT_Error | 78 FT_Error |
57 autofit_module_class_pic_init( FT_Library library ) | 79 autofit_module_class_pic_init( FT_Library library ) |
58 { | 80 { |
59 FT_PIC_Container* pic_container = &library->pic_container; | 81 FT_PIC_Container* pic_container = &library->pic_container; |
60 FT_UInt ss; | 82 FT_UInt ss; |
61 FT_Error error = AF_Err_Ok; | 83 FT_Error error = FT_Err_Ok; |
62 AFModulePIC* container; | 84 AFModulePIC* container = NULL; |
63 FT_Memory memory = library->memory; | 85 FT_Memory memory = library->memory; |
64 | 86 |
65 | 87 |
66 /* allocate pointer, clear and set global container pointer */ | 88 /* allocate pointer, clear and set global container pointer */ |
67 if ( FT_ALLOC ( container, sizeof ( *container ) ) ) | 89 if ( FT_ALLOC ( container, sizeof ( *container ) ) ) |
68 return error; | 90 return error; |
69 FT_MEM_SET( container, 0, sizeof ( *container ) ); | 91 FT_MEM_SET( container, 0, sizeof ( *container ) ); |
70 pic_container->autofit = container; | 92 pic_container->autofit = container; |
71 | 93 |
72 /* initialize pointer table - */ | 94 /* initialize pointer table - */ |
73 /* this is how the module usually expects this data */ | 95 /* this is how the module usually expects this data */ |
| 96 error = FT_Create_Class_af_services( library, |
| 97 &container->af_services ); |
| 98 if ( error ) |
| 99 goto Exit; |
| 100 |
| 101 FT_Init_Class_af_service_properties( &container->af_service_properties ); |
| 102 |
74 for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ ) | 103 for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ ) |
75 { | 104 { |
76 container->af_script_classes[ss] = | 105 container->af_script_classes[ss] = |
77 &container->af_script_classes_rec[ss]; | 106 &container->af_script_classes_rec[ss]; |
78 } | 107 } |
79 container->af_script_classes[AF_SCRIPT_CLASSES_COUNT - 1] = NULL; | 108 container->af_script_classes[AF_SCRIPT_CLASSES_COUNT - 1] = NULL; |
80 | 109 |
81 /* add call to initialization function when you add new scripts */ | 110 /* add call to initialization function when you add new scripts */ |
82 ss = 0; | 111 ss = 0; |
83 FT_Init_Class_af_dummy_script_class( | 112 FT_Init_Class_af_dummy_script_class( |
84 &container->af_script_classes_rec[ss++] ); | 113 &container->af_script_classes_rec[ss++] ); |
85 #ifdef FT_OPTION_AUTOFIT2 | 114 #ifdef FT_OPTION_AUTOFIT2 |
86 FT_Init_Class_af_latin2_script_class( | 115 FT_Init_Class_af_latin2_script_class( |
87 &container->af_script_classes_rec[ss++] ); | 116 &container->af_script_classes_rec[ss++] ); |
88 #endif | 117 #endif |
89 FT_Init_Class_af_latin_script_class( | 118 FT_Init_Class_af_latin_script_class( |
90 &container->af_script_classes_rec[ss++] ); | 119 &container->af_script_classes_rec[ss++] ); |
91 FT_Init_Class_af_cjk_script_class( | 120 FT_Init_Class_af_cjk_script_class( |
92 &container->af_script_classes_rec[ss++] ); | 121 &container->af_script_classes_rec[ss++] ); |
93 FT_Init_Class_af_indic_script_class( | 122 FT_Init_Class_af_indic_script_class( |
94 &container->af_script_classes_rec[ss++] ); | 123 &container->af_script_classes_rec[ss++] ); |
95 | 124 |
96 FT_Init_Class_af_autofitter_service( | 125 FT_Init_Class_af_autofitter_interface( |
97 library, &container->af_autofitter_service ); | 126 library, &container->af_autofitter_interface ); |
98 | 127 |
99 /* Exit: */ | 128 Exit: |
100 | |
101 if ( error ) | 129 if ( error ) |
102 autofit_module_class_pic_free( library ); | 130 autofit_module_class_pic_free( library ); |
103 return error; | 131 return error; |
104 } | 132 } |
105 | 133 |
106 | |
107 #endif /* FT_CONFIG_OPTION_PIC */ | 134 #endif /* FT_CONFIG_OPTION_PIC */ |
108 | 135 |
109 | 136 |
110 /* END */ | 137 /* END */ |
OLD | NEW |