gxhintn.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /* Copyright (C) 1990, 2000 Aladdin Enterprises. All rights reserved.
  2. This software is provided AS-IS with no warranty, either express or
  3. implied.
  4. This software is distributed under license and may not be copied,
  5. modified or distributed except as expressly authorized under the terms
  6. of the license contained in the file LICENSE in this distribution.
  7. For more information about licensing, please refer to
  8. http://www.ghostscript.com/licensing/. For information on
  9. commercial licensing, go to http://www.artifex.com/licensing/ or
  10. contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  12. */
  13. /* $Id: gxhintn.h,v 1.24 2005/09/04 20:42:53 leonardo Exp $ */
  14. /* Type 1 hinter, prototypes */
  15. #ifndef gxhintn_INCLUDED
  16. # define gxhintn_INCLUDED
  17. #include "stdint_.h"
  18. #define FINE_STEM_COMPLEXES 1 /* A temporary development purpose. */
  19. #define ALIGN_BY_STEM_MIDDLE 1 /* A temporary development purpose. */
  20. #define OPPOSITE_STEM_COORD_BUG_FIX 1 /* A temporary development purpose. */
  21. #define TT_AUTOHINT_TOPZONE_BUG_FIX 1 /* A temporary development purpose. */
  22. #ifndef gs_type1_data_DEFINED
  23. #define gs_type1_data_DEFINED
  24. typedef struct gs_type1_data_s gs_type1_data;
  25. #endif
  26. #ifndef gs_type42_data_DEFINED
  27. #define gs_type42_data_DEFINED
  28. typedef struct gs_type42_data_s gs_type42_data;
  29. #endif
  30. #ifndef gx_path_DEFINED
  31. # define gx_path_DEFINED
  32. typedef struct gx_path_s gx_path;
  33. #endif
  34. #define T1_MAX_STEM_SNAPS 12
  35. #define T1_MAX_ALIGNMENT_ZONES 6
  36. #define T1_MAX_CONTOURS 10
  37. #define T1_MAX_POLES (100 + T1_MAX_CONTOURS) /* Must be grater than 8 for 'flex'. */
  38. #define T1_MAX_HINTS 30
  39. typedef fixed t1_glyph_space_coord; /* measured in original glyph space units */
  40. typedef int32_t t1_hinter_space_coord; /* measured in internal outliner's space units */
  41. typedef int32_t int19;
  42. enum t1_hint_type
  43. { hstem, vstem, dot
  44. };
  45. enum t1_pole_type
  46. { offcurve, oncurve, closepath, moveto
  47. };
  48. enum t1_zone_type
  49. { topzone, botzone
  50. };
  51. enum t1_align_type
  52. { unaligned, weak, aligned, topzn, botzn
  53. #if !FINE_STEM_COMPLEXES
  54. /* 'weak' is never used. Defined to simplify a compatibility testing. */
  55. #endif
  56. };
  57. typedef struct {
  58. double xx, xy, yx, yy;
  59. } double_matrix;
  60. typedef struct {
  61. int19 xx, xy, yx, yy;
  62. int32_t denominator;
  63. unsigned int bitshift;
  64. } fraction_matrix;
  65. typedef struct t1_pole_s /* a pole of outline */
  66. { t1_glyph_space_coord gx,gy; /* source unaligned coords */
  67. t1_glyph_space_coord ax,ay; /* aligned coords */
  68. t1_hinter_space_coord ox,oy;
  69. enum t1_pole_type type;
  70. int contour_index;
  71. enum t1_align_type aligned_x, aligned_y;
  72. } t1_pole;
  73. typedef struct t1_hint_s
  74. { enum t1_hint_type type;
  75. t1_glyph_space_coord g0, g1; /* starting and ending transversal coord of the stem */
  76. t1_glyph_space_coord ag0, ag1; /* starting and ending transversal aligned coord of the stem */
  77. bool b0, b1; /* g0, g1 correspond to a real stem. */
  78. #if !FINE_STEM_COMPLEXES
  79. /* b0, b1 are unused. Defined to simplify a compatibility testing. */
  80. #endif
  81. enum t1_align_type aligned0, aligned1; /* ag0, ag1 is aligned */
  82. int q0, q1; /* Stem quality tangent. */
  83. unsigned int stem3_index; /* 1,2,3 for stem3 (not used yet), 0 for other types */
  84. int range_index; /* type 2 only */
  85. int side_mask;
  86. } t1_hint;
  87. typedef struct t1_hint_range_s
  88. { short beg_pole, end_pole;
  89. int contour_index;
  90. int next;
  91. } t1_hint_range; /* type 2 only */
  92. typedef struct t1_zone_s /* alignment zone */
  93. { enum t1_zone_type type;
  94. t1_glyph_space_coord y, overshoot_y;
  95. t1_glyph_space_coord y_min, y_max;
  96. } t1_zone;
  97. typedef struct t1_hinter_s
  98. { fraction_matrix ctmf;
  99. fraction_matrix ctmi;
  100. unsigned int g2o_fraction_bits;
  101. unsigned int max_import_coord;
  102. int32_t g2o_fraction;
  103. t1_glyph_space_coord orig_gx, orig_gy; /* glyph origin in glyph space */
  104. t1_glyph_space_coord subglyph_orig_gx, subglyph_orig_gy; /* glyph origin in glyph space */
  105. fixed orig_dx, orig_dy; /* glyph origin in device space */
  106. fixed orig_ox, orig_oy; /* glyph origin in hinter space */
  107. t1_glyph_space_coord width_gx, width_gy; /* glyph space coords of the glyph origin */
  108. t1_glyph_space_coord cx, cy; /* current point */
  109. t1_glyph_space_coord bx, by; /* starting point of a contour */
  110. uint log2_pixels_x, log2_pixels_y; /* log2 of the number of pixels in unit (by an axis) */
  111. int log2_subpixels_x, log2_subpixels_y; /* log2 of the number of subpixels in unit (may be negative) */
  112. bool transposed;
  113. bool align_to_pixels; /* false == "align to (integral) pixels" */
  114. bool disable_hinting;
  115. bool grid_fit_x, grid_fit_y;
  116. bool charpath_flag;
  117. bool path_opened;
  118. bool autohinting;
  119. t1_glyph_space_coord blue_shift, blue_fuzz;
  120. t1_pole pole0[T1_MAX_POLES], *pole;
  121. t1_hint hint0[T1_MAX_HINTS], *hint;
  122. t1_zone zone0[T1_MAX_ALIGNMENT_ZONES], *zone;
  123. int contour0[T1_MAX_CONTOURS], *contour;
  124. t1_glyph_space_coord stem_snap0[2][T1_MAX_STEM_SNAPS + 1]; /* StdWH + StemSnapH, StdWV + StemSnapV */
  125. t1_glyph_space_coord *stem_snap[2];
  126. t1_hint_range hint_range0[T1_MAX_HINTS], *hint_range;
  127. int stem_snap_count[2], max_stem_snap_count[2]; /* H, V */
  128. int contour_count, max_contour_count;
  129. int zone_count, max_zone_count;
  130. int pole_count, max_pole_count;
  131. int hint_count, max_hint_count;
  132. int hint_range_count, max_hint_range_count;
  133. int primary_hint_count;
  134. int flex_count;
  135. int FontType; /* 1 or 2 */
  136. bool ForceBold;
  137. bool seac_flag;
  138. bool keep_stem_width;
  139. bool suppress_overshoots;
  140. double BlueScale;
  141. double font_size;
  142. double resolution;
  143. double heigt_transform_coef;
  144. double width_transform_coef;
  145. double base_font_scale;
  146. int19 width_transform_coef_rat;
  147. int19 heigt_transform_coef_rat;
  148. int19 width_transform_coef_inv;
  149. int19 heigt_transform_coef_inv;
  150. t1_glyph_space_coord overshoot_threshold;
  151. t1_glyph_space_coord ymin, ymax, ymid;
  152. gx_path *output_path;
  153. gs_memory_t *memory;
  154. } t1_hinter;
  155. void t1_hinter__init(t1_hinter * this, gx_path *output_path);
  156. int t1_hinter__set_mapping(t1_hinter * this, gs_matrix_fixed * ctm,
  157. gs_matrix * FontMatrix, gs_matrix * baseFontMatrix,
  158. int log2_pixels_x, int log2_pixels_y,
  159. int log2_subpixels_x, int log2_subpixels_y,
  160. fixed origin_x, fixed origin_y, bool align_to_pixels);
  161. int t1_hinter__set_font_data(t1_hinter * this, int FontType, gs_type1_data *pdata,
  162. bool no_grid_fitting);
  163. int t1_hinter__set_font42_data(t1_hinter * this, int FontType, gs_type42_data *pdata,
  164. bool no_grid_fitting);
  165. int t1_hinter__sbw(t1_hinter * this, fixed sbx, fixed sby, fixed wx, fixed wy);
  166. int t1_hinter__sbw_seac(t1_hinter * this, fixed sbx, fixed sby);
  167. int t1_hinter__rmoveto(t1_hinter * this, fixed xx, fixed yy);
  168. int t1_hinter__rlineto(t1_hinter *, fixed xx, fixed yy);
  169. int t1_hinter__rcurveto(t1_hinter * this, fixed xx0, fixed yy0, fixed xx1, fixed yy1, fixed xx2, fixed yy2);
  170. void t1_hinter__setcurrentpoint(t1_hinter * this, fixed xx, fixed yy);
  171. int t1_hinter__closepath(t1_hinter * this);
  172. int t1_hinter__flex_beg(t1_hinter * this);
  173. int t1_hinter__flex_end(t1_hinter * this, fixed flex_height);
  174. int t1_hinter__flex_point(t1_hinter * this);
  175. int t1_hinter__hint_mask(t1_hinter * this, byte *mask);
  176. int t1_hinter__drop_hints(t1_hinter * this);
  177. int t1_hinter__dotsection(t1_hinter * this);
  178. int t1_hinter__hstem(t1_hinter * this, fixed x0, fixed x1);
  179. int t1_hinter__vstem(t1_hinter * this, fixed y0, fixed y1);
  180. int t1_hinter__overall_hstem(t1_hinter * this, fixed x0, fixed x1, int side_mask);
  181. int t1_hinter__hstem3(t1_hinter * this, fixed x0, fixed y1, fixed x2, fixed y3, fixed x4, fixed y5);
  182. int t1_hinter__vstem3(t1_hinter * this, fixed y0, fixed y1, fixed y2, fixed y3, fixed y4, fixed y5);
  183. int t1_hinter__endchar(t1_hinter * this, bool seac_flag);
  184. int t1_hinter__endglyph(t1_hinter * this);
  185. int t1_hinter__is_x_fitting(t1_hinter * this);
  186. #endif /* gxhintn_INCLUDED */