sfntpic.c

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  sfntpic.c                                                              */
00004 /*                                                                         */
00005 /*    The FreeType position independent code services for sfnt 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 "sfntpic.h"
00023 
00024 #ifdef FT_CONFIG_OPTION_PIC
00025 
00026   /* forward declaration of PIC init functions from sfdriver.c */
00027   FT_Error FT_Create_Class_sfnt_services( FT_Library, FT_ServiceDescRec**);
00028   void FT_Destroy_Class_sfnt_services( FT_Library, FT_ServiceDescRec*);
00029   void FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec*);
00030   void FT_Init_Class_sfnt_interface( FT_Library, SFNT_Interface*);
00031   void FT_Init_Class_sfnt_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
00032   void FT_Init_Class_sfnt_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
00033   void FT_Init_Class_tt_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
00034   void FT_Init_Class_sfnt_service_sfnt_table( FT_Service_SFNT_TableRec*);
00035 
00036   /* forward declaration of PIC init functions from ttcmap.c */
00037   FT_Error FT_Create_Class_tt_cmap_classes( FT_Library, TT_CMap_Class**);
00038   void FT_Destroy_Class_tt_cmap_classes( FT_Library, TT_CMap_Class*);
00039 
00040   void
00041   sfnt_module_class_pic_free(  FT_Library library )
00042   {
00043     FT_PIC_Container* pic_container = &library->pic_container;
00044     FT_Memory memory = library->memory;
00045     if ( pic_container->sfnt )
00046     {
00047       sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt;
00048       if(container->sfnt_services)
00049         FT_Destroy_Class_sfnt_services(library, container->sfnt_services);
00050       container->sfnt_services = NULL;
00051       if(container->tt_cmap_classes)
00052         FT_Destroy_Class_tt_cmap_classes(library, container->tt_cmap_classes);
00053       container->tt_cmap_classes = NULL;
00054       FT_FREE( container );
00055       pic_container->sfnt = NULL;
00056     }
00057   }
00058 
00059 
00060   FT_Error
00061   sfnt_module_class_pic_init(  FT_Library library )
00062   {
00063     FT_PIC_Container* pic_container = &library->pic_container;
00064     FT_Error        error = FT_Err_Ok;
00065     sfntModulePIC* container;
00066     FT_Memory memory = library->memory;
00067 
00068     /* allocate pointer, clear and set global container pointer */
00069     if ( FT_ALLOC ( container, sizeof ( *container ) ) )
00070       return error;
00071     FT_MEM_SET( container, 0, sizeof(*container) );
00072     pic_container->sfnt = container;
00073 
00074     /* initialize pointer table - this is how the module usually expects this data */
00075     error = FT_Create_Class_sfnt_services(library, &container->sfnt_services);
00076     if(error) 
00077       goto Exit;
00078     error = FT_Create_Class_tt_cmap_classes(library, &container->tt_cmap_classes);
00079     if(error) 
00080       goto Exit;
00081     FT_Init_Class_sfnt_service_glyph_dict(library, &container->sfnt_service_glyph_dict);
00082     FT_Init_Class_sfnt_service_ps_name(library, &container->sfnt_service_ps_name);
00083     FT_Init_Class_tt_service_get_cmap_info(library, &container->tt_service_get_cmap_info);
00084     FT_Init_Class_sfnt_service_sfnt_table(&container->sfnt_service_sfnt_table);
00085 #ifdef TT_CONFIG_OPTION_BDF
00086     FT_Init_Class_sfnt_service_bdf(&container->sfnt_service_bdf);
00087 #endif
00088     FT_Init_Class_sfnt_interface(library, &container->sfnt_interface);
00089 
00090 Exit:
00091     if(error)
00092       sfnt_module_class_pic_free(library);
00093     return error;
00094   }
00095 
00096 
00097 
00098 #endif /* FT_CONFIG_OPTION_PIC */
00099 
00100 
00101 /* END */

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