OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* cffpic.c */ | 3 /* cffpic.c */ |
4 /* */ | 4 /* */ |
5 /* The FreeType position independent code services for cff module. */ | 5 /* The FreeType position independent code services for cff module. */ |
6 /* */ | 6 /* */ |
7 /* Copyright 2009, 2010 by */ | 7 /* Copyright 2009, 2010, 2012, 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 "cffcmap.h" | 22 #include "cffcmap.h" |
23 #include "cffpic.h" | 23 #include "cffpic.h" |
24 #include "cfferrs.h" | 24 #include "cfferrs.h" |
25 | 25 |
| 26 |
26 #ifdef FT_CONFIG_OPTION_PIC | 27 #ifdef FT_CONFIG_OPTION_PIC |
27 | 28 |
28 /* forward declaration of PIC init functions from cffdrivr.c */ | 29 /* forward declaration of PIC init functions from cffdrivr.c */ |
29 FT_Error | 30 FT_Error |
30 FT_Create_Class_cff_services( | 31 FT_Create_Class_cff_services( FT_Library library, |
31 FT_Library library, | 32 FT_ServiceDescRec** output_class ); |
32 FT_ServiceDescRec** output_class ); | |
33 | |
34 void | 33 void |
35 FT_Destroy_Class_cff_services( | 34 FT_Destroy_Class_cff_services( FT_Library library, |
36 FT_Library library, | 35 FT_ServiceDescRec* clazz ); |
37 FT_ServiceDescRec* clazz ); | |
38 | |
39 void | 36 void |
40 FT_Init_Class_cff_service_ps_info( | 37 FT_Init_Class_cff_service_ps_info( FT_Library library, |
41 FT_Library library, | 38 FT_Service_PsInfoRec* clazz ); |
42 FT_Service_PsInfoRec* clazz ); | |
43 | |
44 void | 39 void |
45 FT_Init_Class_cff_service_glyph_dict( | 40 FT_Init_Class_cff_service_glyph_dict( FT_Library library, |
46 FT_Library library, | 41 FT_Service_GlyphDictRec* clazz ); |
47 FT_Service_GlyphDictRec* clazz ); | |
48 | |
49 void | 42 void |
50 FT_Init_Class_cff_service_ps_name( | 43 FT_Init_Class_cff_service_ps_name( FT_Library library, |
51 FT_Library library, | 44 FT_Service_PsFontNameRec* clazz ); |
52 FT_Service_PsFontNameRec* clazz ); | |
53 | |
54 void | 45 void |
55 FT_Init_Class_cff_service_get_cmap_info( | 46 FT_Init_Class_cff_service_get_cmap_info( FT_Library library, |
56 FT_Library library, | 47 FT_Service_TTCMapsRec* clazz ); |
57 FT_Service_TTCMapsRec* clazz ); | |
58 | |
59 void | 48 void |
60 FT_Init_Class_cff_service_cid_info( | 49 FT_Init_Class_cff_service_cid_info( FT_Library library, |
61 FT_Library library, | 50 FT_Service_CIDRec* clazz ); |
62 FT_Service_CIDRec* clazz ); | |
63 | 51 |
64 /* forward declaration of PIC init functions from cffparse.c */ | 52 /* forward declaration of PIC init functions from cffparse.c */ |
65 FT_Error | 53 FT_Error |
66 FT_Create_Class_cff_field_handlers( | 54 FT_Create_Class_cff_field_handlers( FT_Library library, |
67 FT_Library library, | 55 CFF_Field_Handler** output_class ); |
68 CFF_Field_Handler** output_class ); | 56 void |
| 57 FT_Destroy_Class_cff_field_handlers( FT_Library library, |
| 58 CFF_Field_Handler* clazz ); |
69 | 59 |
70 void | |
71 FT_Destroy_Class_cff_field_handlers( | |
72 FT_Library library, | |
73 CFF_Field_Handler* clazz ); | |
74 | 60 |
75 void | 61 void |
76 cff_driver_class_pic_free( FT_Library library ) | 62 cff_driver_class_pic_free( FT_Library library ) |
77 { | 63 { |
78 FT_PIC_Container* pic_container = &library->pic_container; | 64 FT_PIC_Container* pic_container = &library->pic_container; |
79 FT_Memory memory = library->memory; | 65 FT_Memory memory = library->memory; |
80 | 66 |
81 | 67 |
82 if ( pic_container->cff ) | 68 if ( pic_container->cff ) |
83 { | 69 { |
84 CffModulePIC* container = ( CffModulePIC* )pic_container->cff; | 70 CffModulePIC* container = (CffModulePIC*)pic_container->cff; |
85 | 71 |
86 | 72 |
87 if ( container->cff_services ) | 73 if ( container->cff_services ) |
88 FT_Destroy_Class_cff_services( library, | 74 FT_Destroy_Class_cff_services( library, |
89 container->cff_services ); | 75 container->cff_services ); |
90 container->cff_services = NULL; | 76 container->cff_services = NULL; |
91 if ( container->cff_field_handlers ) | 77 if ( container->cff_field_handlers ) |
92 FT_Destroy_Class_cff_field_handlers( | 78 FT_Destroy_Class_cff_field_handlers( |
93 library, container->cff_field_handlers ); | 79 library, container->cff_field_handlers ); |
94 container->cff_field_handlers = NULL; | 80 container->cff_field_handlers = NULL; |
95 FT_FREE( container ); | 81 FT_FREE( container ); |
96 pic_container->cff = NULL; | 82 pic_container->cff = NULL; |
97 } | 83 } |
98 } | 84 } |
99 | 85 |
100 | 86 |
101 FT_Error | 87 FT_Error |
102 cff_driver_class_pic_init( FT_Library library ) | 88 cff_driver_class_pic_init( FT_Library library ) |
103 { | 89 { |
104 FT_PIC_Container* pic_container = &library->pic_container; | 90 FT_PIC_Container* pic_container = &library->pic_container; |
105 FT_Error error = CFF_Err_Ok; | 91 FT_Error error = FT_Err_Ok; |
106 CffModulePIC* container; | 92 CffModulePIC* container = NULL; |
107 FT_Memory memory = library->memory; | 93 FT_Memory memory = library->memory; |
108 | 94 |
109 | 95 |
110 /* allocate pointer, clear and set global container pointer */ | 96 /* allocate pointer, clear and set global container pointer */ |
111 if ( FT_ALLOC ( container, sizeof ( *container ) ) ) | 97 if ( FT_ALLOC ( container, sizeof ( *container ) ) ) |
112 return error; | 98 return error; |
113 FT_MEM_SET( container, 0, sizeof ( *container ) ); | 99 FT_MEM_SET( container, 0, sizeof ( *container ) ); |
114 pic_container->cff = container; | 100 pic_container->cff = container; |
115 | 101 |
116 /* initialize pointer table - this is how the module usually expects this da
ta */ | 102 /* initialize pointer table - */ |
| 103 /* this is how the module usually expects this data */ |
117 error = FT_Create_Class_cff_services( library, | 104 error = FT_Create_Class_cff_services( library, |
118 &container->cff_services ); | 105 &container->cff_services ); |
119 if ( error ) | 106 if ( error ) |
120 goto Exit; | 107 goto Exit; |
| 108 |
121 error = FT_Create_Class_cff_field_handlers( | 109 error = FT_Create_Class_cff_field_handlers( |
122 library, &container->cff_field_handlers ); | 110 library, &container->cff_field_handlers ); |
123 if ( error ) | 111 if ( error ) |
124 goto Exit; | 112 goto Exit; |
| 113 |
125 FT_Init_Class_cff_service_ps_info( | 114 FT_Init_Class_cff_service_ps_info( |
126 library, &container->cff_service_ps_info ); | 115 library, &container->cff_service_ps_info ); |
127 FT_Init_Class_cff_service_glyph_dict( | 116 FT_Init_Class_cff_service_glyph_dict( |
128 library, &container->cff_service_glyph_dict ); | 117 library, &container->cff_service_glyph_dict ); |
129 FT_Init_Class_cff_service_ps_name( | 118 FT_Init_Class_cff_service_ps_name( |
130 library, &container->cff_service_ps_name ); | 119 library, &container->cff_service_ps_name ); |
131 FT_Init_Class_cff_service_get_cmap_info( | 120 FT_Init_Class_cff_service_get_cmap_info( |
132 library, &container->cff_service_get_cmap_info ); | 121 library, &container->cff_service_get_cmap_info ); |
133 FT_Init_Class_cff_service_cid_info( | 122 FT_Init_Class_cff_service_cid_info( |
134 library, &container->cff_service_cid_info ); | 123 library, &container->cff_service_cid_info ); |
135 FT_Init_Class_cff_cmap_encoding_class_rec( | 124 FT_Init_Class_cff_cmap_encoding_class_rec( |
136 library, &container->cff_cmap_encoding_class_rec ); | 125 library, &container->cff_cmap_encoding_class_rec ); |
137 FT_Init_Class_cff_cmap_unicode_class_rec( | 126 FT_Init_Class_cff_cmap_unicode_class_rec( |
138 library, &container->cff_cmap_unicode_class_rec ); | 127 library, &container->cff_cmap_unicode_class_rec ); |
139 Exit: | 128 |
| 129 Exit: |
140 if ( error ) | 130 if ( error ) |
141 cff_driver_class_pic_free( library ); | 131 cff_driver_class_pic_free( library ); |
142 return error; | 132 return error; |
143 } | 133 } |
144 | 134 |
145 #endif /* FT_CONFIG_OPTION_PIC */ | 135 #endif /* FT_CONFIG_OPTION_PIC */ |
146 | 136 |
147 | 137 |
148 /* END */ | 138 /* END */ |
OLD | NEW |