pshmod.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /***************************************************************************/
  2. /* */
  3. /* pshmod.c */
  4. /* */
  5. /* FreeType PostScript hinter module implementation (body). */
  6. /* */
  7. /* Copyright 2001, 2002 by */
  8. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  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_INTERNAL_OBJECTS_H
  19. #include "pshrec.h"
  20. #include "pshalgo.h"
  21. /* the Postscript Hinter module structure */
  22. typedef struct PS_Hinter_Module_Rec_
  23. {
  24. FT_ModuleRec root;
  25. PS_HintsRec ps_hints;
  26. PSH_Globals_FuncsRec globals_funcs;
  27. T1_Hints_FuncsRec t1_funcs;
  28. T2_Hints_FuncsRec t2_funcs;
  29. } PS_Hinter_ModuleRec, *PS_Hinter_Module;
  30. /* finalize module */
  31. FT_CALLBACK_DEF( void )
  32. ps_hinter_done( PS_Hinter_Module module )
  33. {
  34. module->t1_funcs.hints = NULL;
  35. module->t2_funcs.hints = NULL;
  36. ps_hints_done( &module->ps_hints );
  37. }
  38. /* initialize module, create hints recorder and the interface */
  39. FT_CALLBACK_DEF( FT_Error )
  40. ps_hinter_init( PS_Hinter_Module module )
  41. {
  42. FT_Memory memory = module->root.memory;
  43. ps_hints_init( &module->ps_hints, memory );
  44. psh_globals_funcs_init( &module->globals_funcs );
  45. t1_hints_funcs_init( &module->t1_funcs );
  46. module->t1_funcs.hints = (T1_Hints)&module->ps_hints;
  47. t2_hints_funcs_init( &module->t2_funcs );
  48. module->t2_funcs.hints = (T2_Hints)&module->ps_hints;
  49. return 0;
  50. }
  51. /* returns global hints interface */
  52. FT_CALLBACK_DEF( PSH_Globals_Funcs )
  53. pshinter_get_globals_funcs( FT_Module module )
  54. {
  55. return &((PS_Hinter_Module)module)->globals_funcs;
  56. }
  57. /* return Type 1 hints interface */
  58. FT_CALLBACK_DEF( T1_Hints_Funcs )
  59. pshinter_get_t1_funcs( FT_Module module )
  60. {
  61. return &((PS_Hinter_Module)module)->t1_funcs;
  62. }
  63. /* return Type 2 hints interface */
  64. FT_CALLBACK_DEF( T2_Hints_Funcs )
  65. pshinter_get_t2_funcs( FT_Module module )
  66. {
  67. return &((PS_Hinter_Module)module)->t2_funcs;
  68. }
  69. static
  70. const PSHinter_Interface pshinter_interface =
  71. {
  72. pshinter_get_globals_funcs,
  73. pshinter_get_t1_funcs,
  74. pshinter_get_t2_funcs
  75. };
  76. FT_CALLBACK_TABLE_DEF
  77. const FT_Module_Class pshinter_module_class =
  78. {
  79. 0,
  80. sizeof ( PS_Hinter_ModuleRec ),
  81. "pshinter",
  82. 0x10000L,
  83. 0x20000L,
  84. &pshinter_interface, /* module-specific interface */
  85. (FT_Module_Constructor)ps_hinter_init,
  86. (FT_Module_Destructor) ps_hinter_done,
  87. (FT_Module_Requester) 0 /* no additional interface for now */
  88. };
  89. /* END */