PageRenderTime 343ms CodeModel.GetById 161ms app.highlight 7ms RepoModel.GetById 174ms app.codeStats 0ms

/src/compiler/android-ndk/jni/freetype/src/sfnt/sfntpic.c

http://ftk.googlecode.com/
C | 101 lines | 64 code | 16 blank | 21 comment | 7 complexity | ec49039d981dbcbf5fb84860bd3e5941 MD5 | raw file
  1/***************************************************************************/
  2/*                                                                         */
  3/*  sfntpic.c                                                              */
  4/*                                                                         */
  5/*    The FreeType position independent code services for sfnt module.     */
  6/*                                                                         */
  7/*  Copyright 2009 by                                                      */
  8/*  Oran Agra and Mickey Gabel.                                            */
  9/*                                                                         */
 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.                                        */
 15/*                                                                         */
 16/***************************************************************************/
 17
 18
 19#include <ft2build.h>
 20#include FT_FREETYPE_H
 21#include FT_INTERNAL_OBJECTS_H
 22#include "sfntpic.h"
 23
 24#ifdef FT_CONFIG_OPTION_PIC
 25
 26  /* forward declaration of PIC init functions from sfdriver.c */
 27  FT_Error FT_Create_Class_sfnt_services( FT_Library, FT_ServiceDescRec**);
 28  void FT_Destroy_Class_sfnt_services( FT_Library, FT_ServiceDescRec*);
 29  void FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec*);
 30  void FT_Init_Class_sfnt_interface( FT_Library, SFNT_Interface*);
 31  void FT_Init_Class_sfnt_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
 32  void FT_Init_Class_sfnt_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
 33  void FT_Init_Class_tt_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
 34  void FT_Init_Class_sfnt_service_sfnt_table( FT_Service_SFNT_TableRec*);
 35
 36  /* forward declaration of PIC init functions from ttcmap.c */
 37  FT_Error FT_Create_Class_tt_cmap_classes( FT_Library, TT_CMap_Class**);
 38  void FT_Destroy_Class_tt_cmap_classes( FT_Library, TT_CMap_Class*);
 39
 40  void
 41  sfnt_module_class_pic_free(  FT_Library library )
 42  {
 43    FT_PIC_Container* pic_container = &library->pic_container;
 44    FT_Memory memory = library->memory;
 45    if ( pic_container->sfnt )
 46    {
 47      sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt;
 48      if(container->sfnt_services)
 49        FT_Destroy_Class_sfnt_services(library, container->sfnt_services);
 50      container->sfnt_services = NULL;
 51      if(container->tt_cmap_classes)
 52        FT_Destroy_Class_tt_cmap_classes(library, container->tt_cmap_classes);
 53      container->tt_cmap_classes = NULL;
 54      FT_FREE( container );
 55      pic_container->sfnt = NULL;
 56    }
 57  }
 58
 59
 60  FT_Error
 61  sfnt_module_class_pic_init(  FT_Library library )
 62  {
 63    FT_PIC_Container* pic_container = &library->pic_container;
 64    FT_Error        error = FT_Err_Ok;
 65    sfntModulePIC* container;
 66    FT_Memory memory = library->memory;
 67
 68    /* allocate pointer, clear and set global container pointer */
 69    if ( FT_ALLOC ( container, sizeof ( *container ) ) )
 70      return error;
 71    FT_MEM_SET( container, 0, sizeof(*container) );
 72    pic_container->sfnt = container;
 73
 74    /* initialize pointer table - this is how the module usually expects this data */
 75    error = FT_Create_Class_sfnt_services(library, &container->sfnt_services);
 76    if(error) 
 77      goto Exit;
 78    error = FT_Create_Class_tt_cmap_classes(library, &container->tt_cmap_classes);
 79    if(error) 
 80      goto Exit;
 81    FT_Init_Class_sfnt_service_glyph_dict(library, &container->sfnt_service_glyph_dict);
 82    FT_Init_Class_sfnt_service_ps_name(library, &container->sfnt_service_ps_name);
 83    FT_Init_Class_tt_service_get_cmap_info(library, &container->tt_service_get_cmap_info);
 84    FT_Init_Class_sfnt_service_sfnt_table(&container->sfnt_service_sfnt_table);
 85#ifdef TT_CONFIG_OPTION_BDF
 86    FT_Init_Class_sfnt_service_bdf(&container->sfnt_service_bdf);
 87#endif
 88    FT_Init_Class_sfnt_interface(library, &container->sfnt_interface);
 89
 90Exit:
 91    if(error)
 92      sfnt_module_class_pic_free(library);
 93    return error;
 94  }
 95
 96
 97
 98#endif /* FT_CONFIG_OPTION_PIC */
 99
100
101/* END */