/src/compiler/android-ndk/jni/freetype/src/base/basepic.c

http://ftk.googlecode.com/ · C · 83 lines · 43 code · 17 blank · 23 comment · 4 complexity · 9a1ef4a8f7da44d6317de9b917df9bfe 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*);
  24. void FT_Init_Class_ft_bitmap_glyph_class(FT_Glyph_Class*);
  25. /* forward declaration of PIC init functions from ftinit.c */
  26. FT_Error ft_create_default_module_classes(FT_Library);
  27. void ft_destroy_default_module_classes(FT_Library);
  28. void
  29. ft_base_pic_free( FT_Library library )
  30. {
  31. FT_PIC_Container* pic_container = &library->pic_container;
  32. FT_Memory memory = library->memory;
  33. if ( pic_container->base )
  34. {
  35. /* Destroy default module classes (in case FT_Add_Default_Modules was used) */
  36. ft_destroy_default_module_classes( library );
  37. FT_FREE( pic_container->base );
  38. pic_container->base = NULL;
  39. }
  40. }
  41. FT_Error
  42. ft_base_pic_init( FT_Library library )
  43. {
  44. FT_PIC_Container* pic_container = &library->pic_container;
  45. FT_Error error = FT_Err_Ok;
  46. BasePIC* container;
  47. FT_Memory memory = library->memory;
  48. /* allocate pointer, clear and set global container pointer */
  49. if ( FT_ALLOC ( container, sizeof ( *container ) ) )
  50. return error;
  51. FT_MEM_SET( container, 0, sizeof(*container) );
  52. pic_container->base = container;
  53. /* initialize default modules list and pointers */
  54. error = ft_create_default_module_classes( library );
  55. if ( error )
  56. goto Exit;
  57. /* initialize pointer table - this is how the module usually expects this data */
  58. FT_Init_Class_ft_outline_glyph_class(&container->ft_outline_glyph_class);
  59. FT_Init_Class_ft_bitmap_glyph_class(&container->ft_bitmap_glyph_class);
  60. Exit:
  61. if(error)
  62. ft_base_pic_free(library);
  63. return error;
  64. }
  65. #endif /* FT_CONFIG_OPTION_PIC */
  66. /* END */