~ubuntu-branches/ubuntu/natty/luatex/natty

« back to all changes in this revision

Viewing changes to source/texk/web2c/luatexdir/tex/postlinebreak.c

  • 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:
17
17
   You should have received a copy of the GNU General Public License along
18
18
   with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
19
19
 
20
 
#include "luatex-api.h"
 
20
 
21
21
#include <ptexlib.h>
22
 
#include "nodes.h"
 
22
 
 
23
 
23
24
 
24
25
static const char _svn_version[] =
25
 
    "$Id: postlinebreak.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/tex/postlinebreak.c $";
 
26
    "$Id: postlinebreak.c 3261 2009-12-18 11:38:21Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.50.0/source/texk/web2c/luatexdir/tex/postlinebreak.c $";
26
27
 
27
28
/* So far we have gotten a little way into the |line_break| routine, having
28
29
covered its important |try_break| subroutine. Now let's consider the
42
43
 
43
44
*/
44
45
 
45
 
static halfword do_push_dir_node(halfword p, halfword a)
46
 
{
47
 
    halfword n;
48
 
    n = copy_node(a);
49
 
    vlink(n) = p;
50
 
    return n;
51
 
}
52
 
 
53
 
static halfword do_pop_dir_node(halfword p)
54
 
{
55
 
    halfword n = vlink(p);
56
 
    flush_node(p);
57
 
    return n;
58
 
}
59
 
 
60
 
 
61
46
/* The total number of lines that will be set by |post_line_break|
62
47
is |best_line-prev_graf-1|. The last breakpoint is specified by
63
48
|break_node(best_bet)|, and this passive node points to the other breakpoints
75
60
 
76
61
#define next_break prev_break   /*new name for |prev_break| after links are reversed */
77
62
 
78
 
#define append_list(a,b)                                                \
79
 
  { vlink(cur_list.tail_field)=vlink((a)); cur_list.tail_field = b; }
80
 
 
81
 
#define left_skip_code 7        /*glue at left of justified lines */
82
 
#define right_skip_code 8       /*glue at right of justified lines */
83
 
 
84
63
/* the ints are actually halfwords */
85
64
void ext_post_line_break(boolean d,
 
65
                         int paragraph_dir,
86
66
                         int right_skip,
87
67
                         int left_skip,
88
68
                         int pdf_protrude_chars,
120
100
    boolean post_disc_break;    /*and did it have a nonempty post-break part? */
121
101
    scaled cur_width;           /*width of line number |cur_line| */
122
102
    scaled cur_indent;          /*left margin of line number |cur_line| */
123
 
    integer pen;                /*use when calculating penalties between lines */
 
103
    int pen;                    /*use when calculating penalties between lines */
124
104
    halfword cur_p;             /* cur_p, but localized */
125
105
    halfword cur_line;          /*the current line number being justified */
126
106
 
171
151
        for (q = dir_ptr; q != null; q = vlink(q)) {
172
152
            halfword tmp = new_dir(dir_dir(q));
173
153
            halfword nxt = vlink(temp_head);
 
154
            delete_attribute_ref(node_attr(tmp));
 
155
            node_attr(tmp) = node_attr(temp_head);
 
156
            add_node_attr_ref(node_attr(tmp));
174
157
            couple_nodes(temp_head, tmp);
175
158
            try_couple_nodes(tmp, nxt); /* \break\par */
176
159
        }
300
283
            e = vlink(r);
301
284
            for (p = dir_ptr; p != null; p = vlink(p)) {
302
285
                halfword s = new_dir(dir_dir(p) - 64);
 
286
                delete_attribute_ref(node_attr(s));
 
287
                node_attr(s) = node_attr(r);
 
288
                add_node_attr_ref(node_attr(s));
303
289
                couple_nodes(r, s);
304
290
                try_couple_nodes(s, e);
305
291
                r = s;
334
320
                p = alink(q);   /* get |vlink(p) = q| */
335
321
                assert(vlink(p) == q);
336
322
                ptmp = p;
337
 
                p = find_protchar_right(vlink(temp_head), p);
338
323
            }
 
324
            p = find_protchar_right(vlink(temp_head), p);
339
325
            w = char_pw(p, right_side);
340
326
            if (w != 0) {       /* we have found a marginal kern, append it after |ptmp| */
341
327
                k = new_margin_kern(-w, last_rightmost_char, right_side);
 
328
                delete_attribute_ref(node_attr(k));
 
329
                node_attr(k) = node_attr(p);
 
330
                add_node_attr_ref(node_attr(k));
342
331
                vlink(k) = vlink(ptmp);
343
332
                vlink(ptmp) = k;
344
333
                if (ptmp == q)
351
340
            /* @<Put the \(r)\.{\\rightskip} glue after node |q|@>; */
352
341
            halfword r = new_param_glue(right_skip_code);
353
342
            vlink(r) = vlink(q);
 
343
            delete_attribute_ref(node_attr(r));
 
344
            node_attr(r) = node_attr(q);
 
345
            add_node_attr_ref(node_attr(r));
354
346
            vlink(q) = r;
355
347
            q = r;
356
348
        }
390
382
            w = char_pw(p, left_side);
391
383
            if (w != 0) {
392
384
                k = new_margin_kern(-w, last_leftmost_char, left_side);
 
385
                delete_attribute_ref(node_attr(k));
 
386
                node_attr(k) = node_attr(q);
 
387
                add_node_attr_ref(node_attr(k));
393
388
                vlink(k) = q;
394
389
                q = k;
395
390
            }
396
391
        };
397
392
        if (left_skip != zero_glue) {
398
393
            r = new_param_glue(left_skip_code);
 
394
            delete_attribute_ref(node_attr(r));
 
395
            node_attr(r) = node_attr(q);
 
396
            add_node_attr_ref(node_attr(r));
399
397
            vlink(r) = q;
400
398
            q = r;
401
399
        }
417
415
            cur_width = varmem[(par_shape_ptr + 2 * cur_line + 1)].cint;
418
416
        }
419
417
        adjust_tail = adjust_head;
420
 
        pack_direction = paragraph_dir;
421
418
        pre_adjust_tail = pre_adjust_head;
422
419
        if (pdf_adjust_spacing > 0) {
423
 
            just_box = hpack(q, cur_width, cal_expand_ratio);
 
420
            just_box = hpack(q, cur_width, cal_expand_ratio, paragraph_dir);
424
421
        } else {
425
 
            just_box = hpack(q, cur_width, exactly);
 
422
            just_box = hpack(q, cur_width, exactly, paragraph_dir);
426
423
        }
427
424
        shift_amount(just_box) = cur_indent;
 
425
        subtype(just_box) = HLIST_SUBTYPE_LINE;
428
426
        /* /Call the packaging subroutine, setting |just_box| to the justified box; */
429
427
 
430
428
        /* Append the new box to the current vertical list, followed by the list of
546
544
        }
547
545
    } while (cur_p != null);
548
546
    if ((cur_line != best_line) || (vlink(temp_head) != null))
549
 
        tconfusion("line breaking");
 
547
        confusion("line breaking");
550
548
    cur_list.pg_field = best_line - 1;  /* prevgraf */
551
549
    cur_list.dirs_field = dir_ptr;      /* dir_save */
552
550
    dir_ptr = null;