1 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
2 
3     Copyright (C) 2002-2014 by Jin-Hwan Cho and Shunsaku Hirata,
4     the dvipdfmx project team.
5 
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 */
20 
21 #ifndef _CMAP_H_
22 #define _CMAP_H_
23 
24 #include "cid.h"
25 
26 #include <sys/types.h>
27 
28 typedef unsigned short CID;
29 typedef unsigned short UCV16;
30 
31 /* Limits */
32 #define CID_MAX_CID  65535
33 #define CID_MAX      CID_MAX_CID
34 
35 #define CID_NOTDEF_CHAR   "\0\0"
36 #define CID_NOTDEF        0
37 
38 #define UCS_NOTDEF_CHAR   "\377\375"
39 #define UCS_NOTDEF        0xfffd
40 
41 /*
42  * TYPE_IDENTITY and TYPE_CID_TO_CODE is not defined in the CMap spec.
43  */
44 #define CMAP_TYPE_IDENTITY    0
45 #define CMAP_TYPE_CODE_TO_CID 1
46 #define CMAP_TYPE_TO_UNICODE  2
47 #define CMAP_TYPE_CID_TO_CODE 3
48 
49 #define CMAP_PROF_TYPE_INBYTES_MIN  0
50 #define CMAP_PROF_TYPE_INBYTES_MAX  1
51 #define CMAP_PROF_TYPE_OUTBYTES_MIN 2
52 #define CMAP_PROF_TYPE_OUTBYTES_MAX 3
53 
54 typedef struct CMap CMap;
55 
56 
57 /************************** CMAP_MAIN **************************/
58 
59 extern void CMap_set_verbose (void);
60 extern void CMap_set_silent  (int value);
61 
62 extern CMap  *CMap_new     (void);
63 extern void   CMap_release (CMap *cmap);
64 
65 extern int    CMap_is_valid    (CMap *cmap);
66 extern int    CMap_is_Identity (CMap *cmap);
67 extern int    CMap_get_profile (CMap *cmap, int type);
68 
69 extern char       *CMap_get_name (CMap *cmap);
70 extern int         CMap_get_type (CMap *cmap);
71 extern int         CMap_get_wmode(CMap *cmap);
72 extern CIDSysInfo *CMap_get_CIDSysInfo(CMap *cmap);
73 
74 extern void   CMap_set_name   (CMap *cmap, const char *name);
75 extern void   CMap_set_type   (CMap *cmap, int type);
76 extern void   CMap_set_wmode  (CMap *cmap, int wmode);
77 extern void   CMap_set_usecmap(CMap *cmap, CMap *ucmap);
78 extern void   CMap_set_CIDSysInfo (CMap *cmap, const CIDSysInfo *csi);
79 
80 /* charName not supported */
81 extern int   CMap_add_bfchar  (CMap *cmap,
82 			       const unsigned char *src, int srcdim,
83 			       const unsigned char *dest, int destdim);
84 extern int   CMap_add_cidchar (CMap *cmap,
85 			       const unsigned char *src, int srcdim, CID dest);
86 extern int   CMap_add_bfrange (CMap *cmap,
87 			       const unsigned char *srclo, const unsigned char *srchi, int srcdim,
88 			       const unsigned char *dest, int destdim);
89 extern int   CMap_add_cidrange(CMap *cmap,
90 			       const unsigned char *srclo, const unsigned char *hi, int srcdim,
91 			       CID base);
92 
93 extern int CMap_add_notdefchar  (CMap *cmap, const unsigned char *src, int srcdim, CID dst);
94 extern int CMap_add_notdefrange (CMap *cmap,
95 				 const unsigned char *srclo, const unsigned char *srchi, int srcdim,
96 				 CID dst);
97 
98 extern int  CMap_add_codespacerange (CMap *cmap,
99 				     const unsigned char *codelo, const unsigned char *codehi, int dim);
100 extern int  CMap_match_codespace    (CMap *cmap, const unsigned char *c, int dim);
101 
102 extern void CMap_decode_char (CMap *cmap,
103 			      const unsigned char **inbuf, long *inbytesleft,
104 			      unsigned char **outbuf, long *outbytesleft);
105 
106 extern long CMap_decode (CMap *cmap,
107 			 const unsigned char **inbuf,  long *inbytesleft,
108 			 unsigned char **outbuf, long *outbytesleft);
109 
110 extern int  CMap_reverse_decode(CMap *cmap, CID cid);
111 
112 extern void  CMap_cache_init  (void);
113 extern CMap *CMap_cache_get   (int id);
114 extern int   CMap_cache_find  (const char *cmap_name);
115 extern void  CMap_cache_close (void);
116 extern int   CMap_cache_add   (CMap *cmap);
117 
118 #endif /* _CMAP_H_ */
119