/modules/freetype2/src/sfnt/sfntpic.c

http://github.com/zpao/v8monkey · C · 102 lines · 64 code · 17 blank · 21 comment · 7 complexity · 46421ad16f150f1461966fb0ff625ff0 MD5 · raw file

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