ahoptim.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /***************************************************************************/
  2. /* */
  3. /* ahoptim.h */
  4. /* */
  5. /* FreeType auto hinting outline optimization (declaration). */
  6. /* */
  7. /* Copyright 2000-2001 Catharon Productions Inc. */
  8. /* Author: David Turner */
  9. /* */
  10. /* This file is part of the Catharon Typography Project and shall only */
  11. /* be used, modified, and distributed under the terms of the Catharon */
  12. /* Open Source License that should come with this file under the name */
  13. /* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
  14. /* this file you indicate that you have read the license and */
  15. /* understand and accept it fully. */
  16. /* */
  17. /* Note that this license is compatible with the FreeType license. */
  18. /* */
  19. /***************************************************************************/
  20. #ifndef __AHOPTIM_H__
  21. #define __AHOPTIM_H__
  22. #include <ft2build.h>
  23. #include "ahtypes.h"
  24. FT_BEGIN_HEADER
  25. /* the maximal number of stem configurations to record */
  26. /* during optimization */
  27. #define AH_MAX_CONFIGS 8
  28. typedef struct AH_Stem_
  29. {
  30. FT_Pos pos; /* current position */
  31. FT_Pos velocity; /* current velocity */
  32. FT_Pos force; /* sum of current forces */
  33. FT_Pos width; /* normalized width */
  34. FT_Pos min_pos; /* minimum grid position */
  35. FT_Pos max_pos; /* maximum grid position */
  36. AH_Edge edge1; /* left/bottom edge */
  37. AH_Edge edge2; /* right/top edge */
  38. FT_Pos opos; /* original position */
  39. FT_Pos owidth; /* original width */
  40. FT_Pos min_coord; /* minimum coordinate */
  41. FT_Pos max_coord; /* maximum coordinate */
  42. } AH_Stem;
  43. /* A spring between two stems */
  44. typedef struct AH_Spring_
  45. {
  46. AH_Stem* stem1;
  47. AH_Stem* stem2;
  48. FT_Pos owidth; /* original width */
  49. FT_Pos tension; /* current tension */
  50. } AH_Spring;
  51. /* A configuration records the position of each stem at a given time */
  52. /* as well as the associated distortion */
  53. typedef struct AH_Configuration_
  54. {
  55. FT_Pos* positions;
  56. FT_Long distortion;
  57. } AH_Configuration;
  58. typedef struct AH_Optimizer_
  59. {
  60. FT_Memory memory;
  61. AH_Outline outline;
  62. FT_Int num_hstems;
  63. AH_Stem* horz_stems;
  64. FT_Int num_vstems;
  65. AH_Stem* vert_stems;
  66. FT_Int num_hsprings;
  67. FT_Int num_vsprings;
  68. AH_Spring* horz_springs;
  69. AH_Spring* vert_springs;
  70. FT_Int num_configs;
  71. AH_Configuration configs[AH_MAX_CONFIGS];
  72. FT_Pos* positions;
  73. /* during each pass, use these instead */
  74. FT_Int num_stems;
  75. AH_Stem* stems;
  76. FT_Int num_springs;
  77. AH_Spring* springs;
  78. FT_Bool vertical;
  79. FT_Fixed tension_scale;
  80. FT_Pos tension_threshold;
  81. } AH_Optimizer;
  82. /* loads the outline into the optimizer */
  83. int
  84. AH_Optimizer_Init( AH_Optimizer* optimizer,
  85. AH_Outline outline,
  86. FT_Memory memory );
  87. /* compute optimal outline */
  88. void
  89. AH_Optimizer_Compute( AH_Optimizer* optimizer );
  90. /* release the optimization data */
  91. void
  92. AH_Optimizer_Done( AH_Optimizer* optimizer );
  93. FT_END_HEADER
  94. #endif /* __AHOPTIM_H__ */
  95. /* END */