Haru Free PDF Library
hpdf_encoder.h
Go to the documentation of this file.
1 /*
2  * << Haru Free PDF Library >> -- hpdf_encoder.h
3  *
4  * URL: http://libharu.org
5  *
6  * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
7  * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
8  *
9  * Permission to use, copy, modify, distribute and sell this software
10  * and its documentation for any purpose is hereby granted without fee,
11  * provided that the above copyright notice appear in all copies and
12  * that both that copyright notice and this permission notice appear
13  * in supporting documentation.
14  * It is provided "as is" without express or implied warranty.
15  *
16  */
17 
18 #ifndef _HPDF_ENCODER_H
19 #define _HPDF_ENCODER_H
20 
21 #include "hpdf_consts.h"
22 #include "hpdf_streams.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /*-- HPDF_Encoder ---------------------------------------*/
29 
30 #define HPDF_ENCODER_SIG_BYTES 0x454E4344L
31 
32 /*----------------------------------------------------------------------------*/
33 /*------ predefined font encodings -------------------------------------------*/
34 
35 #define HPDF_ENCODING_FONT_SPECIFIC "FontSpecific"
36 #define HPDF_ENCODING_STANDARD "StandardEncoding"
37 #define HPDF_ENCODING_MAC_ROMAN "MacRomanEncoding"
38 #define HPDF_ENCODING_WIN_ANSI "WinAnsiEncoding"
39 #define HPDF_ENCODING_ISO8859_2 "ISO8859-2"
40 #define HPDF_ENCODING_ISO8859_3 "ISO8859-3"
41 #define HPDF_ENCODING_ISO8859_4 "ISO8859-4"
42 #define HPDF_ENCODING_ISO8859_5 "ISO8859-5"
43 #define HPDF_ENCODING_ISO8859_6 "ISO8859-6"
44 #define HPDF_ENCODING_ISO8859_7 "ISO8859-7"
45 #define HPDF_ENCODING_ISO8859_8 "ISO8859-8"
46 #define HPDF_ENCODING_ISO8859_9 "ISO8859-9"
47 #define HPDF_ENCODING_ISO8859_10 "ISO8859-10"
48 #define HPDF_ENCODING_ISO8859_11 "ISO8859-11"
49 #define HPDF_ENCODING_ISO8859_13 "ISO8859-13"
50 #define HPDF_ENCODING_ISO8859_14 "ISO8859-14"
51 #define HPDF_ENCODING_ISO8859_15 "ISO8859-15"
52 #define HPDF_ENCODING_ISO8859_16 "ISO8859-16"
53 #define HPDF_ENCODING_CP1250 "CP1250"
54 #define HPDF_ENCODING_CP1251 "CP1251"
55 #define HPDF_ENCODING_CP1252 "CP1252"
56 #define HPDF_ENCODING_CP1253 "CP1253"
57 #define HPDF_ENCODING_CP1254 "CP1254"
58 #define HPDF_ENCODING_CP1255 "CP1255"
59 #define HPDF_ENCODING_CP1256 "CP1256"
60 #define HPDF_ENCODING_CP1257 "CP1257"
61 #define HPDF_ENCODING_CP1258 "CP1258"
62 #define HPDF_ENCODING_KOI8_R "KOI8-R"
63 
64 /*----------------------------------------------------------------------------*/
65 /*----- definition for font encoding -----------------------------------------*/
66 
67 #define char_NOTDEF ".notdef"
68 
69 typedef enum _HPDF_EncodingType {
76 
77 
78 typedef struct _HPDF_ParseText_Rec {
79  const HPDF_BYTE *text;
84 
85 
87 
90  HPDF_ParseText_Rec *state);
91 
92 typedef HPDF_UNICODE
94  HPDF_UINT16 code);
95 
96 typedef char *
97 (*HPDF_Encoder_EncodeText_Func) (HPDF_Encoder encoder,
98  const char *text,
99  HPDF_UINT len,
100  HPDF_UINT *encoded_length);
101 
102 typedef HPDF_STATUS
104  HPDF_Stream out);
105 
106 
107 typedef HPDF_STATUS
109 
110 
111 typedef void
113 
114 
115 typedef struct _HPDF_Encoder_Rec {
121 
128  /*
129  char lang_code[3];
130  char country_code[3];
131  */
132  void *attr;
134 
135 
136 typedef enum _HPDF_BaseEncodings {
143 
146 
147 void
149  HPDF_ParseText_Rec *state,
150  const HPDF_BYTE *text,
151  HPDF_UINT len);
152 
155  HPDF_ParseText_Rec *state);
156 
157 
158 
161  HPDF_UINT16 code);
162 
163 
164 void
166 
167 /*-- HPDF_BasicEncoder ----------------------------------*/
168 
169 
171 
180 
181 
184  const char *encoding_name);
185 
186 
187 void
189 
190 
193  HPDF_Stream out);
194 
195 
198  HPDF_UINT16 code);
199 
200 /*-- HPDF_CMapEncoder ----------------------------------*/
201 
202 typedef HPDF_BOOL
204  HPDF_BYTE b);
205 
206 typedef struct _HPDF_CidRange_Rec {
211 
212 
213 typedef struct _HPDF_UnicodeMap_Rec {
217 
219 
222  HPDF_UINT16 cid_map[256][256];
236 
237 
240  char *name,
241  HPDF_Encoder_Init_Func init_fn);
242 
243 
246 
247 
248 void
250 
251 
254  HPDF_Stream out);
255 
256 
259  HPDF_UINT16 code);
260 
263  HPDF_UINT16 code);
264 
267  HPDF_ParseText_Rec *state,
268  const HPDF_BYTE *text,
269  HPDF_UINT len);
270 
273  HPDF_ParseText_Rec *state);
274 
275 
278  const HPDF_CidRange_Rec *range);
279 
280 
283  HPDF_CidRange_Rec range);
284 
285 
288  HPDF_CidRange_Rec range);
289 
290 
291 void
293  const HPDF_UnicodeMap_Rec *array1);
294 
295 
298  const HPDF_UINT16 *code);
299 
300 HPDF_BOOL
302  const HPDF_UINT16 code);
303 
304 /*-- utility functions ----------------------------------*/
305 
306 const char*
308 
309 
311 HPDF_GryphNameToUnicode (const char *gryph_name);
312 
313 #ifdef __cplusplus
314 }
315 #endif /* __cplusplus */
316 
317 #endif /* _HPDF_ENCODER_H */
318 
#define HPDF_LIMIT_MAX_NAME_LEN
Definition: hpdf_consts.h:120
#define HPDF_MAX_JWW_NUM
Definition: hpdf_consts.h:155
struct _HPDF_CMapEncoderAttr_Rec HPDF_CMapEncoderAttr_Rec
HPDF_UNICODE HPDF_BasicEncoder_ToUnicode(HPDF_Encoder encoder, HPDF_UINT16 code)
HPDF_Encoder HPDF_CMapEncoder_New(HPDF_MMgr mmgr, char *name, HPDF_Encoder_Init_Func init_fn)
HPDF_ByteType HPDF_Encoder_ByteType(HPDF_Encoder encoder, HPDF_ParseText_Rec *state)
void HPDF_CMapEncoder_SetUnicodeArray(HPDF_Encoder encoder, const HPDF_UnicodeMap_Rec *array1)
void HPDF_Encoder_Free(HPDF_Encoder encoder)
void HPDF_BasicEncoder_Free(HPDF_Encoder encoder)
const char * HPDF_UnicodeToGryphName(HPDF_UNICODE unicode)
struct _HPDF_ParseText_Rec HPDF_ParseText_Rec
HPDF_STATUS(* HPDF_Encoder_Write_Func)(HPDF_Encoder encoder, HPDF_Stream out)
Definition: hpdf_encoder.h:103
HPDF_STATUS HPDF_CMapEncoder_SetParseText(HPDF_Encoder encoder, HPDF_ParseText_Rec *state, const HPDF_BYTE *text, HPDF_UINT len)
HPDF_STATUS HPDF_CMapEncoder_AddNotDefRange(HPDF_Encoder encoder, HPDF_CidRange_Rec range)
HPDF_Encoder HPDF_BasicEncoder_New(HPDF_MMgr mmgr, const char *encoding_name)
void HPDF_Encoder_SetParseText(HPDF_Encoder encoder, HPDF_ParseText_Rec *state, const HPDF_BYTE *text, HPDF_UINT len)
void HPDF_CMapEncoder_Free(HPDF_Encoder encoder)
HPDF_STATUS HPDF_BasicEncoder_Write(HPDF_Encoder encoder, HPDF_Stream out)
struct _HPDF_BasicEncoderAttr_Rec HPDF_BasicEncoderAttr_Rec
enum _HPDF_BaseEncodings HPDF_BaseEncodings
HPDF_ByteType(* HPDF_Encoder_ByteType_Func)(HPDF_Encoder encoder, HPDF_ParseText_Rec *state)
Definition: hpdf_encoder.h:89
HPDF_STATUS HPDF_CMapEncoder_AddJWWLineHead(HPDF_Encoder encoder, const HPDF_UINT16 *code)
HPDF_STATUS HPDF_CMapEncoder_AddCMap(HPDF_Encoder encoder, const HPDF_CidRange_Rec *range)
struct _HPDF_BasicEncoderAttr_Rec * HPDF_BasicEncoderAttr
Definition: hpdf_encoder.h:170
struct _HPDF_UnicodeMap_Rec HPDF_UnicodeMap_Rec
struct _HPDF_Encoder_Rec * HPDF_Encoder
Definition: hpdf_encoder.h:86
struct _HPDF_Encoder_Rec HPDF_Encoder_Rec
HPDF_STATUS HPDF_Encoder_Validate(HPDF_Encoder encoder)
_HPDF_EncodingType
Definition: hpdf_encoder.h:69
@ HPDF_ENCODING_EOF
Definition: hpdf_encoder.h:74
@ HPDF_WIN_ANSI_ENCODING
Definition: hpdf_encoder.h:72
@ HPDF_FONT_SPECIFIC
Definition: hpdf_encoder.h:73
@ HPDF_STANDARD_ENCODING
Definition: hpdf_encoder.h:70
@ HPDF_MAC_ROMAN_ENCODING
Definition: hpdf_encoder.h:71
_HPDF_BaseEncodings
Definition: hpdf_encoder.h:136
@ HPDF_BASE_ENCODING_MAC_ROMAN
Definition: hpdf_encoder.h:139
@ HPDF_BASE_ENCODING_EOF
Definition: hpdf_encoder.h:141
@ HPDF_BASE_ENCODING_FONT_SPECIFIC
Definition: hpdf_encoder.h:140
@ HPDF_BASE_ENCODING_STANDARD
Definition: hpdf_encoder.h:137
@ HPDF_BASE_ENCODING_WIN_ANSI
Definition: hpdf_encoder.h:138
enum _HPDF_EncodingType HPDF_EncodingType
HPDF_STATUS HPDF_CMapEncoder_InitAttr(HPDF_Encoder encoder)
HPDF_UNICODE HPDF_GryphNameToUnicode(const char *gryph_name)
struct _HPDF_CMapEncoderAttr_Rec * HPDF_CMapEncoderAttr
Definition: hpdf_encoder.h:218
struct _HPDF_CidRange_Rec HPDF_CidRange_Rec
HPDF_ByteType HPDF_CMapEncoder_ByteType(HPDF_Encoder encoder, HPDF_ParseText_Rec *state)
void(* HPDF_Encoder_Free_Func)(HPDF_Encoder encoder)
Definition: hpdf_encoder.h:112
HPDF_STATUS(* HPDF_Encoder_Init_Func)(HPDF_Encoder encoder)
Definition: hpdf_encoder.h:108
char *(* HPDF_Encoder_EncodeText_Func)(HPDF_Encoder encoder, const char *text, HPDF_UINT len, HPDF_UINT *encoded_length)
Definition: hpdf_encoder.h:97
HPDF_UINT16 HPDF_CMapEncoder_ToCID(HPDF_Encoder encoder, HPDF_UINT16 code)
HPDF_UNICODE HPDF_Encoder_ToUnicode(HPDF_Encoder encoder, HPDF_UINT16 code)
HPDF_STATUS HPDF_CMapEncoder_Write(HPDF_Encoder encoder, HPDF_Stream out)
HPDF_STATUS HPDF_CMapEncoder_AddCodeSpaceRange(HPDF_Encoder encoder, HPDF_CidRange_Rec range)
HPDF_BOOL(* HPDF_CMapEncoder_ByteType_Func)(HPDF_Encoder encoder, HPDF_BYTE b)
Definition: hpdf_encoder.h:203
HPDF_UNICODE HPDF_CMapEncoder_ToUnicode(HPDF_Encoder encoder, HPDF_UINT16 code)
HPDF_BOOL HPDF_Encoder_CheckJWWLineHead(HPDF_Encoder encoder, const HPDF_UINT16 code)
HPDF_UNICODE(* HPDF_Encoder_ToUnicode_Func)(HPDF_Encoder encoder, HPDF_UINT16 code)
Definition: hpdf_encoder.h:93
signed int HPDF_INT
Definition: hpdf_types.h:44
unsigned short HPDF_UINT16
Definition: hpdf_types.h:63
signed int HPDF_BOOL
Definition: hpdf_types.h:89
unsigned int HPDF_UINT
Definition: hpdf_types.h:45
unsigned int HPDF_UINT32
Definition: hpdf_types.h:57
enum _HPDF_ByteType HPDF_ByteType
HPDF_UINT16 HPDF_UNICODE
Definition: hpdf_types.h:100
unsigned char HPDF_BYTE
Definition: hpdf_types.h:74
enum _HPDF_EncoderType HPDF_EncoderType
unsigned long HPDF_STATUS
Definition: hpdf_types.h:94
enum _HPDF_WritingMode HPDF_WritingMode
Definition: hpdf_encoder.h:172
char base_encoding[HPDF_LIMIT_MAX_NAME_LEN+1]
Definition: hpdf_encoder.h:173
HPDF_BYTE first_char
Definition: hpdf_encoder.h:174
HPDF_BYTE differences[256]
Definition: hpdf_encoder.h:178
HPDF_BOOL has_differences
Definition: hpdf_encoder.h:177
HPDF_UNICODE unicode_map[256]
Definition: hpdf_encoder.h:176
HPDF_BYTE last_char
Definition: hpdf_encoder.h:175
Definition: hpdf_encoder.h:220
HPDF_List notdef_range
Definition: hpdf_encoder.h:225
HPDF_UINT16 cid_map[256][256]
Definition: hpdf_encoder.h:222
HPDF_CMapEncoder_ByteType_Func is_lead_byte_fn
Definition: hpdf_encoder.h:231
HPDF_INT suppliment
Definition: hpdf_encoder.h:230
char registry[HPDF_LIMIT_MAX_NAME_LEN+1]
Definition: hpdf_encoder.h:228
HPDF_List cmap_range
Definition: hpdf_encoder.h:224
HPDF_CMapEncoder_ByteType_Func is_trial_byte_fn
Definition: hpdf_encoder.h:232
HPDF_List code_space_range
Definition: hpdf_encoder.h:226
HPDF_UINT16 jww_line_head[HPDF_MAX_JWW_NUM]
Definition: hpdf_encoder.h:223
HPDF_INT uid_offset
Definition: hpdf_encoder.h:233
HPDF_UINT xuid[3]
Definition: hpdf_encoder.h:234
char ordering[HPDF_LIMIT_MAX_NAME_LEN+1]
Definition: hpdf_encoder.h:229
HPDF_WritingMode writing_mode
Definition: hpdf_encoder.h:227
HPDF_UNICODE unicode_map[256][256]
Definition: hpdf_encoder.h:221
Definition: hpdf_encoder.h:206
HPDF_UINT16 from
Definition: hpdf_encoder.h:207
HPDF_UINT16 cid
Definition: hpdf_encoder.h:209
HPDF_UINT16 to
Definition: hpdf_encoder.h:208
Definition: hpdf_encoder.h:115
HPDF_MMgr mmgr
Definition: hpdf_encoder.h:118
HPDF_Encoder_ByteType_Func byte_type_fn
Definition: hpdf_encoder.h:122
HPDF_EncoderType type
Definition: hpdf_encoder.h:120
HPDF_Encoder_ToUnicode_Func to_unicode_fn
Definition: hpdf_encoder.h:123
char name[HPDF_LIMIT_MAX_NAME_LEN+1]
Definition: hpdf_encoder.h:117
HPDF_Encoder_Init_Func init_fn
Definition: hpdf_encoder.h:127
HPDF_Error error
Definition: hpdf_encoder.h:119
HPDF_Encoder_Write_Func write_fn
Definition: hpdf_encoder.h:125
HPDF_Encoder_Free_Func free_fn
Definition: hpdf_encoder.h:126
void * attr
Definition: hpdf_encoder.h:132
HPDF_UINT32 sig_bytes
Definition: hpdf_encoder.h:116
HPDF_Encoder_EncodeText_Func encode_text_fn
Definition: hpdf_encoder.h:124
Definition: hpdf_error.h:180
Definition: hpdf_list.h:30
Definition: hpdf_mmgr.h:40
Definition: hpdf_encoder.h:78
HPDF_UINT len
Definition: hpdf_encoder.h:81
HPDF_UINT index
Definition: hpdf_encoder.h:80
HPDF_ByteType byte_type
Definition: hpdf_encoder.h:82
const HPDF_BYTE * text
Definition: hpdf_encoder.h:79
Definition: hpdf_streams.h:99
Definition: hpdf_encoder.h:213
HPDF_UINT16 unicode
Definition: hpdf_encoder.h:215
HPDF_UINT16 code
Definition: hpdf_encoder.h:214