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