1 /***************************************************************************/
5 /* The FreeType position independent code services for autofit module. */
7 /* Copyright 2009-2014 by */
8 /* Oran Agra and Mickey Gabel. */
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 */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
20 #include FT_FREETYPE_H
21 #include FT_INTERNAL_OBJECTS_H
27 #ifdef FT_CONFIG_OPTION_PIC
29 /* forward declaration of PIC init functions from afmodule.c */
31 FT_Create_Class_af_services( FT_Library library,
32 FT_ServiceDescRec** output_class );
35 FT_Destroy_Class_af_services( FT_Library library,
36 FT_ServiceDescRec* clazz );
39 FT_Init_Class_af_service_properties( FT_Service_PropertiesRec* clazz );
41 void FT_Init_Class_af_autofitter_interface(
43 FT_AutoHinter_InterfaceRec* clazz );
46 /* forward declaration of PIC init functions from writing system classes */
48 #define WRITING_SYSTEM( ws, WS ) /* empty */
54 autofit_module_class_pic_free( FT_Library library )
56 FT_PIC_Container* pic_container = &library->pic_container;
57 FT_Memory memory = library->memory;
60 if ( pic_container->autofit )
62 AFModulePIC* container = (AFModulePIC*)pic_container->autofit;
65 if ( container->af_services )
66 FT_Destroy_Class_af_services( library,
67 container->af_services );
68 container->af_services = NULL;
71 pic_container->autofit = NULL;
77 autofit_module_class_pic_init( FT_Library library )
79 FT_PIC_Container* pic_container = &library->pic_container;
81 FT_Error error = FT_Err_Ok;
82 AFModulePIC* container = NULL;
83 FT_Memory memory = library->memory;
86 /* allocate pointer, clear and set global container pointer */
87 if ( FT_ALLOC ( container, sizeof ( *container ) ) )
89 FT_MEM_SET( container, 0, sizeof ( *container ) );
90 pic_container->autofit = container;
92 /* initialize pointer table - */
93 /* this is how the module usually expects this data */
94 error = FT_Create_Class_af_services( library,
95 &container->af_services );
99 FT_Init_Class_af_service_properties( &container->af_service_properties );
101 for ( ss = 0; ss < AF_WRITING_SYSTEM_MAX; ss++ )
102 container->af_writing_system_classes[ss] =
103 &container->af_writing_system_classes_rec[ss];
104 container->af_writing_system_classes[AF_WRITING_SYSTEM_MAX] = NULL;
106 for ( ss = 0; ss < AF_SCRIPT_MAX; ss++ )
107 container->af_script_classes[ss] =
108 &container->af_script_classes_rec[ss];
109 container->af_script_classes[AF_SCRIPT_MAX] = NULL;
111 for ( ss = 0; ss < AF_STYLE_MAX; ss++ )
112 container->af_style_classes[ss] =
113 &container->af_style_classes_rec[ss];
114 container->af_style_classes[AF_STYLE_MAX] = NULL;
116 #undef WRITING_SYSTEM
117 #define WRITING_SYSTEM( ws, WS ) \
118 FT_Init_Class_af_ ## ws ## _writing_system_class( \
119 &container->af_writing_system_classes_rec[ss++] );
122 #include "afwrtsys.h"
125 #define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
126 FT_Init_Class_af_ ## s ## _script_class( \
127 &container->af_script_classes_rec[ss++] );
130 #include "afscript.h"
133 #define STYLE( s, S, d, ws, sc, bss, c ) \
134 FT_Init_Class_af_ ## s ## _style_class( \
135 &container->af_style_classes_rec[ss++] );
138 #include "afstyles.h"
140 FT_Init_Class_af_autofitter_interface(
141 library, &container->af_autofitter_interface );
145 autofit_module_class_pic_free( library );
149 #endif /* FT_CONFIG_OPTION_PIC */