/src/freetype/src/truetype/ttpic.c

https://bitbucket.org/cabalistic/ogredeps/ · C · 100 lines · 60 code · 20 blank · 20 comment · 5 complexity · 58826bd846679fb6e05b33be99fd827d MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ttpic.c */
  4. /* */
  5. /* The FreeType position independent code services for truetype 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 "ttpic.h"
  21. #include "tterrors.h"
  22. #ifdef FT_CONFIG_OPTION_PIC
  23. /* forward declaration of PIC init functions from ttdriver.c */
  24. FT_Error
  25. FT_Create_Class_tt_services( FT_Library library,
  26. FT_ServiceDescRec** output_class );
  27. void
  28. FT_Destroy_Class_tt_services( FT_Library library,
  29. FT_ServiceDescRec* clazz );
  30. void
  31. FT_Init_Class_tt_service_gx_multi_masters(
  32. FT_Service_MultiMastersRec* sv_mm );
  33. void
  34. FT_Init_Class_tt_service_truetype_glyf(
  35. FT_Service_TTGlyfRec* sv_ttglyf );
  36. void
  37. tt_driver_class_pic_free( FT_Library library )
  38. {
  39. FT_PIC_Container* pic_container = &library->pic_container;
  40. FT_Memory memory = library->memory;
  41. if ( pic_container->truetype )
  42. {
  43. TTModulePIC* container = (TTModulePIC*)pic_container->truetype;
  44. if ( container->tt_services )
  45. FT_Destroy_Class_tt_services( library, container->tt_services );
  46. container->tt_services = NULL;
  47. FT_FREE( container );
  48. pic_container->truetype = NULL;
  49. }
  50. }
  51. FT_Error
  52. tt_driver_class_pic_init( FT_Library library )
  53. {
  54. FT_PIC_Container* pic_container = &library->pic_container;
  55. FT_Error error = TT_Err_Ok;
  56. TTModulePIC* container;
  57. FT_Memory memory = library->memory;
  58. /* allocate pointer, clear and set global container pointer */
  59. if ( FT_ALLOC ( container, sizeof ( *container ) ) )
  60. return error;
  61. FT_MEM_SET( container, 0, sizeof ( *container ) );
  62. pic_container->truetype = container;
  63. /* initialize pointer table - this is how the module usually expects this data */
  64. error = FT_Create_Class_tt_services( library,
  65. &container->tt_services );
  66. if ( error )
  67. goto Exit;
  68. #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
  69. FT_Init_Class_tt_service_gx_multi_masters(
  70. &container->tt_service_gx_multi_masters );
  71. #endif
  72. FT_Init_Class_tt_service_truetype_glyf(
  73. &container->tt_service_truetype_glyf );
  74. Exit:
  75. if ( error )
  76. tt_driver_class_pic_free( library );
  77. return error;
  78. }
  79. #endif /* FT_CONFIG_OPTION_PIC */
  80. /* END */