/src/freetype/src/autofit/afpic.c

https://bitbucket.org/cabalistic/ogredeps/ · C · 110 lines · 65 code · 21 blank · 24 comment · 4 complexity · db4fa7d4c089ae7805215056d30b2af7 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* afpic.c */
  4. /* */
  5. /* The FreeType position independent code services for autofit module. */
  6. /* */
  7. /* Copyright 2009, 2010, 2011 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 "afpic.h"
  21. #include "aferrors.h"
  22. #ifdef FT_CONFIG_OPTION_PIC
  23. /* forward declaration of PIC init functions from afmodule.c */
  24. void FT_Init_Class_af_autofitter_service(
  25. FT_Library library,
  26. FT_AutoHinter_ServiceRec* clazz );
  27. /* forward declaration of PIC init functions from script classes */
  28. #include "aflatin.h"
  29. #ifdef FT_OPTION_AUTOFIT2
  30. #include "aflatin2.h"
  31. #endif
  32. #include "afcjk.h"
  33. #include "afdummy.h"
  34. #include "afindic.h"
  35. void
  36. autofit_module_class_pic_free( FT_Library library )
  37. {
  38. FT_PIC_Container* pic_container = &library->pic_container;
  39. FT_Memory memory = library->memory;
  40. if ( pic_container->autofit )
  41. {
  42. FT_FREE( pic_container->autofit );
  43. pic_container->autofit = NULL;
  44. }
  45. }
  46. FT_Error
  47. autofit_module_class_pic_init( FT_Library library )
  48. {
  49. FT_PIC_Container* pic_container = &library->pic_container;
  50. FT_UInt ss;
  51. FT_Error error = AF_Err_Ok;
  52. AFModulePIC* container;
  53. FT_Memory memory = library->memory;
  54. /* allocate pointer, clear and set global container pointer */
  55. if ( FT_ALLOC ( container, sizeof ( *container ) ) )
  56. return error;
  57. FT_MEM_SET( container, 0, sizeof ( *container ) );
  58. pic_container->autofit = container;
  59. /* initialize pointer table - */
  60. /* this is how the module usually expects this data */
  61. for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
  62. {
  63. container->af_script_classes[ss] =
  64. &container->af_script_classes_rec[ss];
  65. }
  66. container->af_script_classes[AF_SCRIPT_CLASSES_COUNT - 1] = NULL;
  67. /* add call to initialization function when you add new scripts */
  68. ss = 0;
  69. FT_Init_Class_af_dummy_script_class(
  70. &container->af_script_classes_rec[ss++] );
  71. #ifdef FT_OPTION_AUTOFIT2
  72. FT_Init_Class_af_latin2_script_class(
  73. &container->af_script_classes_rec[ss++] );
  74. #endif
  75. FT_Init_Class_af_latin_script_class(
  76. &container->af_script_classes_rec[ss++] );
  77. FT_Init_Class_af_cjk_script_class(
  78. &container->af_script_classes_rec[ss++] );
  79. FT_Init_Class_af_indic_script_class(
  80. &container->af_script_classes_rec[ss++] );
  81. FT_Init_Class_af_autofitter_service(
  82. library, &container->af_autofitter_service );
  83. /* Exit: */
  84. if ( error )
  85. autofit_module_class_pic_free( library );
  86. return error;
  87. }
  88. #endif /* FT_CONFIG_OPTION_PIC */
  89. /* END */