/src/freetype/src/sfnt/sfntpic.c

https://bitbucket.org/cabalistic/ogredeps/ · C · 146 lines · 95 code · 30 blank · 21 comment · 7 complexity · 4c7380c6e0f687fa3915f42fce6c2063 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. #include "sferrors.h"
  22. #ifdef FT_CONFIG_OPTION_PIC
  23. /* forward declaration of PIC init functions from sfdriver.c */
  24. FT_Error
  25. FT_Create_Class_sfnt_services( FT_Library library,
  26. FT_ServiceDescRec** ouput_class );
  27. void
  28. FT_Destroy_Class_sfnt_services( FT_Library library,
  29. FT_ServiceDescRec* clazz );
  30. void
  31. FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec* clazz );
  32. void
  33. FT_Init_Class_sfnt_interface( FT_Library library,
  34. SFNT_Interface* clazz );
  35. void
  36. FT_Init_Class_sfnt_service_glyph_dict(
  37. FT_Library library,
  38. FT_Service_GlyphDictRec* clazz );
  39. void
  40. FT_Init_Class_sfnt_service_ps_name(
  41. FT_Library library,
  42. FT_Service_PsFontNameRec* clazz );
  43. void
  44. FT_Init_Class_tt_service_get_cmap_info(
  45. FT_Library library,
  46. FT_Service_TTCMapsRec* clazz );
  47. void
  48. FT_Init_Class_sfnt_service_sfnt_table(
  49. FT_Service_SFNT_TableRec* clazz );
  50. /* forward declaration of PIC init functions from ttcmap.c */
  51. FT_Error
  52. FT_Create_Class_tt_cmap_classes( FT_Library library,
  53. TT_CMap_Class** output_class );
  54. void
  55. FT_Destroy_Class_tt_cmap_classes( FT_Library library,
  56. TT_CMap_Class* clazz );
  57. void
  58. sfnt_module_class_pic_free( FT_Library library )
  59. {
  60. FT_PIC_Container* pic_container = &library->pic_container;
  61. FT_Memory memory = library->memory;
  62. if ( pic_container->sfnt )
  63. {
  64. sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt;
  65. if ( container->sfnt_services )
  66. FT_Destroy_Class_sfnt_services( library,
  67. container->sfnt_services );
  68. container->sfnt_services = NULL;
  69. if ( container->tt_cmap_classes )
  70. FT_Destroy_Class_tt_cmap_classes( library,
  71. container->tt_cmap_classes );
  72. container->tt_cmap_classes = NULL;
  73. FT_FREE( container );
  74. pic_container->sfnt = NULL;
  75. }
  76. }
  77. FT_Error
  78. sfnt_module_class_pic_init( FT_Library library )
  79. {
  80. FT_PIC_Container* pic_container = &library->pic_container;
  81. FT_Error error = SFNT_Err_Ok;
  82. sfntModulePIC* container;
  83. FT_Memory memory = library->memory;
  84. /* allocate pointer, clear and set global container pointer */
  85. if ( FT_ALLOC ( container, sizeof ( *container ) ) )
  86. return error;
  87. FT_MEM_SET( container, 0, sizeof ( *container ) );
  88. pic_container->sfnt = container;
  89. /* initialize pointer table - this is how the module usually expects this data */
  90. error = FT_Create_Class_sfnt_services( library,
  91. &container->sfnt_services );
  92. if ( error )
  93. goto Exit;
  94. error = FT_Create_Class_tt_cmap_classes( library,
  95. &container->tt_cmap_classes );
  96. if ( error )
  97. goto Exit;
  98. FT_Init_Class_sfnt_service_glyph_dict(
  99. library, &container->sfnt_service_glyph_dict );
  100. FT_Init_Class_sfnt_service_ps_name(
  101. library, &container->sfnt_service_ps_name );
  102. FT_Init_Class_tt_service_get_cmap_info(
  103. library, &container->tt_service_get_cmap_info );
  104. FT_Init_Class_sfnt_service_sfnt_table(
  105. &container->sfnt_service_sfnt_table );
  106. #ifdef TT_CONFIG_OPTION_BDF
  107. FT_Init_Class_sfnt_service_bdf( &container->sfnt_service_bdf );
  108. #endif
  109. FT_Init_Class_sfnt_interface( library, &container->sfnt_interface );
  110. Exit:
  111. if ( error )
  112. sfnt_module_class_pic_free( library );
  113. return error;
  114. }
  115. #endif /* FT_CONFIG_OPTION_PIC */
  116. /* END */