3 % Copyright
2010-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"
26 /* maybe we should have an extra callback on normal rules or on any rule in
2.0+ */
28 void pdf_place_rule
(PDF pdf
, halfword q
, scaledpos size
, int callback_id
)
31 pdfstructure
*p
= pdf-
>pstruct
;
32 scaledpos pos
= pdf-
>posstruct-
>pos
;
33 halfword s
= subtype
(q
);
35 if
(s
>= math_over_rule
&& s <= math_radical_rule) {
36 if
(callback_id
== 0) {
43 pdf_place_form
(pdf
,q
);
44 } else if
(s
== image_rule
) {
45 pdf_place_image
(pdf
,q
);
46 } else if
(s
== empty_rule
) {
47 /* place nothing
, only take space
*/
48 } else if
(s
== user_rule
) {
49 if
(callback_id
!= 0) {
50 pdf_goto_pagemode
(pdf
);
52 pdf_set_pos_temp
(pdf
, pos
);
53 run_callback
(callback_id
, "Ndd->",q
,size.h
,size.v
);
54 pdf_puts
(pdf
, "\nQ\n");
57 /* normal_rule or
>= 100 being a leader rule
*/
58 pdf_goto_pagemode
(pdf
);
59 dim.h.m
= i64round
(size.h
* p-
>k1
);
61 dim.v.m
= i64round
(size.v
* p-
>k1
);
64 if
(size.v
<= one_bp
) {
65 pos.v
+= i64round
(0.5 * size.v
);
66 pdf_set_pos_temp
(pdf
, pos
);
67 pdf_puts
(pdf
, "[]0 d 0 J ");
68 print_pdffloat
(pdf
, dim.v
);
69 pdf_puts
(pdf
, " w 0 0 m ");
70 print_pdffloat
(pdf
, dim.h
);
71 pdf_puts
(pdf
, " 0 l S\n");
72 } else if
(size.h
<= one_bp
) {
73 pos.h
+= i64round
(0.5 * size.h
);
74 pdf_set_pos_temp
(pdf
, pos
);
75 pdf_puts
(pdf
, "[]0 d 0 J ");
76 print_pdffloat
(pdf
, dim.h
);
77 pdf_puts
(pdf
, " w 0 0 m 0 ");
78 print_pdffloat
(pdf
, dim.v
);
79 pdf_puts
(pdf
, " l S\n");
81 pdf_set_pos_temp
(pdf
, pos
);
82 pdf_puts
(pdf
, "0 0 ");
83 print_pdffloat
(pdf
, dim.h
);
85 print_pdffloat
(pdf
, dim.v
);
86 pdf_puts
(pdf
, " re f\n");