>From 4d2afb828117744550ba921e2ca93ea84f80eba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Mon, 15 Feb 2021 22:02:40 +0100 Subject: [PATCH 2/3] Fix break_width for nested discretionary --- source/texk/web2c/luatexdir/tex/linebreak.c | 46 +++++++-------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/source/texk/web2c/luatexdir/tex/linebreak.c b/source/texk/web2c/luatexdir/tex/linebreak.c index 131e27a5a..f09e34e2e 100644 --- a/source/texk/web2c/luatexdir/tex/linebreak.c +++ b/source/texk/web2c/luatexdir/tex/linebreak.c @@ -1094,7 +1094,10 @@ static void compute_break_width(int break_type, int line_break_dir, int adjust_s path, as we are talking about the breaking on {\it this} position. */ - sub_from_widths(vlink_no_break(p), line_break_dir, adjust_spacing, break_width); + if (subtype(p) == select_disc) + sub_from_widths(vlink_no_break(alink(p)), line_break_dir, adjust_spacing, break_width); + else + sub_from_widths(vlink_no_break(p), line_break_dir, adjust_spacing, break_width); add_to_widths(vlink_post_break(p), line_break_dir, adjust_spacing, break_width); do_one_seven_eight(add_disc_width_to_break_width); if (vlink_post_break(p) == null) { @@ -2299,42 +2302,26 @@ void ext_do_line_break( if (subtype(cur_p) == init_disc) { /*tex - We should at two break points after the one - we added above: - - \startitemize[n] - \startitem - which does a possible break in INIT's - |post_break| - \stopitem - \startitem - which means the |no_break| actually - was broken just a character later - \stopitem - \stopitemize - - Do the select-0 case |f-f-i|: - + The breakpoint after the one we added above + should be special since it's corresponding + disc_width depends on whether the previous + breakpoint will be taken. This isn't handled + yet, so we assume the more common case: Only + one of the breakpoints is used, therefore + |disc_width| is the |pre_break| of the break + in INIT's |no_break|. This is stored in + SELECT's |no_break|. */ actual_penalty = (int) disc_penalty(vlink(cur_p)); - s = vlink_pre_break(vlink(cur_p)); - add_to_widths(s, line_break_dir, adjust_spacing, disc_width); - ext_try_break(actual_penalty, hyphenated_node, - line_break_dir, adjust_spacing, - par_shape_ptr, adj_demerits, - tracing_paragraphs, - protrude_chars, line_penalty, - last_line_fit, double_hyphen_demerits, - final_hyphen_demerits, first_p, - vlink(cur_p)); - /*tex This does not work. */ -#if 0 /*tex Go back to the starting situation. */ do_one_seven_eight(sub_disc_width_from_active_width); do_one_seven_eight(reset_disc_width); + /*tex Ensure that alink is set for |compute_break_width| */ + alink(vlink(cur_p)) = cur_p; /*tex Add select |no_break| to |active_width|. */ s = vlink_no_break(vlink(cur_p)); add_to_widths(s, line_break_dir, adjust_spacing, disc_width); + do_one_seven_eight(add_disc_width_to_active_width); ext_try_break(actual_penalty, hyphenated_node, line_break_dir, adjust_spacing, par_shape_ptr, adj_demerits, @@ -2343,7 +2330,6 @@ void ext_do_line_break( last_line_fit, double_hyphen_demerits, final_hyphen_demerits, first_p, vlink(cur_p)); -#endif } do_one_seven_eight(sub_disc_width_from_active_width); } -- 2.30.1