/src/freetype/src/cff/cffpic.c

https://bitbucket.org/cabalistic/ogredeps/ · C · 148 lines · 102 code · 25 blank · 21 comment · 7 complexity · 331a84865252966c20e5cede230c6b50 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* cffpic.c */
  4. /* */
  5. /* The FreeType position independent code services for cff 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 "cffcmap.h"
  21. #include "cffpic.h"
  22. #include "cfferrs.h"
  23. #ifdef FT_CONFIG_OPTION_PIC
  24. /* forward declaration of PIC init functions from cffdrivr.c */
  25. FT_Error
  26. FT_Create_Class_cff_services(
  27. FT_Library library,
  28. FT_ServiceDescRec** output_class );
  29. void
  30. FT_Destroy_Class_cff_services(
  31. FT_Library library,
  32. FT_ServiceDescRec* clazz );
  33. void
  34. FT_Init_Class_cff_service_ps_info(
  35. FT_Library library,
  36. FT_Service_PsInfoRec* clazz );
  37. void
  38. FT_Init_Class_cff_service_glyph_dict(
  39. FT_Library library,
  40. FT_Service_GlyphDictRec* clazz );
  41. void
  42. FT_Init_Class_cff_service_ps_name(
  43. FT_Library library,
  44. FT_Service_PsFontNameRec* clazz );
  45. void
  46. FT_Init_Class_cff_service_get_cmap_info(
  47. FT_Library library,
  48. FT_Service_TTCMapsRec* clazz );
  49. void
  50. FT_Init_Class_cff_service_cid_info(
  51. FT_Library library,
  52. FT_Service_CIDRec* clazz );
  53. /* forward declaration of PIC init functions from cffparse.c */
  54. FT_Error
  55. FT_Create_Class_cff_field_handlers(
  56. FT_Library library,
  57. CFF_Field_Handler** output_class );
  58. void
  59. FT_Destroy_Class_cff_field_handlers(
  60. FT_Library library,
  61. CFF_Field_Handler* clazz );
  62. void
  63. cff_driver_class_pic_free( FT_Library library )
  64. {
  65. FT_PIC_Container* pic_container = &library->pic_container;
  66. FT_Memory memory = library->memory;
  67. if ( pic_container->cff )
  68. {
  69. CffModulePIC* container = ( CffModulePIC* )pic_container->cff;
  70. if ( container->cff_services )
  71. FT_Destroy_Class_cff_services( library,
  72. container->cff_services );
  73. container->cff_services = NULL;
  74. if ( container->cff_field_handlers )
  75. FT_Destroy_Class_cff_field_handlers(
  76. library, container->cff_field_handlers );
  77. container->cff_field_handlers = NULL;
  78. FT_FREE( container );
  79. pic_container->cff = NULL;
  80. }
  81. }
  82. FT_Error
  83. cff_driver_class_pic_init( FT_Library library )
  84. {
  85. FT_PIC_Container* pic_container = &library->pic_container;
  86. FT_Error error = CFF_Err_Ok;
  87. CffModulePIC* container;
  88. FT_Memory memory = library->memory;
  89. /* allocate pointer, clear and set global container pointer */
  90. if ( FT_ALLOC ( container, sizeof ( *container ) ) )
  91. return error;
  92. FT_MEM_SET( container, 0, sizeof ( *container ) );
  93. pic_container->cff = container;
  94. /* initialize pointer table - this is how the module usually expects this data */
  95. error = FT_Create_Class_cff_services( library,
  96. &container->cff_services );
  97. if ( error )
  98. goto Exit;
  99. error = FT_Create_Class_cff_field_handlers(
  100. library, &container->cff_field_handlers );
  101. if ( error )
  102. goto Exit;
  103. FT_Init_Class_cff_service_ps_info(
  104. library, &container->cff_service_ps_info );
  105. FT_Init_Class_cff_service_glyph_dict(
  106. library, &container->cff_service_glyph_dict );
  107. FT_Init_Class_cff_service_ps_name(
  108. library, &container->cff_service_ps_name );
  109. FT_Init_Class_cff_service_get_cmap_info(
  110. library, &container->cff_service_get_cmap_info );
  111. FT_Init_Class_cff_service_cid_info(
  112. library, &container->cff_service_cid_info );
  113. FT_Init_Class_cff_cmap_encoding_class_rec(
  114. library, &container->cff_cmap_encoding_class_rec );
  115. FT_Init_Class_cff_cmap_unicode_class_rec(
  116. library, &container->cff_cmap_unicode_class_rec );
  117. Exit:
  118. if ( error )
  119. cff_driver_class_pic_free( library );
  120. return error;
  121. }
  122. #endif /* FT_CONFIG_OPTION_PIC */
  123. /* END */