/src/freetype/src/base/basepic.c

https://bitbucket.org/cabalistic/ogredeps/ · C · 93 lines · 50 code · 19 blank · 24 comment · 4 complexity · f082961543e86320f54588521ad20516 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* basepic.c */
  4. /* */
  5. /* The FreeType position independent code services for base. */
  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. #include <ft2build.h>
  18. #include FT_FREETYPE_H
  19. #include FT_INTERNAL_OBJECTS_H
  20. #include "basepic.h"
  21. #ifdef FT_CONFIG_OPTION_PIC
  22. /* forward declaration of PIC init functions from ftglyph.c */
  23. void FT_Init_Class_ft_outline_glyph_class( FT_Glyph_Class* clazz );
  24. void FT_Init_Class_ft_bitmap_glyph_class( FT_Glyph_Class* clazz );
  25. /* forward declaration of PIC init function from ftrfork.c (not modularized) */
  26. void FT_Init_Table_raccess_guess_table( ft_raccess_guess_rec* record );
  27. /* forward declaration of PIC init functions from ftinit.c */
  28. FT_Error
  29. ft_create_default_module_classes( FT_Library library );
  30. void
  31. ft_destroy_default_module_classes( FT_Library library );
  32. void
  33. ft_base_pic_free( FT_Library library )
  34. {
  35. FT_PIC_Container* pic_container = &library->pic_container;
  36. FT_Memory memory = library->memory;
  37. if ( pic_container->base )
  38. {
  39. /* Destroy default module classes (in case FT_Add_Default_Modules was used) */
  40. ft_destroy_default_module_classes( library );
  41. FT_FREE( pic_container->base );
  42. pic_container->base = NULL;
  43. }
  44. }
  45. FT_Error
  46. ft_base_pic_init( FT_Library library )
  47. {
  48. FT_PIC_Container* pic_container = &library->pic_container;
  49. FT_Error error = FT_Err_Ok;
  50. BasePIC* container;
  51. FT_Memory memory = library->memory;
  52. /* allocate pointer, clear and set global container pointer */
  53. if ( FT_ALLOC ( container, sizeof ( *container ) ) )
  54. return error;
  55. FT_MEM_SET( container, 0, sizeof ( *container ) );
  56. pic_container->base = container;
  57. /* initialize default modules list and pointers */
  58. error = ft_create_default_module_classes( library );
  59. if ( error )
  60. goto Exit;
  61. /* initialize pointer table - this is how the module usually expects this data */
  62. FT_Init_Class_ft_outline_glyph_class(
  63. &container->ft_outline_glyph_class );
  64. FT_Init_Class_ft_bitmap_glyph_class(
  65. &container->ft_bitmap_glyph_class );
  66. FT_Init_Table_raccess_guess_table(
  67. (ft_raccess_guess_rec*)&container->ft_raccess_guess_table);
  68. Exit:
  69. if( error )
  70. ft_base_pic_free( library );
  71. return error;
  72. }
  73. #endif /* FT_CONFIG_OPTION_PIC */
  74. /* END */