xref: /plan9/sys/src/cmd/gs/src/gsfcmap.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1997, 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: gsfcmap.h,v 1.9 2003/02/06 09:40:00 igor Exp $ */
18 /* Public interface to CMaps */
19 
20 #ifndef gsfcmap_INCLUDED
21 #  define gsfcmap_INCLUDED
22 
23 #include "gsccode.h"
24 
25 /* Define the abstract type for a CMap. */
26 #ifndef gs_cmap_DEFINED
27 #  define gs_cmap_DEFINED
28 typedef struct gs_cmap_s gs_cmap_t;
29 #endif
30 
31 /* ---------------- Procedural interface ---------------- */
32 
33 /*
34  * Create an Identity CMap.
35  */
36 int gs_cmap_create_identity(gs_cmap_t **ppcmap, int num_bytes, int wmode,
37 			    gs_memory_t *mem);
38 
39 /*
40  * Create an Identity CMap where each entry varies only in the lowest byte,
41  * and that maps to characters rather than to CIDs.
42  * (This is suitable for use as a ToUnicode CMap, for example.)
43  */
44 int gs_cmap_create_char_identity(gs_cmap_t **ppcmap, int num_bytes,
45 				 int wmode, gs_memory_t *mem);
46 
47 /*
48  * Decode a character from a string using a CMap, updating the index.
49  * Return 0 for a CID or name, N > 0 for a character code where N is the
50  * number of bytes in the code, or an error.  Store the decoded bytes in
51  * *pchr.  For undefined characters, set *pglyph = gs_no_glyph and return 0.
52  */
53 int gs_cmap_decode_next(const gs_cmap_t *pcmap, const gs_const_string *str,
54 			uint *pindex, uint *pfidx,
55 			gs_char *pchr, gs_glyph *pglyph);
56 
57 /*
58  * Allocate and initialize a ToUnicode CMap.
59  */
60 int gs_cmap_ToUnicode_alloc(gs_memory_t *mem, int id, int num_codes, int key_size,
61 			    gs_cmap_t **ppcmap);
62 
63 /*
64  * Write a code pair to ToUnicode CMap.
65  */
66 void gs_cmap_ToUnicode_add_pair(gs_cmap_t *pcmap, int code0, int code2);
67 
68 #endif /* gsfcmap_INCLUDED */
69