~ubuntu-branches/ubuntu/saucy/luatex/saucy

« back to all changes in this revision

Viewing changes to source/texk/web2c/luatexdir/pdf/pdftypes.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2009-12-25 09:47:05 UTC
  • mfrom: (1.1.9 upstream) (4.2.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091225094705-y33rpflo8t4u9nag
Tags: 0.50.0-1
* new upstream release
* disable fix-hurd-ftbfs patch, included upstream
* disable upstram-fixes, included upstream
* disable ubuntu_libpoppler-0.11, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* pdftypes.h
 
2
 
 
3
   Copyright 2009 Taco Hoekwater <taco@luatex.org>
 
4
 
 
5
   This file is part of LuaTeX.
 
6
 
 
7
   LuaTeX is free software; you can redistribute it and/or modify it under
 
8
   the terms of the GNU General Public License as published by the Free
 
9
   Software Foundation; either version 2 of the License, or (at your
 
10
   option) any later version.
 
11
 
 
12
   LuaTeX is distributed in the hope that it will be useful, but WITHOUT
 
13
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
14
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 
15
   License for more details.
 
16
 
 
17
   You should have received a copy of the GNU General Public License along
 
18
   with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
 
19
 
 
20
/* $Id: pdftypes.h 3275 2009-12-20 22:20:08Z hhenkel $ */
 
21
 
 
22
#ifndef PDFTYPES_H
 
23
#  define PDFTYPES_H
 
24
 
 
25
#  include <zlib.h>
 
26
 
 
27
/* This stucture holds everything that is needed for the actual pdf generation.
 
28
 
 
29
Because this structure interfaces with C++, it is not wise to use |boolean|
 
30
here (C++ has a boolean type built-in that is not compatible). Also, I have
 
31
plans to convert the backend code into a C library for use with e.g. standalone
 
32
lua. Together, this means that it is best only to use the standard C types and
 
33
the types explicitly defined in this header, and stay away from types like
 
34
|integer| and |eight_bits| that are used elsewhere in the \LUATEX\ sources.
 
35
 
 
36
 */
 
37
 
 
38
typedef struct os_obj_data_ {
 
39
    int num;
 
40
    int off;
 
41
} os_obj_data;
 
42
 
 
43
typedef struct {
 
44
    long m;                     /* mantissa (significand) */
 
45
    int e;                      /* exponent * -1 */
 
46
} pdffloat;
 
47
 
 
48
typedef struct {
 
49
    pdffloat h;
 
50
    pdffloat v;
 
51
} pdfpos;
 
52
 
 
53
#  define scaled int
 
54
 
 
55
typedef struct scaledpos_ {
 
56
    scaled h;
 
57
    scaled v;
 
58
} scaledpos;
 
59
 
 
60
typedef struct scaled_whd_ {
 
61
    scaled wd;                  /* TeX width */
 
62
    scaled ht;                  /* TeX height */
 
63
    scaled dp;                  /* TeX depth */
 
64
} scaled_whd;
 
65
 
 
66
typedef struct posstructure_ {
 
67
    scaledpos pos;              /* position on the page */
 
68
    int dir;                    /* direction of stuff to be put onto the page */
 
69
} posstructure;
 
70
 
 
71
typedef struct {
 
72
    scaledpos curpos;           /* \pdflastpos position */
 
73
    posstructure boxpos;        /* box dir and position of the box origin on the page */
 
74
    scaled_whd boxdim;          /* box dimensions (in hlist/vlist coordinate system) */
 
75
} pos_info_structure;
 
76
 
 
77
typedef enum { PMODE_NONE, PMODE_PAGE, PMODE_TEXT, PMODE_CHARARRAY, PMODE_CHAR
 
78
} pos_mode;
 
79
 
 
80
typedef enum { OMODE_NONE, OMODE_DVI, OMODE_PDF, OMODE_LUA } output_mode;
 
81
 
 
82
#  define MAX_OMODE 3           /* largest index in enum output_mode */
 
83
 
 
84
typedef enum { ST_INITIAL, ST_OMODE_FIX, ST_FILE_OPEN, ST_HEADER_WRITTEN,
 
85
    ST_FILE_CLOSED
 
86
} output_state;
 
87
 
 
88
typedef struct pdf_object_list_ {
 
89
    int info;
 
90
    struct pdf_object_list_ *link;
 
91
} pdf_object_list;
 
92
 
 
93
typedef enum { WMODE_H, WMODE_V } writing_mode; /* []TJ runs horizontal or vertical */
 
94
 
 
95
typedef struct {
 
96
    pdfpos pdf;                 /* pos. on page (PDF page raster) */
 
97
    pdfpos pdf_bt_pos;          /* pos. at begin of BT-ET group (PDF page raster) */
 
98
    pdfpos pdf_tj_pos;          /* pos. at begin of TJ array (PDF page raster) */
 
99
    pdffloat cw;                /* pos. within [(..)..]TJ array (glyph raster);
 
100
                                   cw.e = fractional digits in /Widths array */
 
101
    pdffloat tj_delta;          /* rel. movement in [(..)..]TJ array (glyph raster) */
 
102
    pdffloat fs;                /* font size in PDF units */
 
103
    pdffloat fs_cur;            /* to check if fs.m has changed and Tf needed */
 
104
    pdffloat cm[6];             /* cm array */
 
105
    pdffloat tm[6];             /* Tm array */
 
106
    double k1;                  /* conv. factor from TeX sp to PDF page raster */
 
107
    double k2;                  /* conv. factor from PDF page raster to TJ array raster */
 
108
    int f_pdf;                  /* /F* font number, of unexpanded base font! */
 
109
    int f_pdf_cur;              /* to check if f_pdf has changed and Tf needed */
 
110
    writing_mode wmode;         /* PDF writing mode WMode (horizontal/vertical) */
 
111
    pos_mode mode;              /* current positioning mode */
 
112
    int ishex;                  /* Whether the current char string is <> or () */
 
113
} pdfstructure;
 
114
 
 
115
typedef struct obj_entry_ {
 
116
    union {
 
117
        int int0;
 
118
        char *str0;
 
119
    } u;
 
120
    int int1;
 
121
    off_t int2;
 
122
    int int3;
 
123
    union {
 
124
        int int4;
 
125
        char *str4;
 
126
    } v;
 
127
    int objtype;                /* integer int5 */
 
128
} obj_entry;
 
129
 
 
130
typedef struct dest_name_entry_ {
 
131
    char *objname;              /* destination name */
 
132
    int objnum;                 /* destination object number */
 
133
} dest_name_entry;
 
134
 
 
135
#  define pdf_max_link_level  10        /* maximum depth of link nesting */
 
136
 
 
137
typedef struct pdf_link_stack_record {
 
138
    int nesting_level;
 
139
    int link_node;              /* holds a copy of the corresponding |pdf_start_link_node| */
 
140
    int ref_link_node;          /* points to original |pdf_start_link_node|, or a
 
141
                                   copy of |link_node| created by |append_link| in
 
142
                                   case of multi-line link */
 
143
} pdf_link_stack_record;
 
144
 
 
145
/* types of objects */
 
146
typedef enum {
 
147
    obj_type_font = 0,          /* index of linked list of Fonts objects */
 
148
    obj_type_outline = 1,       /* index of linked list of outline objects */
 
149
    obj_type_dest = 2,          /* index of linked list of destination objects */
 
150
    obj_type_obj = 3,           /* index of linked list of raw objects */
 
151
    obj_type_xform = 4,         /* index of linked list of XObject forms */
 
152
    obj_type_ximage = 5,        /* index of linked list of XObject images */
 
153
    obj_type_thread = 6,        /* index of linked list of num article threads */
 
154
    /* |obj_type_thread| is the highest entry in |head_tab|, but there are a few
 
155
       more linked lists that are handy: */
 
156
    obj_type_pagestream = 7,    /* Page stream objects */
 
157
    obj_type_page = 8,          /* Page objects */
 
158
    obj_type_pages = 9,         /* Pages objects */
 
159
    obj_type_link = 10,         /* link objects */
 
160
    obj_type_bead = 11,         /* thread bead objects */
 
161
    obj_type_annot = 12,        /* annotation objects */
 
162
    obj_type_objstm = 13,       /* /ObjStm objects */
 
163
    obj_type_others = 14        /* any other objects (also not linked in any list) */
 
164
} pdf_obj_type;
 
165
 
 
166
#  define HEAD_TAB_MAX      6   /* obj_type_thread */
 
167
#  define PDF_OBJ_TYPE_MAX 14   /* obj_type_others */
 
168
 
 
169
typedef struct pdf_resource_struct_ {
 
170
    pdf_object_list *font_list; /* |font_list| during flushing pending forms */
 
171
    pdf_object_list *dest_list; /* the pdf destinations */
 
172
    pdf_object_list *obj_list;  /* |pdf_obj_list| */
 
173
    pdf_object_list *xform_list;        /* |pdf_xform_list| */
 
174
    pdf_object_list *ximage_list;       /* |pdf_ximage_list| */
 
175
    pdf_object_list *link_list; /* the pdf links */
 
176
    pdf_object_list *bead_list; /* the thread beads */
 
177
    pdf_object_list *annot_list;        /* the pdf annotations */
 
178
    int text_procset;           /* |pdf_text_procset| */
 
179
    int image_procset;          /* |pdf_image_procset| */
 
180
    int last_resources;         /* halfword to most recently generated Resources object. */
 
181
} pdf_resource_struct;
 
182
 
 
183
typedef struct pdf_output_file_ {
 
184
    FILE *file;                 /* the PDF output file handle */
 
185
    char *file_name;            /* the PDF output file name */
 
186
    output_mode o_mode;         /* output mode (DVI/PDF/...) */
 
187
    output_state o_state;
 
188
    /* generation parameters */
 
189
    int gamma;
 
190
    int image_gamma;
 
191
    int image_hicolor;          /* boolean */
 
192
    int image_apply_gamma;
 
193
    int draftmode;
 
194
    int pk_resolution;
 
195
    int decimal_digits;
 
196
    int gen_tounicode;
 
197
    int inclusion_copy_font;
 
198
    int replace_font;
 
199
    int minor_version;          /* fixed minor part of the PDF version */
 
200
    int compress_level;         /* level for zlib object stream compression */
 
201
    int objcompresslevel;       /* fixed level for activating PDF object streams */
 
202
    char *job_id_string;        /* the full job string */
 
203
 
 
204
    /* output file buffering  */
 
205
    unsigned char *op_buf;      /* the PDF output buffer */
 
206
    int op_buf_size;            /* output buffer size (static) */
 
207
    int op_ptr;                 /* store for PDF buffer |pdf_ptr| while inside object streams */
 
208
    unsigned char *os_buf;      /* the PDF object stream buffer */
 
209
    int os_buf_size;            /* current size of the PDF object stream buffer, grows dynamically */
 
210
    int os_ptr;                 /* store for object stream |pdf_ptr| while outside object streams */
 
211
 
 
212
    os_obj_data *os_obj;        /* array of object stream objects */
 
213
    int os_idx;                 /* pointer into |pdf_os_objnum| and |pdf_os_objoff| */
 
214
    int os_cntr;                /* counter for object stream objects */
 
215
    int os_mode;                /* true if producing object stream */
 
216
    int os_enable;              /* true if object streams are globally enabled */
 
217
    int os_cur_objnum;          /* number of current object stream object */
 
218
 
 
219
    unsigned char *buf;         /* pointer to the PDF output buffer or PDF object stream buffer */
 
220
    int buf_size;               /* end of PDF output buffer or PDF object stream buffer */
 
221
    int ptr;                    /* pointer to the first unused byte in the PDF buffer or object stream buffer */
 
222
    off_t save_offset;          /* to save |pdf_offset| */
 
223
    off_t gone;                 /* number of bytes that were flushed to output */
 
224
 
 
225
    char *printf_buf;           /* a scratch buffer for |pdf_printf| */
 
226
 
 
227
    time_t start_time;          /* when this job started */
 
228
    char *start_time_str;       /* minimum size for time_str is 24: "D:YYYYmmddHHMMSS+HH'MM'" */
 
229
 
 
230
    /* define fb_ptr, fb_array & fb_limit */
 
231
    char *fb_array;
 
232
    char *fb_ptr;
 
233
    size_t fb_limit;
 
234
 
 
235
    char *zipbuf;
 
236
    z_stream c_stream;          /* compression stream */
 
237
    int zip_write_state;        /* which state of compression we are in */
 
238
 
 
239
    int pk_scale_factor;        /* this is just a preprocessed value that depends on
 
240
                                   |pk_resolution| and |decimal_digits| */
 
241
 
 
242
    int img_page_group_val;     /* page group information pointer from included pdf or png images */
 
243
    char *resname_prefix;       /* global prefix of resources name */
 
244
 
 
245
    int mem_size;               /* allocated size of |mem| array */
 
246
    int *mem;
 
247
    int mem_ptr;
 
248
 
 
249
    pdfstructure *pstruct;      /* utity structure keeping position status in PDF page stream */
 
250
    posstructure *posstruct;    /* structure for positioning within page */
 
251
 
 
252
    int obj_tab_size;           /* allocated size of |obj_tab| array */
 
253
    obj_entry *obj_tab;
 
254
    int head_tab[HEAD_TAB_MAX + 1];     /* heads of the object lists in |obj_tab| */
 
255
    struct avl_table *obj_tree[PDF_OBJ_TYPE_MAX + 1];   /* this is useful for finding the objects back */
 
256
 
 
257
    int pages_tail;
 
258
    int obj_ptr;                /* user objects counter */
 
259
    int sys_obj_ptr;            /* system objects counter, including object streams */
 
260
    int last_pages;             /* pointer to most recently generated pages object */
 
261
    int last_page;              /* pointer to most recently generated page object */
 
262
    int last_stream;            /* pointer to most recently generated stream */
 
263
    off_t stream_length;        /* length of most recently generated stream */
 
264
    off_t stream_length_offset; /* file offset of the last stream length */
 
265
    int seek_write_length;      /* flag whether to seek back and write \.{/Length} */
 
266
    int last_byte;              /* byte most recently written to PDF file; for \.{endstream} in new line */
 
267
 
 
268
    /* integer last_resources;     halfword to most recently generated Resources object.
 
269
       TH: this used to be a local in pdf_shipout, but I would like to
 
270
       be able to split that function into a pre- and post part */
 
271
 
 
272
    int obj_count;
 
273
    int xform_count;
 
274
    int ximage_count;
 
275
 
 
276
    pdf_resource_struct *resources;
 
277
 
 
278
    /* the variables from pdfdest */
 
279
    int dest_names_size;
 
280
    int dest_names_ptr;
 
281
    dest_name_entry *dest_names;
 
282
    /* the (static) variables from pdfoutline */
 
283
    int first_outline;
 
284
    int last_outline;
 
285
    int parent_outline;
 
286
    /* the pdf link stack */
 
287
    pdf_link_stack_record link_stack[(pdf_max_link_level + 1)];
 
288
    int link_stack_ptr;
 
289
    /* the thread data */
 
290
    int last_thread;            /* pointer to the last thread */
 
291
    scaled_whd thread;
 
292
    int last_thread_id;         /* identifier of the last thread */
 
293
    int last_thread_named_id;   /* is identifier of the last thread named */
 
294
    int thread_level;           /* depth of nesting of box containing the last thread */
 
295
 
 
296
    int f_cur;                  /* TeX font number */
 
297
} pdf_output_file;
 
298
 
 
299
typedef pdf_output_file *PDF;
 
300
 
 
301
#endif