1 /* Copyright (C) 2001-2006 Artifex Software, Inc.
2    All Rights Reserved.
3 
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6 
7    This software is distributed under license and may not be copied, modified
8    or distributed except as expressly authorized under the terms of that
9    license.  Refer to licensing information at http://www.artifex.com/
10    or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11    San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12 */
13 
14 /* $Id: gschar.h 8022 2007-06-05 22:23:38Z giles $ */
15 /* Client interface to character operations */
16 
17 #ifndef gschar_INCLUDED
18 #  define gschar_INCLUDED
19 
20 #include "gsccode.h"
21 #include "gscpm.h"
22 
23 /* String display, like image display, uses an enumeration structure */
24 /* to keep track of what's going on (aka 'poor man's coroutine'). */
25 #ifndef gs_show_enum_DEFINED
26 #  define gs_show_enum_DEFINED
27 typedef struct gs_show_enum_s gs_show_enum;
28 #endif
29 
30 /* Define an opaque type for fonts if necessary. */
31 #ifndef gs_font_DEFINED
32 #  define gs_font_DEFINED
33 typedef struct gs_font_s gs_font;
34 #endif
35 
36 /* Allocate an enumerator. */
37 gs_show_enum *gs_show_enum_alloc(gs_memory_t *, gs_state *, client_name_t);
38 
39 /* Release the contents of an enumerator. */
40 /* (This happens automatically if the enumeration finishes normally.) */
41 /* If the second argument is not NULL, also free the enumerator. */
42 void gs_show_enum_release(gs_show_enum *, gs_memory_t *);
43 
44 /* Initialize a text enumeration. */
45 int
46     /* PostScript operators */
47     gs_show_n_init(gs_show_enum *, gs_state *, const char *, uint),
48     gs_ashow_n_init(gs_show_enum *, gs_state *, floatp, floatp, const char *, uint),
49     gs_widthshow_n_init(gs_show_enum *, gs_state *, floatp, floatp, gs_char, const char *, uint),
50     gs_awidthshow_n_init(gs_show_enum *, gs_state *, floatp, floatp, gs_char, floatp, floatp, const char *, uint),
51     gs_kshow_n_init(gs_show_enum *, gs_state *, const char *, uint),
52     gs_xyshow_n_init(gs_show_enum *, gs_state *, const char *, uint),
53     gs_glyphshow_init(gs_show_enum *, gs_state *, gs_glyph), gs_cshow_n_init(gs_show_enum *, gs_state *, const char *, uint),
54     gs_stringwidth_n_init(gs_show_enum *, gs_state *, const char *, uint),
55     gs_charpath_n_init(gs_show_enum *, gs_state *, const char *, uint, bool),
56     /* Extensions */
57     gs_glyphpath_init(gs_show_enum *, gs_state *, gs_glyph, bool),
58     gs_glyphwidth_init(gs_show_enum *, gs_state *, gs_glyph),
59     gs_charboxpath_n_init(gs_show_enum *, gs_state *, const char *, uint, bool);
60 int gs_show_use_glyph(gs_show_enum *, gs_glyph);
61 
62 /* After setting up the enumeration, all the string-related routines */
63 /* work the same way.  The client calls gs_show_next until it returns */
64 /* a zero (successful completion) or negative (error) value. */
65 /* Other values indicate the following situations: */
66 
67 	/* The client must render a character: obtain the code from */
68 	/* gs_show_current_char, do whatever is necessary, and then */
69 	/* call gs_show_next again. */
70 #define gs_show_render TEXT_PROCESS_RENDER
71 
72 	/* The client has asked to intervene between characters (kshow). */
73 	/* Obtain the previous and next codes from gs_kshow_previous_char */
74 	/* and gs_kshow_next_char, do whatever is necessary, and then */
75 	/* call gs_show_next again. */
76 #define gs_show_kern TEXT_PROCESS_INTERVENE
77 
78 	/* The client has asked to handle characters individually */
79 	/* (xshow, yshow, xyshow, cshow).  Obtain the current code */
80 	/* from gs_show_current_char, do whatever is necessary, and then */
81 	/* call gs_show_next again. */
82 #define gs_show_move TEXT_PROCESS_INTERVENE
83 
84 int gs_show_next(gs_show_enum *);
85 
86 gs_char
87     gs_show_current_char(const gs_show_enum *),
88     gs_kshow_previous_char(const gs_show_enum *),
89     gs_kshow_next_char(const gs_show_enum *);
90 gs_font *
91     gs_show_current_font(const gs_show_enum *);
92 
93 gs_glyph
94     gs_show_current_glyph(const gs_show_enum *);
95 int gs_show_current_width(const gs_show_enum *, gs_point *);
96 void gs_show_width(const gs_show_enum *, gs_point *);  /* cumulative width */
97 
98 gs_char_path_mode
99     gs_show_in_charpath(const gs_show_enum *);  /* return charpath flag */
100 
101 /* Character cache and metrics operators. */
102 /* gs_setcachedevice* return 1 iff the cache device was just installed. */
103 int gs_setcachedevice_float(gs_show_enum *, gs_state *, const float * /*[6] */ );
104 int gs_setcachedevice_double(gs_show_enum *, gs_state *, const double * /*[6] */ );
105 #define gs_setcachedevice(penum, pgs, pw)\
106   gs_setcachedevice_float(penum, pgs, pw)
107 int gs_setcachedevice2_float(gs_show_enum *, gs_state *, const float * /*[10] */ );
108 int gs_setcachedevice2_double(gs_show_enum *, gs_state *, const double * /*[10] */ );
109 #define gs_setcachedevice2(penum, pgs, pw2)\
110   gs_setcachedevice2_float(penum, pgs, pw2)
111 int gs_setcharwidth(gs_show_enum *, gs_state *, floatp, floatp);
112 
113 /* Return true if we only need the width from the rasterizer */
114 /* and can short-circuit the full rendering of the character, */
115 /* false if we need the actual character bits. */
116 /* This is only meaningful just before calling gs_setcharwidth or */
117 /* gs_setcachedevice[2]. */
118 bool gs_show_width_only(const gs_show_enum *);
119 
120 #endif /* gschar_INCLUDED */
121