3 % Copyright
2009-2011 Taco Hoekwater
<taco@@luatex.org
>
5 % This file is part of LuaTeX.
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.
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.
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
/>.
22 #include
"pdf/pdfpage.h"
25 int pdf_cur_form
; /* the form being output
*/
27 void pdf_place_form
(PDF pdf
, halfword p
)
32 pdfstructure
*q
= pdf-
>pstruct
;
34 int objnum
= rule_index
(p
);
35 nat.wd
= obj_xform_width
(pdf
, objnum
);
36 nat.ht
= obj_xform_height
(pdf
, objnum
);
37 nat.dp
= obj_xform_depth
(pdf
, objnum
);
38 /* no transform yet
*/
42 if
(nat.wd
!= tex.wd || nat.ht
!= tex.ht || nat.dp
!= tex.dp
) {
43 x
= ext_xn_over_d
(ten_pow
[r
], tex.wd
, nat.wd
);
44 y
= ext_xn_over_d
(ten_pow
[r
], tex.dp
+ tex.ht
, nat.dp
+ nat.ht
);
47 setpdffloat
(cm
[0], x
, r
);
48 setpdffloat
(cm
[1], 0, r
);
49 setpdffloat
(cm
[2], 0, r
);
50 setpdffloat
(cm
[3], y
, r
);
51 pdf_goto_pagemode
(pdf
);
52 (void
) calc_pdfpos
(q
, pdf-
>posstruct-
>pos
);
56 pdf_print_cm
(pdf
, cm
);
57 pdf_printf
(pdf
, "/Fm%d", (int
) obj_info
(pdf
, objnum
));
58 pdf_print_resname_prefix
(pdf
);
59 pdf_puts
(pdf
, " Do\nQ\n");
60 addto_page_resources
(pdf
, obj_type_xform
, objnum
);
63 /* we will store token lists as strings too
*/
66 void scan_pdfxform
(PDF pdf
)
71 k
= pdf_create_obj
(pdf
, obj_type_xform
, pdf-
>xform_count
);
72 set_obj_data_ptr
(pdf
, k
, pdf_get_mem
(pdf
, pdfmem_xform_size
));
73 if
(scan_keyword
("type")) {
75 set_obj_xform_type
(pdf
, k
, cur_val
);
77 set_obj_xform_type
(pdf
, k
, 0);
79 if
(scan_keyword
("attr")) {
80 scan_toks
(false
, true
);
81 set_obj_xform_attr
(pdf
, k
, def_ref
);
83 set_obj_xform_attr
(pdf
, k
, null
);
85 set_obj_xform_attr_str
(pdf
, k
, null
);
86 if
(scan_keyword
("resources")) {
87 scan_toks
(false
, true
);
88 set_obj_xform_resources
(pdf
, k
, def_ref
);
90 set_obj_xform_resources
(pdf
, k
, null
);
92 set_obj_xform_resources_str
(pdf
, k
, null
);
96 normal_error
("pdf backend", "xforms cannot be used with a void box");
97 set_obj_xform_box
(pdf
, k
, p
); /* save pointer to the box
*/
98 set_obj_xform_width
(pdf
, k
, width
(p
));
99 set_obj_xform_height
(pdf
, k
, height
(p
));
100 set_obj_xform_depth
(pdf
, k
, depth
(p
));
102 last_saved_box_index
= k
;
106 void scan_pdfrefxform
(PDF pdf
)
108 scaled_whd alt_rule
, dim
, nat
;
109 alt_rule
= scan_alt_rule
(); /* scans |
<rule spec
>| to |alt_rule|
*/
111 check_obj_type
(pdf
, obj_type_xform
, cur_val
);
112 tail_append
(new_rule
(box_rule
));
113 nat.wd
= obj_xform_width
(pdf
, cur_val
);
114 nat.ht
= obj_xform_height
(pdf
, cur_val
);
115 nat.dp
= obj_xform_depth
(pdf
, cur_val
);
116 if
(alt_rule.wd
!= null_flag || alt_rule.ht
!= null_flag || alt_rule.dp
!= null_flag
) {
117 dim
= tex_scale
(nat
, alt_rule
);
121 width
(tail_par
) = dim.wd
;
122 height
(tail_par
) = dim.ht
;
123 depth
(tail_par
) = dim.dp
;
124 rule_index
(tail_par
) = cur_val
;