1 /* Copyright (C) 1989, 2000 artofcode LLC.  All rights reserved.
2 
3   This program is free software; you can redistribute it and/or modify it
4   under the terms of the GNU General Public License as published by the
5   Free Software Foundation; either version 2 of the License, or (at your
6   option) any later version.
7 
8   This program is distributed in the hope that it will be useful, but
9   WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   General Public License for more details.
12 
13   You should have received a copy of the GNU General Public License along
14   with this program; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA, 02111-1307.
16 
17 */
18 
19 /*$Id: gschar.h,v 1.3.6.1.2.1 2003/01/17 00:49:02 giles Exp $ */
20 /* Client interface to character operations */
21 
22 #ifndef gschar_INCLUDED
23 #  define gschar_INCLUDED
24 
25 #include "gsccode.h"
26 #include "gscpm.h"
27 
28 /* String display, like image display, uses an enumeration structure */
29 /* to keep track of what's going on (aka 'poor man's coroutine'). */
30 #ifndef gs_show_enum_DEFINED
31 #  define gs_show_enum_DEFINED
32 typedef struct gs_show_enum_s gs_show_enum;
33 #endif
34 
35 /* Define an opaque type for fonts if necessary. */
36 #ifndef gs_font_DEFINED
37 #  define gs_font_DEFINED
38 typedef struct gs_font_s gs_font;
39 #endif
40 
41 /* Allocate an enumerator. */
42 gs_show_enum *gs_show_enum_alloc(P3(gs_memory_t *, gs_state *, client_name_t));
43 
44 /* Release the contents of an enumerator. */
45 /* (This happens automatically if the enumeration finishes normally.) */
46 /* If the second argument is not NULL, also free the enumerator. */
47 void gs_show_enum_release(P2(gs_show_enum *, gs_memory_t *));
48 
49 /* Initialize a text enumeration. */
50 int
51     /* PostScript operators */
52     gs_show_n_init(P4(gs_show_enum *, gs_state *, const char *, uint)),
53     gs_ashow_n_init(P6(gs_show_enum *, gs_state *, floatp, floatp, const char *, uint)),
54     gs_widthshow_n_init(P7(gs_show_enum *, gs_state *, floatp, floatp, gs_char, const char *, uint)),
55     gs_awidthshow_n_init(P9(gs_show_enum *, gs_state *, floatp, floatp, gs_char, floatp, floatp, const char *, uint)),
56     gs_kshow_n_init(P4(gs_show_enum *, gs_state *, const char *, uint)),
57     gs_xyshow_n_init(P4(gs_show_enum *, gs_state *, const char *, uint)),
58     gs_glyphshow_init(P3(gs_show_enum *, gs_state *, gs_glyph)), gs_cshow_n_init(P4(gs_show_enum *, gs_state *, const char *, uint)),
59     gs_stringwidth_n_init(P4(gs_show_enum *, gs_state *, const char *, uint)),
60     gs_charpath_n_init(P5(gs_show_enum *, gs_state *, const char *, uint, bool)),
61     /* Extensions */
62     gs_glyphpath_init(P4(gs_show_enum *, gs_state *, gs_glyph, bool)),
63     gs_glyphwidth_init(P3(gs_show_enum *, gs_state *, gs_glyph)),
64     gs_charboxpath_n_init(P5(gs_show_enum *, gs_state *, const char *, uint, bool));
65 int gs_show_use_glyph(P2(gs_show_enum *, gs_glyph));
66 
67 /* After setting up the enumeration, all the string-related routines */
68 /* work the same way.  The client calls gs_show_next until it returns */
69 /* a zero (successful completion) or negative (error) value. */
70 /* Other values indicate the following situations: */
71 
72 	/* The client must render a character: obtain the code from */
73 	/* gs_show_current_char, do whatever is necessary, and then */
74 	/* call gs_show_next again. */
75 #define gs_show_render TEXT_PROCESS_RENDER
76 
77 	/* The client has asked to intervene between characters (kshow). */
78 	/* Obtain the previous and next codes from gs_kshow_previous_char */
79 	/* and gs_kshow_next_char, do whatever is necessary, and then */
80 	/* call gs_show_next again. */
81 #define gs_show_kern TEXT_PROCESS_INTERVENE
82 
83 	/* The client has asked to handle characters individually */
84 	/* (xshow, yshow, xyshow, cshow).  Obtain the current code */
85 	/* from gs_show_current_char, do whatever is necessary, and then */
86 	/* call gs_show_next again. */
87 #define gs_show_move TEXT_PROCESS_INTERVENE
88 
89 int gs_show_next(P1(gs_show_enum *));
90 
91 gs_char
92     gs_show_current_char(P1(const gs_show_enum *)),
93     gs_kshow_previous_char(P1(const gs_show_enum *)),
94     gs_kshow_next_char(P1(const gs_show_enum *));
95 gs_font *
96     gs_show_current_font(P1(const gs_show_enum *));
97 
98 gs_glyph
99     gs_show_current_glyph(P1(const gs_show_enum *));
100 int gs_show_current_width(P2(const gs_show_enum *, gs_point *));
101 void gs_show_width(P2(const gs_show_enum *, gs_point *));  /* cumulative width */
102 
103 gs_char_path_mode
104     gs_show_in_charpath(P1(const gs_show_enum *));  /* return charpath flag */
105 
106 /* Character cache and metrics operators. */
107 /* gs_setcachedevice* return 1 iff the cache device was just installed. */
108 int gs_setcachedevice_float(P3(gs_show_enum *, gs_state *, const float * /*[6] */ ));
109 int gs_setcachedevice_double(P3(gs_show_enum *, gs_state *, const double * /*[6] */ ));
110 #define gs_setcachedevice(penum, pgs, pw)\
111   gs_setcachedevice_float(penum, pgs, pw)
112 int gs_setcachedevice2_float(P3(gs_show_enum *, gs_state *, const float * /*[10] */ ));
113 int gs_setcachedevice2_double(P3(gs_show_enum *, gs_state *, const double * /*[10] */ ));
114 #define gs_setcachedevice2(penum, pgs, pw2)\
115   gs_setcachedevice2_float(penum, pgs, pw2)
116 int gs_setcharwidth(P4(gs_show_enum *, gs_state *, floatp, floatp));
117 
118 /* Return true if we only need the width from the rasterizer */
119 /* and can short-circuit the full rendering of the character, */
120 /* false if we need the actual character bits. */
121 /* This is only meaningful just before calling gs_setcharwidth or */
122 /* gs_setcachedevice[2]. */
123 bool gs_show_width_only(P1(const gs_show_enum *));
124 
125 #endif /* gschar_INCLUDED */
126