afpic.c

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  afpic.c                                                                */
00004 /*                                                                         */
00005 /*    The FreeType position independent code services for autofit module.  */
00006 /*                                                                         */
00007 /*  Copyright 2009 by                                                      */
00008 /*  Oran Agra and Mickey Gabel.                                            */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /***************************************************************************/
00017 
00018 
00019 #include <ft2build.h>
00020 #include FT_FREETYPE_H
00021 #include FT_INTERNAL_OBJECTS_H
00022 #include "afpic.h"
00023 
00024 #ifdef FT_CONFIG_OPTION_PIC
00025 
00026   /* forward declaration of PIC init functions from afmodule.c */
00027   void FT_Init_Class_af_autofitter_service( FT_Library, FT_AutoHinter_ServiceRec*);
00028 
00029   /* forward declaration of PIC init functions from script classes */
00030 #include "aflatin.h"
00031 #include "aflatin2.h"
00032 #include "afcjk.h"
00033 #include "afdummy.h"
00034 #include "afindic.h"
00035 
00036   void
00037   autofit_module_class_pic_free( FT_Library library )
00038   {
00039     FT_PIC_Container* pic_container = &library->pic_container;
00040     FT_Memory memory = library->memory;
00041     if ( pic_container->autofit )
00042     {
00043       FT_FREE( pic_container->autofit );
00044       pic_container->autofit = NULL;
00045     }
00046   }
00047 
00048   FT_Error
00049   autofit_module_class_pic_init( FT_Library library )
00050   {
00051     FT_PIC_Container* pic_container = &library->pic_container;
00052     FT_UInt         ss;
00053     FT_Error        error = FT_Err_Ok;
00054     AFModulePIC*  container;
00055     FT_Memory memory = library->memory;
00056 
00057     /* allocate pointer, clear and set global container pointer */
00058     if ( FT_ALLOC ( container, sizeof ( *container ) ) )
00059       return error;
00060     FT_MEM_SET( container, 0, sizeof(*container) );
00061     pic_container->autofit = container;
00062 
00063     /* initialize pointer table - this is how the module usually expects this data */
00064     for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
00065     {
00066       container->af_script_classes[ss] = &container->af_script_classes_rec[ss];
00067     }
00068     container->af_script_classes[AF_SCRIPT_CLASSES_COUNT-1] = NULL;
00069     
00070     /* add call to initialization function when you add new scripts */
00071     ss = 0;
00072     FT_Init_Class_af_dummy_script_class(&container->af_script_classes_rec[ss++]);
00073 #ifdef FT_OPTION_AUTOFIT2
00074     FT_Init_Class_af_latin2_script_class(&container->af_script_classes_rec[ss++]);
00075 #endif
00076     FT_Init_Class_af_latin_script_class(&container->af_script_classes_rec[ss++]);
00077     FT_Init_Class_af_cjk_script_class(&container->af_script_classes_rec[ss++]);
00078     FT_Init_Class_af_indic_script_class(&container->af_script_classes_rec[ss++]);    
00079 
00080     FT_Init_Class_af_autofitter_service(library, &container->af_autofitter_service);
00081 
00082 /*Exit:*/
00083     if(error)
00084       autofit_module_class_pic_free(library);
00085     return error;
00086   }
00087 
00088 
00089 #endif /* FT_CONFIG_OPTION_PIC */
00090 
00091 
00092 /* END */

Generated on Tue Jul 5 14:13:42 2011 for ROOT_528-00b_version by  doxygen 1.5.1