pshalgo2.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /***************************************************************************/
  2. /* */
  3. /* pshalgo2.h */
  4. /* */
  5. /* PostScript hinting algorithm 2 (specification). */
  6. /* */
  7. /* Copyright 2001 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. #ifndef __PSHALGO2_H__
  18. #define __PSHALGO2_H__
  19. #include "pshrec.h"
  20. #include "pshglob.h"
  21. #include FT_TRIGONOMETRY_H
  22. FT_BEGIN_HEADER
  23. typedef struct PSH2_HintRec_* PSH2_Hint;
  24. typedef enum
  25. {
  26. PSH2_HINT_GHOST = PS_HINT_FLAG_GHOST,
  27. PSH2_HINT_BOTTOM = PS_HINT_FLAG_BOTTOM,
  28. PSH2_HINT_ACTIVE = 4,
  29. PSH2_HINT_FITTED = 8
  30. } PSH2_Hint_Flags;
  31. #define psh2_hint_is_active( x ) ( ( (x)->flags & PSH2_HINT_ACTIVE ) != 0 )
  32. #define psh2_hint_is_ghost( x ) ( ( (x)->flags & PSH2_HINT_GHOST ) != 0 )
  33. #define psh2_hint_is_fitted( x ) ( ( (x)->flags & PSH2_HINT_FITTED ) != 0 )
  34. #define psh2_hint_activate( x ) (x)->flags |= PSH2_HINT_ACTIVE
  35. #define psh2_hint_deactivate( x ) (x)->flags &= ~PSH2_HINT_ACTIVE
  36. #define psh2_hint_set_fitted( x ) (x)->flags |= PSH2_HINT_FITTED
  37. typedef struct PSH2_HintRec_
  38. {
  39. FT_Int org_pos;
  40. FT_Int org_len;
  41. FT_Pos cur_pos;
  42. FT_Pos cur_len;
  43. FT_UInt flags;
  44. PSH2_Hint parent;
  45. FT_Int order;
  46. } PSH2_HintRec;
  47. /* this is an interpolation zone used for strong points; */
  48. /* weak points are interpolated according to their strong */
  49. /* neighbours */
  50. typedef struct PSH2_ZoneRec_
  51. {
  52. FT_Fixed scale;
  53. FT_Fixed delta;
  54. FT_Pos min;
  55. FT_Pos max;
  56. } PSH2_ZoneRec, *PSH2_Zone;
  57. typedef struct PSH2_Hint_TableRec_
  58. {
  59. FT_UInt max_hints;
  60. FT_UInt num_hints;
  61. PSH2_Hint hints;
  62. PSH2_Hint* sort;
  63. PSH2_Hint* sort_global;
  64. FT_UInt num_zones;
  65. PSH2_Zone zones;
  66. PSH2_Zone zone;
  67. PS_Mask_Table hint_masks;
  68. PS_Mask_Table counter_masks;
  69. } PSH2_Hint_TableRec, *PSH2_Hint_Table;
  70. typedef struct PSH2_PointRec_* PSH2_Point;
  71. typedef struct PSH2_ContourRec_* PSH2_Contour;
  72. enum
  73. {
  74. PSH2_DIR_NONE = 4,
  75. PSH2_DIR_UP = 1,
  76. PSH2_DIR_DOWN = -1,
  77. PSH2_DIR_LEFT = -2,
  78. PSH2_DIR_RIGHT = 2
  79. };
  80. enum
  81. {
  82. PSH2_POINT_OFF = 1, /* point is off the curve */
  83. PSH2_POINT_STRONG = 2, /* point is strong */
  84. PSH2_POINT_SMOOTH = 4, /* point is smooth */
  85. PSH2_POINT_FITTED = 8 /* point is already fitted */
  86. };
  87. typedef struct PSH2_PointRec_
  88. {
  89. PSH2_Point prev;
  90. PSH2_Point next;
  91. PSH2_Contour contour;
  92. FT_UInt flags;
  93. FT_Char dir_in;
  94. FT_Char dir_out;
  95. FT_Angle angle_in;
  96. FT_Angle angle_out;
  97. PSH2_Hint hint;
  98. FT_Pos org_u;
  99. FT_Pos cur_u;
  100. #ifdef DEBUG_HINTER
  101. FT_Pos org_x;
  102. FT_Pos cur_x;
  103. FT_Pos org_y;
  104. FT_Pos cur_y;
  105. FT_UInt flags_x;
  106. FT_UInt flags_y;
  107. #endif
  108. } PSH2_PointRec;
  109. #define psh2_point_is_strong( p ) ( (p)->flags & PSH2_POINT_STRONG )
  110. #define psh2_point_is_fitted( p ) ( (p)->flags & PSH2_POINT_FITTED )
  111. #define psh2_point_is_smooth( p ) ( (p)->flags & PSH2_POINT_SMOOTH )
  112. #define psh2_point_set_strong( p ) (p)->flags |= PSH2_POINT_STRONG
  113. #define psh2_point_set_fitted( p ) (p)->flags |= PSH2_POINT_FITTED
  114. #define psh2_point_set_smooth( p ) (p)->flags |= PSH2_POINT_SMOOTH
  115. typedef struct PSH2_ContourRec_
  116. {
  117. PSH2_Point start;
  118. FT_UInt count;
  119. } PSH2_ContourRec;
  120. typedef struct PSH2_GlyphRec_
  121. {
  122. FT_UInt num_points;
  123. FT_UInt num_contours;
  124. PSH2_Point points;
  125. PSH2_Contour contours;
  126. FT_Memory memory;
  127. FT_Outline* outline;
  128. PSH_Globals globals;
  129. PSH2_Hint_TableRec hint_tables[2];
  130. FT_Bool vertical;
  131. FT_Int major_dir;
  132. FT_Int minor_dir;
  133. } PSH2_GlyphRec, *PSH2_Glyph;
  134. #ifdef DEBUG_HINTER
  135. extern PSH2_Hint_Table ps2_debug_hint_table;
  136. typedef void
  137. (*PSH2_HintFunc)( PSH2_Hint hint,
  138. FT_Bool vertical );
  139. extern PSH2_HintFunc ps2_debug_hint_func;
  140. extern PSH2_Glyph ps2_debug_glyph;
  141. #endif
  142. extern FT_Error
  143. ps2_hints_apply( PS_Hints ps_hints,
  144. FT_Outline* outline,
  145. PSH_Globals globals,
  146. FT_Render_Mode hint_mode );
  147. FT_END_HEADER
  148. #endif /* __PSHALGO2_H__ */
  149. /* END */