OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* sfntpic.c */ | 3 /* sfntpic.c */ |
4 /* */ | 4 /* */ |
5 /* The FreeType position independent code services for sfnt module. */ | 5 /* The FreeType position independent code services for sfnt 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 "sfntpic.h" | 22 #include "sfntpic.h" |
23 #include "sferrors.h" | 23 #include "sferrors.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 sfdriver.c */ | 28 /* forward declaration of PIC init functions from sfdriver.c */ |
28 FT_Error | 29 FT_Error |
29 FT_Create_Class_sfnt_services( FT_Library library, | 30 FT_Create_Class_sfnt_services( FT_Library library, |
30 FT_ServiceDescRec** ouput_class ); | 31 FT_ServiceDescRec** output_class ); |
31 | |
32 void | 32 void |
33 FT_Destroy_Class_sfnt_services( FT_Library library, | 33 FT_Destroy_Class_sfnt_services( FT_Library library, |
34 FT_ServiceDescRec* clazz ); | 34 FT_ServiceDescRec* clazz ); |
35 | |
36 void | 35 void |
37 FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec* clazz ); | 36 FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec* clazz ); |
38 | |
39 void | 37 void |
40 FT_Init_Class_sfnt_interface( FT_Library library, | 38 FT_Init_Class_sfnt_interface( FT_Library library, |
41 SFNT_Interface* clazz ); | 39 SFNT_Interface* clazz ); |
42 | |
43 void | 40 void |
44 FT_Init_Class_sfnt_service_glyph_dict( | 41 FT_Init_Class_sfnt_service_glyph_dict( |
45 FT_Library library, | 42 FT_Library library, |
46 FT_Service_GlyphDictRec* clazz ); | 43 FT_Service_GlyphDictRec* clazz ); |
47 | |
48 void | 44 void |
49 FT_Init_Class_sfnt_service_ps_name( | 45 FT_Init_Class_sfnt_service_ps_name( |
50 FT_Library library, | 46 FT_Library library, |
51 FT_Service_PsFontNameRec* clazz ); | 47 FT_Service_PsFontNameRec* clazz ); |
52 | |
53 void | 48 void |
54 FT_Init_Class_tt_service_get_cmap_info( | 49 FT_Init_Class_tt_service_get_cmap_info( |
55 FT_Library library, | 50 FT_Library library, |
56 FT_Service_TTCMapsRec* clazz ); | 51 FT_Service_TTCMapsRec* clazz ); |
57 | |
58 void | 52 void |
59 FT_Init_Class_sfnt_service_sfnt_table( | 53 FT_Init_Class_sfnt_service_sfnt_table( |
60 FT_Service_SFNT_TableRec* clazz ); | 54 FT_Service_SFNT_TableRec* clazz ); |
61 | 55 |
| 56 |
62 /* forward declaration of PIC init functions from ttcmap.c */ | 57 /* forward declaration of PIC init functions from ttcmap.c */ |
63 FT_Error | 58 FT_Error |
64 FT_Create_Class_tt_cmap_classes( FT_Library library, | 59 FT_Create_Class_tt_cmap_classes( FT_Library library, |
65 TT_CMap_Class** output_class ); | 60 TT_CMap_Class** output_class ); |
66 | |
67 void | 61 void |
68 FT_Destroy_Class_tt_cmap_classes( FT_Library library, | 62 FT_Destroy_Class_tt_cmap_classes( FT_Library library, |
69 TT_CMap_Class* clazz ); | 63 TT_CMap_Class* clazz ); |
70 | 64 |
| 65 |
71 void | 66 void |
72 sfnt_module_class_pic_free( FT_Library library ) | 67 sfnt_module_class_pic_free( FT_Library library ) |
73 { | 68 { |
74 FT_PIC_Container* pic_container = &library->pic_container; | 69 FT_PIC_Container* pic_container = &library->pic_container; |
75 FT_Memory memory = library->memory; | 70 FT_Memory memory = library->memory; |
76 | 71 |
77 | 72 |
78 if ( pic_container->sfnt ) | 73 if ( pic_container->sfnt ) |
79 { | 74 { |
80 sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt; | 75 sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt; |
81 | 76 |
82 | 77 |
83 if ( container->sfnt_services ) | 78 if ( container->sfnt_services ) |
84 FT_Destroy_Class_sfnt_services( library, | 79 FT_Destroy_Class_sfnt_services( library, |
85 container->sfnt_services ); | 80 container->sfnt_services ); |
86 container->sfnt_services = NULL; | 81 container->sfnt_services = NULL; |
| 82 |
87 if ( container->tt_cmap_classes ) | 83 if ( container->tt_cmap_classes ) |
88 FT_Destroy_Class_tt_cmap_classes( library, | 84 FT_Destroy_Class_tt_cmap_classes( library, |
89 container->tt_cmap_classes ); | 85 container->tt_cmap_classes ); |
90 container->tt_cmap_classes = NULL; | 86 container->tt_cmap_classes = NULL; |
| 87 |
91 FT_FREE( container ); | 88 FT_FREE( container ); |
92 pic_container->sfnt = NULL; | 89 pic_container->sfnt = NULL; |
93 } | 90 } |
94 } | 91 } |
95 | 92 |
96 | 93 |
97 FT_Error | 94 FT_Error |
98 sfnt_module_class_pic_init( FT_Library library ) | 95 sfnt_module_class_pic_init( FT_Library library ) |
99 { | 96 { |
100 FT_PIC_Container* pic_container = &library->pic_container; | 97 FT_PIC_Container* pic_container = &library->pic_container; |
101 FT_Error error = SFNT_Err_Ok; | 98 FT_Error error = FT_Err_Ok; |
102 sfntModulePIC* container; | 99 sfntModulePIC* container = NULL; |
103 FT_Memory memory = library->memory; | 100 FT_Memory memory = library->memory; |
104 | 101 |
105 | 102 |
106 /* allocate pointer, clear and set global container pointer */ | 103 /* allocate pointer, clear and set global container pointer */ |
107 if ( FT_ALLOC ( container, sizeof ( *container ) ) ) | 104 if ( FT_ALLOC( container, sizeof ( *container ) ) ) |
108 return error; | 105 return error; |
109 FT_MEM_SET( container, 0, sizeof ( *container ) ); | 106 FT_MEM_SET( container, 0, sizeof ( *container ) ); |
110 pic_container->sfnt = container; | 107 pic_container->sfnt = container; |
111 | 108 |
112 /* initialize pointer table - this is how the module usually expects this da
ta */ | 109 /* initialize pointer table - */ |
| 110 /* this is how the module usually expects this data */ |
113 error = FT_Create_Class_sfnt_services( library, | 111 error = FT_Create_Class_sfnt_services( library, |
114 &container->sfnt_services ); | 112 &container->sfnt_services ); |
115 if ( error ) | 113 if ( error ) |
116 goto Exit; | 114 goto Exit; |
| 115 |
117 error = FT_Create_Class_tt_cmap_classes( library, | 116 error = FT_Create_Class_tt_cmap_classes( library, |
118 &container->tt_cmap_classes ); | 117 &container->tt_cmap_classes ); |
119 if ( error ) | 118 if ( error ) |
120 goto Exit; | 119 goto Exit; |
121 | 120 |
122 FT_Init_Class_sfnt_service_glyph_dict( | 121 FT_Init_Class_sfnt_service_glyph_dict( |
123 library, &container->sfnt_service_glyph_dict ); | 122 library, &container->sfnt_service_glyph_dict ); |
124 FT_Init_Class_sfnt_service_ps_name( | 123 FT_Init_Class_sfnt_service_ps_name( |
125 library, &container->sfnt_service_ps_name ); | 124 library, &container->sfnt_service_ps_name ); |
126 FT_Init_Class_tt_service_get_cmap_info( | 125 FT_Init_Class_tt_service_get_cmap_info( |
127 library, &container->tt_service_get_cmap_info ); | 126 library, &container->tt_service_get_cmap_info ); |
128 FT_Init_Class_sfnt_service_sfnt_table( | 127 FT_Init_Class_sfnt_service_sfnt_table( |
129 &container->sfnt_service_sfnt_table ); | 128 &container->sfnt_service_sfnt_table ); |
130 #ifdef TT_CONFIG_OPTION_BDF | 129 #ifdef TT_CONFIG_OPTION_BDF |
131 FT_Init_Class_sfnt_service_bdf( &container->sfnt_service_bdf ); | 130 FT_Init_Class_sfnt_service_bdf( &container->sfnt_service_bdf ); |
132 #endif | 131 #endif |
133 FT_Init_Class_sfnt_interface( library, &container->sfnt_interface ); | 132 FT_Init_Class_sfnt_interface( library, &container->sfnt_interface ); |
134 | 133 |
135 Exit: | 134 Exit: |
136 if ( error ) | 135 if ( error ) |
137 sfnt_module_class_pic_free( library ); | 136 sfnt_module_class_pic_free( library ); |
138 return error; | 137 return error; |
139 } | 138 } |
140 | 139 |
141 | |
142 | |
143 #endif /* FT_CONFIG_OPTION_PIC */ | 140 #endif /* FT_CONFIG_OPTION_PIC */ |
144 | 141 |
145 | 142 |
146 /* END */ | 143 /* END */ |
OLD | NEW |