Haru Free PDF Library
hpdf_fontdef.h
Go to the documentation of this file.
1 /*
2  * << Haru Free PDF Library >> -- hpdf_fontdef.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_FONTDEF_H
19 #define _HPDF_FONTDEF_H
20 
21 #include "hpdf_objects.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 
28 #define HPDF_FONTDEF_SIG_BYTES 0x464F4E54L
29 
30 /*------ collection of flags for defining characteristics. ---*/
31 
32 #define HPDF_FONT_FIXED_WIDTH 1
33 #define HPDF_FONT_SERIF 2
34 #define HPDF_FONT_SYMBOLIC 4
35 #define HPDF_FONT_SCRIPT 8
36  /* Reserved 16 */
37 #define HPDF_FONT_STD_CHARSET 32
38 #define HPDF_FONT_ITALIC 64
39  /* Reserved 128
40  Reserved 256
41  Reserved 512
42  Reserved 1024
43  Reserved 2048
44  Reserved 4096
45  Reserved 8192
46  Reserved 16384
47  Reserved 32768 */
48 #define HPDF_FONT_ALL_CAP 65536
49 #define HPDF_FONT_SMALL_CAP 131072
50 #define HPDF_FONT_FOURCE_BOLD 262144
51 
52 #define HPDF_CID_W_TYPE_FROM_TO 0
53 #define HPDF_CID_W_TYPE_FROM_ARRAY 1
54 
55 /*-- HPDF_FontDef ---------------------------------------*/
56 
57 typedef struct _HPDF_CharData {
62 
63 typedef enum _HPDF_FontDefType {
70 
71 typedef struct _HPDF_CID_Width {
75 
76 /*----------------------------------------------------------------------------*/
77 /*----- HPDF_FontDef ---------------------------------------------------------*/
78 
80 
81 typedef void (*HPDF_FontDef_FreeFunc) (HPDF_FontDef fontdef);
82 
83 typedef void (*HPDF_FontDef_CleanFunc) (HPDF_FontDef fontdef);
84 
86 
87 typedef struct _HPDF_FontDef_Rec {
96 
109 
110  /* the initial value of descriptor entry is NULL.
111  * when first font-object based on the fontdef object is created,
112  * the font-descriptor object is created and descriptor entry is set.
113  */
116 
118  void *attr;
120 
121 
122 void
124 
125 
126 void
128 
129 
130 HPDF_BOOL
132 
133 
134 /*----------------------------------------------------------------------------*/
135 /*----- HPDF_Type1FontDef ---------------------------------------------------*/
136 
138 
140  HPDF_BYTE first_char; /* Required */
141  HPDF_BYTE last_char; /* Required */
142  HPDF_CharData *widths; /* Required */
144 
146  char *char_set;
153 
156 
157 
158 
161 
162 
165  HPDF_Stream afm,
166  HPDF_Stream font_data);
167 
168 
171  HPDF_FontDef src);
172 
173 
176  const HPDF_CharData *widths);
177 
178 
181  const char *gryph_name);
182 
183 
186  HPDF_UNICODE unicode);
187 
188 
191  const char *font_name);
192 
193 
194 
195 /*----------------------------------------------------------------------------*/
196 /*----- HPDF_TTFontDef ------------------------------------------------------*/
197 
198 #define HPDF_TTF_FONT_TAG_LEN 6
199 
200 typedef struct _HPDF_TTF_Table {
201  char tag[4];
206 
207 
208 typedef struct _HPDF_TTF_OffsetTbl {
216 
217 
218 typedef struct _HPDF_TTF_CmapRange {
234 
235 
236 typedef struct _HPDF_TTF_GryphOffsets {
239  HPDF_BYTE *flgs; /* 0: unused, 1: used */
241 
242 
243 typedef struct _HPDF_TTF_LongHorMetric {
247 
248 
249 typedef struct _HPDF_TTF_FontHeader {
268 
269 
270 typedef struct _HPDF_TTF_NameRecord {
278 
279 
280 typedef struct _HPDF_TTF_NamingTable {
286 
287 
289 
290 typedef struct _HPDF_TTFontDefAttr_Rec {
294  char *char_set;
310 
312 
315 
318 
319 
320 
323 
324 
327  HPDF_Stream stream,
328  HPDF_BOOL embedding);
329 
330 
333  HPDF_Stream stream,
334  HPDF_UINT index,
335  HPDF_BOOL embedding);
336 
337 
340  HPDF_UINT16 unicode);
341 
342 
345  HPDF_UINT16 unicode);
346 
347 
350  HPDF_UINT16 gid);
351 
352 
355  HPDF_Stream stream);
356 
357 
358 HPDF_Box
360  HPDF_UINT16 unicode);
361 
362 
363 void
365  char *tag);
366 
367 
368 /*----------------------------------------------------------------------------*/
369 /*----- HPDF_CIDFontDef -----------------------------------------------------*/
370 
372 
373 typedef struct _HPDF_CIDFontDefAttrRec {
378 
379 
382  char *name,
383  HPDF_FontDef_InitFunc init_fn);
384 
385 
388  const HPDF_CID_Width *widths);
389 
390 
393  HPDF_UINT16 cid);
394 
395 
396 
399  HPDF_BOOL bold,
400  HPDF_BOOL italic);
401 
402 #ifdef __cplusplus
403 }
404 #endif /* __cplusplus */
405 
406 #endif /* _HPDF_FONTDEF_H */
#define HPDF_LIMIT_MAX_NAME_LEN
Definition: hpdf_consts.h:120
struct _HPDF_TTF_NamingTable HPDF_TTF_NamingTable
struct _HPDF_FontDef_Rec * HPDF_FontDef
Definition: hpdf_fontdef.h:79
HPDF_UINT16 HPDF_TTFontDef_GetGlyphid(HPDF_FontDef fontdef, HPDF_UINT16 unicode)
HPDF_FontDef HPDF_Type1FontDef_New(HPDF_MMgr mmgr)
HPDF_Box HPDF_TTFontDef_GetCharBBox(HPDF_FontDef fontdef, HPDF_UINT16 unicode)
enum _HPDF_FontDefType HPDF_FontDefType
_HPDF_FontDefType
Definition: hpdf_fontdef.h:63
@ HPDF_FONTDEF_TYPE_CID
Definition: hpdf_fontdef.h:66
@ HPDF_FONTDEF_TYPE_UNINITIALIZED
Definition: hpdf_fontdef.h:67
@ HPDF_FONTDEF_TYPE_TRUETYPE
Definition: hpdf_fontdef.h:65
@ HPDF_FONTDEF_TYPE_EOF
Definition: hpdf_fontdef.h:68
@ HPDF_FONTDEF_TYPE_TYPE1
Definition: hpdf_fontdef.h:64
HPDF_FontDef HPDF_Type1FontDef_Duplicate(HPDF_MMgr mmgr, HPDF_FontDef src)
void HPDF_FontDef_Free(HPDF_FontDef fontdef)
HPDF_INT16 HPDF_CIDFontDef_GetCIDWidth(HPDF_FontDef fontdef, HPDF_UINT16 cid)
HPDF_STATUS HPDF_Type1FontDef_SetWidths(HPDF_FontDef fontdef, const HPDF_CharData *widths)
struct _HPDF_CIDFontDefAttrRec * HPDF_CIDFontDefAttr
Definition: hpdf_fontdef.h:371
struct _HPDF_TTF_NameRecord HPDF_TTF_NameRecord
struct _HPDF_CID_Width HPDF_CID_Width
#define HPDF_TTF_FONT_TAG_LEN
Definition: hpdf_fontdef.h:198
HPDF_INT16 HPDF_TTFontDef_GetGidWidth(HPDF_FontDef fontdef, HPDF_UINT16 gid)
struct _HPDF_TTF_OffsetTbl HPDF_TTF_OffsetTbl
struct _HPDF_TTFontDefAttr_Rec * HPDF_TTFontDefAttr
Definition: hpdf_fontdef.h:288
HPDF_STATUS HPDF_CIDFontDef_AddWidth(HPDF_FontDef fontdef, const HPDF_CID_Width *widths)
struct _HPDF_Type1FontDefAttrRec HPDF_Type1FontDefAttr_Rec
void HPDF_FontDef_Cleanup(HPDF_FontDef fontdef)
HPDF_STATUS HPDF_TTFontDef_SaveFontData(HPDF_FontDef fontdef, HPDF_Stream stream)
HPDF_STATUS HPDF_CIDFontDef_ChangeStyle(HPDF_FontDef fontdef, HPDF_BOOL bold, HPDF_BOOL italic)
struct _HPDF_TTF_FontHeader HPDF_TTF_FontHeader
struct _HPDF_TTF_Table HPDF_TTFTable
HPDF_FontDef HPDF_CIDFontDef_New(HPDF_MMgr mmgr, char *name, HPDF_FontDef_InitFunc init_fn)
void HPDF_TTFontDef_SetTagName(HPDF_FontDef fontdef, char *tag)
HPDF_INT16 HPDF_TTFontDef_GetCharWidth(HPDF_FontDef fontdef, HPDF_UINT16 unicode)
HPDF_FontDef HPDF_Base14FontDef_New(HPDF_MMgr mmgr, const char *font_name)
HPDF_FontDef HPDF_Type1FontDef_Load(HPDF_MMgr mmgr, HPDF_Stream afm, HPDF_Stream font_data)
struct _HPDF_CIDFontDefAttrRec HPDF_CIDFontDefAttr_Rec
struct _HPDF_TTF_GryphOffsets HPDF_TTF_GryphOffsets
struct _HPDF_TTF_LongHorMetric HPDF_TTF_LongHorMetric
HPDF_FontDef HPDF_TTFontDef_Load(HPDF_MMgr mmgr, HPDF_Stream stream, HPDF_BOOL embedding)
HPDF_INT16 HPDF_Type1FontDef_GetWidth(HPDF_FontDef fontdef, HPDF_UNICODE unicode)
HPDF_BOOL HPDF_FontDef_Validate(HPDF_FontDef fontdef)
HPDF_INT16 HPDF_Type1FontDef_GetWidthByName(HPDF_FontDef fontdef, const char *gryph_name)
HPDF_FontDef HPDF_TTFontDef_New(HPDF_MMgr mmgr)
HPDF_FontDef HPDF_TTFontDef_Load2(HPDF_MMgr mmgr, HPDF_Stream stream, HPDF_UINT index, HPDF_BOOL embedding)
struct _HPDF_FontDef_Rec HPDF_FontDef_Rec
struct _HPDF_TTF_CmapRange HPDF_TTF_CmapRange
struct _HPDF_Type1FontDefAttrRec * HPDF_Type1FontDefAttr
Definition: hpdf_fontdef.h:137
HPDF_STATUS(* HPDF_FontDef_InitFunc)(HPDF_FontDef fontdef)
Definition: hpdf_fontdef.h:85
struct _HPDF_CharData HPDF_CharData
struct _HPDF_TTFontDefAttr_Rec HPDF_TTFontDefAttr_Rec
void(* HPDF_FontDef_FreeFunc)(HPDF_FontDef fontdef)
Definition: hpdf_fontdef.h:81
void(* HPDF_FontDef_CleanFunc)(HPDF_FontDef fontdef)
Definition: hpdf_fontdef.h:83
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
HPDF_UINT16 HPDF_UNICODE
Definition: hpdf_types.h:100
unsigned char HPDF_BYTE
Definition: hpdf_types.h:74
unsigned long HPDF_STATUS
Definition: hpdf_types.h:94
signed short HPDF_INT16
Definition: hpdf_types.h:62
Definition: hpdf_fontdef.h:373
HPDF_INT16 DW2[2]
Definition: hpdf_fontdef.h:376
HPDF_List widths
Definition: hpdf_fontdef.h:374
HPDF_INT16 DW
Definition: hpdf_fontdef.h:375
Definition: hpdf_fontdef.h:71
HPDF_INT16 width
Definition: hpdf_fontdef.h:73
HPDF_UINT16 cid
Definition: hpdf_fontdef.h:72
Definition: hpdf_fontdef.h:57
HPDF_INT16 width
Definition: hpdf_fontdef.h:60
HPDF_UNICODE unicode
Definition: hpdf_fontdef.h:59
HPDF_INT16 char_cd
Definition: hpdf_fontdef.h:58
Definition: hpdf_objects.h:421
Definition: hpdf_error.h:180
Definition: hpdf_fontdef.h:87
HPDF_Dict descriptor
Definition: hpdf_fontdef.h:114
HPDF_Error error
Definition: hpdf_fontdef.h:91
HPDF_FontDef_FreeFunc free_fn
Definition: hpdf_fontdef.h:94
HPDF_INT16 descent
Definition: hpdf_fontdef.h:98
HPDF_INT16 avg_width
Definition: hpdf_fontdef.h:103
HPDF_MMgr mmgr
Definition: hpdf_fontdef.h:90
HPDF_UINT16 stemv
Definition: hpdf_fontdef.h:102
HPDF_FontDef_CleanFunc clean_fn
Definition: hpdf_fontdef.h:93
HPDF_FontDef_InitFunc init_fn
Definition: hpdf_fontdef.h:95
void * attr
Definition: hpdf_fontdef.h:118
HPDF_UINT32 sig_bytes
Definition: hpdf_fontdef.h:88
HPDF_Stream data
Definition: hpdf_fontdef.h:115
char base_font[HPDF_LIMIT_MAX_NAME_LEN+1]
Definition: hpdf_fontdef.h:89
HPDF_INT16 ascent
Definition: hpdf_fontdef.h:97
HPDF_UINT16 stemh
Definition: hpdf_fontdef.h:106
HPDF_INT16 missing_width
Definition: hpdf_fontdef.h:105
HPDF_INT16 max_width
Definition: hpdf_fontdef.h:104
HPDF_UINT flags
Definition: hpdf_fontdef.h:99
HPDF_INT16 italic_angle
Definition: hpdf_fontdef.h:101
HPDF_FontDefType type
Definition: hpdf_fontdef.h:92
HPDF_UINT16 cap_height
Definition: hpdf_fontdef.h:108
HPDF_Box font_bbox
Definition: hpdf_fontdef.h:100
HPDF_BOOL valid
Definition: hpdf_fontdef.h:117
HPDF_UINT16 x_height
Definition: hpdf_fontdef.h:107
Definition: hpdf_list.h:30
Definition: hpdf_mmgr.h:40
Definition: hpdf_types.h:110
Definition: hpdf_streams.h:99
Definition: hpdf_fontdef.h:218
HPDF_UINT16 range_shift
Definition: hpdf_fontdef.h:225
HPDF_UINT16 reserved_pad
Definition: hpdf_fontdef.h:227
HPDF_UINT16 * end_count
Definition: hpdf_fontdef.h:226
HPDF_UINT16 * start_count
Definition: hpdf_fontdef.h:228
HPDF_UINT glyph_id_array_count
Definition: hpdf_fontdef.h:232
HPDF_UINT16 seg_count_x2
Definition: hpdf_fontdef.h:222
HPDF_UINT16 entry_selector
Definition: hpdf_fontdef.h:224
HPDF_UINT16 format
Definition: hpdf_fontdef.h:219
HPDF_UINT16 * glyph_id_array
Definition: hpdf_fontdef.h:231
HPDF_UINT16 * id_range_offset
Definition: hpdf_fontdef.h:230
HPDF_UINT16 length
Definition: hpdf_fontdef.h:220
HPDF_UINT16 language
Definition: hpdf_fontdef.h:221
HPDF_INT16 * id_delta
Definition: hpdf_fontdef.h:229
HPDF_UINT16 search_range
Definition: hpdf_fontdef.h:223
Definition: hpdf_fontdef.h:249
HPDF_INT16 font_direction_hint
Definition: hpdf_fontdef.h:264
HPDF_BYTE modified[8]
Definition: hpdf_fontdef.h:257
HPDF_INT16 x_max
Definition: hpdf_fontdef.h:260
HPDF_UINT16 units_per_em
Definition: hpdf_fontdef.h:255
HPDF_BYTE created[8]
Definition: hpdf_fontdef.h:256
HPDF_BYTE version_number[4]
Definition: hpdf_fontdef.h:250
HPDF_INT16 glyph_data_format
Definition: hpdf_fontdef.h:266
HPDF_INT16 y_min
Definition: hpdf_fontdef.h:259
HPDF_UINT32 magic_number
Definition: hpdf_fontdef.h:253
HPDF_INT16 index_to_loc_format
Definition: hpdf_fontdef.h:265
HPDF_UINT16 mac_style
Definition: hpdf_fontdef.h:262
HPDF_UINT32 font_revision
Definition: hpdf_fontdef.h:251
HPDF_UINT16 flags
Definition: hpdf_fontdef.h:254
HPDF_INT16 x_min
Definition: hpdf_fontdef.h:258
HPDF_INT16 y_max
Definition: hpdf_fontdef.h:261
HPDF_UINT32 check_sum_adjustment
Definition: hpdf_fontdef.h:252
HPDF_UINT16 lowest_rec_ppem
Definition: hpdf_fontdef.h:263
Definition: hpdf_fontdef.h:236
HPDF_BYTE * flgs
Definition: hpdf_fontdef.h:239
HPDF_UINT32 * offsets
Definition: hpdf_fontdef.h:238
HPDF_UINT32 base_offset
Definition: hpdf_fontdef.h:237
Definition: hpdf_fontdef.h:243
HPDF_UINT16 advance_width
Definition: hpdf_fontdef.h:244
HPDF_INT16 lsb
Definition: hpdf_fontdef.h:245
Definition: hpdf_fontdef.h:270
HPDF_UINT16 platform_id
Definition: hpdf_fontdef.h:271
HPDF_UINT16 language_id
Definition: hpdf_fontdef.h:273
HPDF_UINT16 encoding_id
Definition: hpdf_fontdef.h:272
HPDF_UINT16 offset
Definition: hpdf_fontdef.h:276
HPDF_UINT16 name_id
Definition: hpdf_fontdef.h:274
HPDF_UINT16 length
Definition: hpdf_fontdef.h:275
Definition: hpdf_fontdef.h:280
HPDF_UINT16 count
Definition: hpdf_fontdef.h:282
HPDF_UINT16 string_offset
Definition: hpdf_fontdef.h:283
HPDF_TTF_NameRecord * name_records
Definition: hpdf_fontdef.h:284
HPDF_UINT16 format
Definition: hpdf_fontdef.h:281
Definition: hpdf_fontdef.h:208
HPDF_UINT16 num_tables
Definition: hpdf_fontdef.h:210
HPDF_UINT32 sfnt_version
Definition: hpdf_fontdef.h:209
HPDF_TTFTable * table
Definition: hpdf_fontdef.h:214
HPDF_UINT16 search_range
Definition: hpdf_fontdef.h:211
HPDF_UINT16 range_shift
Definition: hpdf_fontdef.h:213
HPDF_UINT16 entry_selector
Definition: hpdf_fontdef.h:212
Definition: hpdf_fontdef.h:200
HPDF_UINT32 length
Definition: hpdf_fontdef.h:204
HPDF_UINT32 check_sum
Definition: hpdf_fontdef.h:202
HPDF_UINT32 offset
Definition: hpdf_fontdef.h:203
char tag[4]
Definition: hpdf_fontdef.h:201
Definition: hpdf_fontdef.h:290
HPDF_TTF_FontHeader header
Definition: hpdf_fontdef.h:297
HPDF_Stream stream
Definition: hpdf_fontdef.h:316
HPDF_BYTE panose[10]
Definition: hpdf_fontdef.h:307
HPDF_TTF_GryphOffsets glyph_tbl
Definition: hpdf_fontdef.h:298
char * char_set
Definition: hpdf_fontdef.h:294
HPDF_UINT16 num_h_metric
Definition: hpdf_fontdef.h:302
HPDF_BOOL is_cidfont
Definition: hpdf_fontdef.h:314
HPDF_BYTE first_char
Definition: hpdf_fontdef.h:292
HPDF_TTF_NamingTable name_tbl
Definition: hpdf_fontdef.h:300
HPDF_UINT32 code_page_range2
Definition: hpdf_fontdef.h:309
HPDF_UINT32 code_page_range1
Definition: hpdf_fontdef.h:308
char tag_name[HPDF_TTF_FONT_TAG_LEN+1]
Definition: hpdf_fontdef.h:295
char base_font[HPDF_LIMIT_MAX_NAME_LEN+1]
Definition: hpdf_fontdef.h:291
HPDF_UINT length1
Definition: hpdf_fontdef.h:311
HPDF_TTF_LongHorMetric * h_metric
Definition: hpdf_fontdef.h:301
HPDF_TTF_CmapRange cmap
Definition: hpdf_fontdef.h:304
HPDF_TTF_OffsetTbl offset_tbl
Definition: hpdf_fontdef.h:303
HPDF_UINT16 fs_type
Definition: hpdf_fontdef.h:305
char tag_name2[(HPDF_TTF_FONT_TAG_LEN+1) *2]
Definition: hpdf_fontdef.h:296
HPDF_BYTE last_char
Definition: hpdf_fontdef.h:293
HPDF_BOOL embedding
Definition: hpdf_fontdef.h:313
HPDF_BYTE sfamilyclass[2]
Definition: hpdf_fontdef.h:306
HPDF_UINT16 num_glyphs
Definition: hpdf_fontdef.h:299
Definition: hpdf_fontdef.h:139
HPDF_BOOL is_base14font
Definition: hpdf_fontdef.h:151
HPDF_BOOL is_fixed_pitch
Definition: hpdf_fontdef.h:152
HPDF_UINT length1
Definition: hpdf_fontdef.h:148
HPDF_BYTE last_char
Definition: hpdf_fontdef.h:141
HPDF_INT16 leading
Definition: hpdf_fontdef.h:145
HPDF_UINT length2
Definition: hpdf_fontdef.h:149
HPDF_CharData * widths
Definition: hpdf_fontdef.h:142
char encoding_scheme[HPDF_LIMIT_MAX_NAME_LEN+1]
Definition: hpdf_fontdef.h:147
HPDF_BYTE first_char
Definition: hpdf_fontdef.h:140
HPDF_UINT widths_count
Definition: hpdf_fontdef.h:143
char * char_set
Definition: hpdf_fontdef.h:146
HPDF_UINT length3
Definition: hpdf_fontdef.h:150
HPDF_Stream font_data
Definition: hpdf_fontdef.h:154