fix getsup (HH)
[luatex.git] / source / texk / web2c / luatexdir / pdf / pdfrule.w
blobdf4979088c8242533e41eb5d98a863bae5dee3e4
1 % pdfrule.w
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/>.
20 @ @c
21 #include "ptexlib.h"
22 #include "pdf/pdfpage.h"
24 @ @c
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)
30 pdfpos dim;
31 pdfstructure *p = pdf->pstruct;
32 scaledpos pos = pdf->posstruct->pos;
33 halfword s = subtype(q);
34 /* (void) q; */
35 if (s >= math_over_rule && s <= math_radical_rule) {
36 if (callback_id == 0) {
37 s = normal_rule;
38 } else {
39 s = user_rule;
42 if (s == box_rule) {
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);
51 pdf_puts(pdf, "q\n");
52 pdf_set_pos_temp(pdf, pos);
53 run_callback(callback_id, "Ndd->",q,size.h,size.v);
54 pdf_puts(pdf, "\nQ\n");
56 } else {
57 /* normal_rule or >= 100 being a leader rule */
58 pdf_goto_pagemode(pdf);
59 dim.h.m = i64round(size.h * p->k1);
60 dim.h.e = p->pdf.h.e;
61 dim.v.m = i64round(size.v * p->k1);
62 dim.v.e = p->pdf.v.e;
63 pdf_puts(pdf, "q\n");
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");
80 } else {
81 pdf_set_pos_temp(pdf, pos);
82 pdf_puts(pdf, "0 0 ");
83 print_pdffloat(pdf, dim.h);
84 pdf_out(pdf, ' ');
85 print_pdffloat(pdf, dim.v);
86 pdf_puts(pdf, " re f\n");
88 pdf_puts(pdf, "Q\n");