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