home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / GXTYPE1.H < prev    next >
C/C++ Source or Header  |  1992-05-28  |  5KB  |  126 lines

  1. /* Copyright (C) 1990, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gxtype1.h */
  21. /* Private Adobe Type 1 font definitions for GhostScript library */
  22. #include "gscrypt1.h"
  23. #include "gstype1.h"
  24.  
  25. /* Define the structures for the state of a Type 1 interpreter. */
  26.  
  27. /* Define the control state of the interpreter. */
  28. /* This is what must be saved and restored */
  29. /* when calling a CharString subroutine. */
  30. typedef struct {
  31.     const byte *ip;
  32.     crypt_state dstate;
  33. } ip_state;
  34.  
  35. /* Define the stem hint tables. */
  36. /* Each stem hint table is kept sorted. */
  37. /* Stem hints are in device coordinates. */
  38. #define max_stems 3            /* arbitrary */
  39. typedef struct {
  40.     fixed v0, v1;            /* coordinates (widened a little) */
  41.     fixed dv0, dv1;            /* adjustment values */
  42. } stem_hint;
  43. typedef struct {
  44.     int count;
  45.     stem_hint *current;        /* cache cursor for search */
  46.     stem_hint data[max_stems];
  47. } stem_hint_table;
  48.  
  49. /* Define the standard stem width tables. */
  50. /* Each table is sorted, since the StemSnap arrays are sorted. */
  51. #define max_snaps (1 + max_StemSnap)
  52. typedef struct {
  53.     int count;
  54.     fixed data[max_snaps];
  55. } stem_snap_table;
  56.  
  57. /* Define the alignment zone structure. */
  58. /* These are in device coordinates also. */
  59. #define max_a_zones (max_BlueValues + max_OtherBlues)
  60. typedef struct {
  61.     int is_top_zone;
  62.     fixed v0, v1;            /* range for testing */
  63.     fixed flat;            /* flat position */
  64. } alignment_zone;
  65.  
  66. /* Define the structure for hints that depend only on the font and CTM, */
  67. /* not on the individual character.  Eventually these should be cached */
  68. /* with the font/matrix pair. */
  69. typedef struct font_hints_s {
  70.     int axes_swapped;        /* true if x & y axes interchanged */
  71.                     /* (only set if using hints) */
  72.     int x_inverted, y_inverted;    /* true if axis is inverted */
  73.     int use_x_hints;        /* true if we should use hints */
  74.                     /* for char space x coords (vstem) */
  75.     int use_y_hints;        /* true if we should use hints */
  76.                     /* for char space y coords (hstem) */
  77.     stem_snap_table snap_h;        /* StdHW, StemSnapH */
  78.     stem_snap_table snap_v;        /* StdVW, StemSnapV */
  79.     fixed blue_fuzz, blue_shift;    /* alignment zone parameters */
  80.                     /* in device pixels */
  81.     int suppress_overshoot;        /* (computed from BlueScale) */
  82.     int a_zone_count;        /* # of alignment zones */
  83.     alignment_zone a_zones[max_a_zones];    /* the alignment zones */
  84. } font_hints;
  85.  
  86. /* This is the full state of the Type 1 interpreter. */
  87. #define ostack_size 24            /* per documentation */
  88. #define ipstack_size 10            /* per documentation */
  89. struct gs_type1_state_s {
  90.         /* The following are set at initialization */
  91.     gs_show_enum *penum;        /* show enumerator */
  92.     gs_state *pgs;            /* graphics state */
  93.     gs_type1_data *pdata;        /* font-specific data */
  94.     int charpath_flag;        /* 0 for show, 1 for false */
  95.                     /* charpath, 2 for true charpath */
  96.     int paint_type;            /* 0/3 for fill, 1/2 for stroke */
  97.     fixed_coeff fc;            /* cached fixed coefficients */
  98.     float flatness;            /* flatness for character curves */
  99.     font_hints fh;            /* font-level hints */
  100.         /* The following are updated dynamically */
  101.     fixed ostack[ostack_size];    /* the Type 1 operand stack */
  102.     int os_count;            /* # of occupied stack entries */
  103.     ip_state ipstack[ipstack_size+1];    /* control stack */
  104.     int ips_count;            /* # of occupied entries */
  105.     gs_fixed_point lsb;        /* left side bearing */
  106.     gs_fixed_point width;        /* character width (char coords) */
  107.     int seac_base;            /* base character code for seac, */
  108.                     /* or -1 */
  109.         /* The following are set dynamically. */
  110.     int in_dotsection;        /* true if inside dotsection */
  111.     int vstem3_set;            /* true if vstem3 seen */
  112.     gs_fixed_point vs_offset;    /* device space offset for centering */
  113.                     /* middle stem of vstem3 */
  114.     stem_hint_table hstem_hints;    /* horizontal stem hints */
  115.     stem_hint_table vstem_hints;    /* vertical stem hints */
  116. };
  117.  
  118. /* Interface between main Type 1 interpreter and hint routines. */
  119. extern void compute_font_hints(P3(font_hints *, const gs_matrix_fixed *,
  120.                   const gs_type1_data *));
  121. extern void reset_stem_hints(P1(gs_type1_state *));
  122. extern void find_stem_hints(P6(gs_type1_state *, fixed, fixed,
  123.                    fixed, fixed, gs_fixed_point *));
  124. extern void type1_hstem(P3(gs_type1_state *, fixed, fixed));
  125. extern void type1_vstem(P3(gs_type1_state *, fixed, fixed));
  126.