OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ttpic.c */ | 3 /* ttpic.c */ |
4 /* */ | 4 /* */ |
5 /* The FreeType position independent code services for truetype module. */ | 5 /* The FreeType position independent code services for truetype 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 "ttpic.h" | 22 #include "ttpic.h" |
23 #include "tterrors.h" | 23 #include "tterrors.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 ttdriver.c */ | 28 /* forward declaration of PIC init functions from ttdriver.c */ |
28 FT_Error | 29 FT_Error |
29 FT_Create_Class_tt_services( FT_Library library, | 30 FT_Create_Class_tt_services( FT_Library library, |
30 FT_ServiceDescRec** output_class ); | 31 FT_ServiceDescRec** output_class ); |
31 | |
32 void | 32 void |
33 FT_Destroy_Class_tt_services( FT_Library library, | 33 FT_Destroy_Class_tt_services( FT_Library library, |
34 FT_ServiceDescRec* clazz ); | 34 FT_ServiceDescRec* clazz ); |
35 | |
36 void | 35 void |
37 FT_Init_Class_tt_service_gx_multi_masters( | 36 FT_Init_Class_tt_service_gx_multi_masters( |
38 FT_Service_MultiMastersRec* sv_mm ); | 37 FT_Service_MultiMastersRec* sv_mm ); |
39 | |
40 void | 38 void |
41 FT_Init_Class_tt_service_truetype_glyf( | 39 FT_Init_Class_tt_service_truetype_glyf( |
42 FT_Service_TTGlyfRec* sv_ttglyf ); | 40 FT_Service_TTGlyfRec* sv_ttglyf ); |
43 | 41 |
| 42 |
44 void | 43 void |
45 tt_driver_class_pic_free( FT_Library library ) | 44 tt_driver_class_pic_free( FT_Library library ) |
46 { | 45 { |
47 FT_PIC_Container* pic_container = &library->pic_container; | 46 FT_PIC_Container* pic_container = &library->pic_container; |
48 FT_Memory memory = library->memory; | 47 FT_Memory memory = library->memory; |
49 | 48 |
50 | 49 |
51 if ( pic_container->truetype ) | 50 if ( pic_container->truetype ) |
52 { | 51 { |
53 TTModulePIC* container = (TTModulePIC*)pic_container->truetype; | 52 TTModulePIC* container = (TTModulePIC*)pic_container->truetype; |
54 | 53 |
55 | 54 |
56 if ( container->tt_services ) | 55 if ( container->tt_services ) |
57 FT_Destroy_Class_tt_services( library, container->tt_services ); | 56 FT_Destroy_Class_tt_services( library, container->tt_services ); |
58 container->tt_services = NULL; | 57 container->tt_services = NULL; |
59 FT_FREE( container ); | 58 FT_FREE( container ); |
60 pic_container->truetype = NULL; | 59 pic_container->truetype = NULL; |
61 } | 60 } |
62 } | 61 } |
63 | 62 |
64 | 63 |
65 FT_Error | 64 FT_Error |
66 tt_driver_class_pic_init( FT_Library library ) | 65 tt_driver_class_pic_init( FT_Library library ) |
67 { | 66 { |
68 FT_PIC_Container* pic_container = &library->pic_container; | 67 FT_PIC_Container* pic_container = &library->pic_container; |
69 FT_Error error = TT_Err_Ok; | 68 FT_Error error = FT_Err_Ok; |
70 TTModulePIC* container; | 69 TTModulePIC* container = NULL; |
71 FT_Memory memory = library->memory; | 70 FT_Memory memory = library->memory; |
72 | 71 |
73 | 72 |
74 /* allocate pointer, clear and set global container pointer */ | 73 /* allocate pointer, clear and set global container pointer */ |
75 if ( FT_ALLOC ( container, sizeof ( *container ) ) ) | 74 if ( FT_ALLOC( container, sizeof ( *container ) ) ) |
76 return error; | 75 return error; |
77 FT_MEM_SET( container, 0, sizeof ( *container ) ); | 76 FT_MEM_SET( container, 0, sizeof ( *container ) ); |
78 pic_container->truetype = container; | 77 pic_container->truetype = container; |
79 | 78 |
80 /* initialize pointer table - this is how the module usually expects this da
ta */ | 79 /* initialize pointer table - this is how the module usually */ |
| 80 /* expects this data */ |
81 error = FT_Create_Class_tt_services( library, | 81 error = FT_Create_Class_tt_services( library, |
82 &container->tt_services ); | 82 &container->tt_services ); |
83 if ( error ) | 83 if ( error ) |
84 goto Exit; | 84 goto Exit; |
85 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT | 85 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT |
86 FT_Init_Class_tt_service_gx_multi_masters( | 86 FT_Init_Class_tt_service_gx_multi_masters( |
87 &container->tt_service_gx_multi_masters ); | 87 &container->tt_service_gx_multi_masters ); |
88 #endif | 88 #endif |
89 FT_Init_Class_tt_service_truetype_glyf( | 89 FT_Init_Class_tt_service_truetype_glyf( |
90 &container->tt_service_truetype_glyf ); | 90 &container->tt_service_truetype_glyf ); |
91 Exit: | 91 |
| 92 Exit: |
92 if ( error ) | 93 if ( error ) |
93 tt_driver_class_pic_free( library ); | 94 tt_driver_class_pic_free( library ); |
94 return error; | 95 return error; |
95 } | 96 } |
96 | 97 |
97 #endif /* FT_CONFIG_OPTION_PIC */ | 98 #endif /* FT_CONFIG_OPTION_PIC */ |
98 | 99 |
99 | 100 |
100 /* END */ | 101 /* END */ |
OLD | NEW |