Debian Codegraph @

texk/dvipdfm-x/pdfdev.h

raw
1 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
2
3 Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
4 the dvipdfmx project team.
5
6 Copyright (C) 1998, 1999 by Mark A. Wicks <[email protected]>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 */
22
23 #ifndef _PDFDEV_H_
24 #define _PDFDEV_H_
25
26 #include "numbers.h"
27 #include "pdfobj.h"
28 #include "pdfcolor.h"
29
30 typedef struct pdf_dev pdf_dev;
31
32 typedef int spt_t;
33
34 typedef struct pdf_tmatrix
35 {
36 double a, b, c, d, e, f;
37 } pdf_tmatrix;
38
39 typedef struct pdf_rect
40 {
41 double llx, lly, urx, ury;
42 } pdf_rect;
43
44 typedef struct pdf_coord
45 {
46 double x, y;
47 } pdf_coord;
48
49 /* The name transform_info is misleading.
50 * I'll put this here for a moment...
51 */
52 typedef struct
53 {
54 /* Physical dimensions
55 *
56 * If those values are given, images will be scaled
57 * and/or shifted to fit within a box described by
58 * those values.
59 */
60 double width;
61 double height;
62 double depth;
63
64 pdf_tmatrix matrix; /* transform matrix */
65 pdf_rect bbox; /* user_bbox */
66
67 int flags;
68 } transform_info;
69 #define INFO_HAS_USER_BBOX (1 << 0)
70 #define INFO_HAS_WIDTH (1 << 1)
71 #define INFO_HAS_HEIGHT (1 << 2)
72 #define INFO_DO_CLIP (1 << 3)
73 #define INFO_DO_HIDE (1 << 4)
74 extern void transform_info_clear (transform_info *info);
75
76 /* Not in spt_t. */
77 extern int pdf_sprint_matrix (char *buf, const pdf_tmatrix *p);
78 extern int pdf_sprint_rect (char *buf, const pdf_rect *p);
79 extern int pdf_sprint_coord (char *buf, const pdf_coord *p);
80 extern int pdf_sprint_length (char *buf, double value);
81 extern int pdf_sprint_number (char *buf, double value);
82
83 /* unit_conv: multiplier for input unit (spt_t) to bp conversion.
84 * precision: How many fractional digits preserved in output (not real
85 * accuracy control).
86 * is_bw: Ignore color related special instructions.
87 */
88 extern void pdf_init_device (double unit_conv, int precision, int is_bw);
89 extern void pdf_close_device (void);
90
91 /* returns 1.0/unit_conv */
92 extern double dev_unit_dviunit (void);
93
94 /* Draw texts and rules:
95 *
96 * xpos, ypos, width, and height are all fixed-point numbers
97 * converted to big-points by multiplying unit_conv (dvi2pts).
98 * They must be position in the user space.
99 *
100 * ctype:
101 * 0 - input string is in multi-byte encoding.
102 * 1 - input string is in 8-bit encoding.
103 * 2 - input string is in 16-bit encoding.
104 */
105 extern void pdf_dev_set_string (spt_t xpos, spt_t ypos,
106 const void *instr_ptr, int instr_len,
107 spt_t text_width, int font_id);
108 extern void pdf_dev_set_rule (spt_t xpos, spt_t ypos, spt_t width, spt_t height);
109
110 /* Place XObject: rect returned */
111 extern int pdf_dev_put_image (int xobj_id, transform_info *p, double ref_x, double ref_y, pdf_rect *rect);
112
113 /* The design_size and ptsize required by PK font support...
114 */
115 extern int pdf_dev_locate_font (const char *font_name, spt_t ptsize);
116
117 /* The following two routines are NOT WORKING.
118 * Dvipdfmx doesn't manage gstate well..
119 */
120 #define pdf_dev_scale() (1.0)
121
122 /* Access text state parameters. */
123 extern int pdf_dev_get_font_wmode (int font_id); /* ps: special support want this (pTeX). */
124
125 /* Text composition (direction) mode
126 * This affects only when auto_rotate is enabled.
127 */
128 extern int pdf_dev_get_dirmode (void);
129 extern void pdf_dev_set_dirmode (int dir_mode);
130
131 /* Set rect to rectangle in device space.
132 * Unit conversion spt_t to bp and transformation applied within it.
133 */
134 extern void pdf_dev_set_rect (pdf_rect *rect,
135 spt_t x_pos, spt_t y_pos,
136 spt_t width, spt_t height, spt_t depth);
137
138 /* Accessor to various device parameters.
139 */
140 #define PDF_DEV_PARAM_AUTOROTATE 1
141 #define PDF_DEV_PARAM_COLORMODE 2
142
143 extern int pdf_dev_get_param (int param_type);
144 extern void pdf_dev_set_param (int param_type, int value);
145
146 /* Text composition mode is ignored (always same as font's
147 * writing mode) and glyph rotation is not enabled if
148 * auto_rotate is unset.
149 */
150 #define pdf_dev_set_autorotate(v) pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, (v))
151
152 /*
153 * For pdf_doc, pdf_draw and others.
154 */
155
156 /* Force reselecting font and color:
157 * XFrom (content grabbing) and Metapost support want them.
158 */
159 extern void pdf_dev_reset_fonts (int newpage);
160 extern void pdf_dev_reset_color (int force);
161
162 /* Initialization of transformation matrix with M and others.
163 * They are called within pdf_doc_begin_page() and pdf_doc_end_page().
164 */
165 extern void pdf_dev_bop (const pdf_tmatrix *M);
166 extern void pdf_dev_eop (void);
167
168 /* Text is normal and line art is not normal in dvipdfmx. So we don't have
169 * begin_text (BT in PDF) and end_text (ET), but instead we have graphics_mode()
170 * to terminate text section. pdf_dev_flushpath() and others call this.
171 */
172 extern void graphics_mode (void);
173
174 extern void pdf_dev_begin_actualtext (uint16_t *unicodes, int len);
175 extern void pdf_dev_end_actualtext (void);
176
177 extern int pdf_dev_font_minbytes (int font_id);
178 #endif /* _PDFDEV_H_ */