diff options
24 files changed, 269 insertions, 161 deletions
diff --git a/Build/source/texk/web2c/luatexdir/font/writet3.w b/Build/source/texk/web2c/luatexdir/font/writet3.w index c7cc79a722f..879cef8d5a0 100644 --- a/Build/source/texk/web2c/luatexdir/font/writet3.w +++ b/Build/source/texk/web2c/luatexdir/font/writet3.w @@ -148,6 +148,11 @@ static boolean writepk(PDF pdf, internal_font_number f) cd.rastersize = 256; cd.raster = xtalloc((unsigned long) cd.rastersize, halfword); check_preamble = true; + if (dpi==0) { + normal_error("type 3","invalid dpi value 0"); + } else if (newdpi==0) { + newdpi = dpi; + } while (readchar(check_preamble, &cd) != 0) { check_preamble = false; if (!pdf_char_marked(f, cd.charcode)) diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c index dfc3dac6743..778fbf18876 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c @@ -71,6 +71,7 @@ static const char *const callbacknames[] = { "hpack_quality", "vpack_quality", "process_rule", "insert_local_par", + "contribute_filter", NULL }; diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c index 42f1063264e..d9a5569fc38 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -1930,21 +1930,21 @@ static int lua_nodelib_has_field(lua_State * L) static int lua_nodelib_is_char(lua_State * L) { - halfword f; halfword n = *(check_isnode(L, 1)); - if ((type(n) == glyph_node) && (subtype(n) < 256)) { /* <= 256 */ - if (lua_type(L,2) == LUA_TNUMBER) { - f = (halfword) lua_tointeger(L, 2); - if (f && f == font(n)) { - lua_pushinteger(L,character(n)); - return 1; - } + if (type(n) != glyph_node) { + lua_pushnil(L); /* no glyph at all */ + } else if (subtype(n) >= 256) { + lua_pushboolean(L,0); /* a done glyph */ + } else if (lua_type(L,2) == LUA_TNUMBER) { + halfword f = lua_tointeger(L, 2); + if (f && f == font(n)) { + lua_pushinteger(L,character(n)); /* a todo glyph in the asked font */ } else { - lua_pushinteger(L,character(n)); - return 1; + lua_pushboolean(L,0); /* a todo glyph in another font */ } + } else { + lua_pushinteger(L,character(n)); /* a todo glyph */ } - lua_pushboolean(L,0); return 1; } @@ -2085,6 +2085,11 @@ static int lua_nodelib_subtypes(lua_State * L) } } if (l > 0) { + /* add math states */ + for (i = 0; node_subtypes_mathglue[i] != NULL; i++) { + lua_pushstring(L, node_subtypes_mathglue[i]); /* todo */ + lua_rawseti(L, -2, 98 + i); + } /* add leaders */ for (i = 0; node_subtypes_leader[i] != NULL; i++) { lua_pushstring(L, node_subtypes_leader[i]); /* todo */ @@ -5840,19 +5845,20 @@ static int lua_nodelib_direct_setlink(lua_State * L) static int lua_nodelib_direct_is_char(lua_State * L) { halfword n = lua_tointeger(L, 1); - if ((type(n) == glyph_node) && (subtype(n) < 256)) { /* <= 256 */ - if (lua_type(L,2) == LUA_TNUMBER) { - halfword f = lua_tointeger(L, 2); - if (f && f == font(n)) { - lua_pushinteger(L,character(n)); - return 1; - } + if (type(n) != glyph_node) { + lua_pushnil(L); /* no glyph at all */ + } else if (subtype(n) >= 256) { + lua_pushboolean(L,0); /* a done glyph */ + } else if (lua_type(L,2) == LUA_TNUMBER) { + halfword f = lua_tointeger(L, 2); + if (f && f == font(n)) { + lua_pushinteger(L,character(n)); /* a todo glyph in the asked font */ } else { - lua_pushinteger(L,character(n)); - return 1; + lua_pushboolean(L,0); /* a todo glyph in another font */ } + } else { + lua_pushinteger(L,character(n)); /* a todo glyph */ } - lua_pushboolean(L,0); return 1; } diff --git a/Build/source/texk/web2c/luatexdir/lua/luanode.w b/Build/source/texk/web2c/luatexdir/lua/luanode.w index bd328b8c2f2..3325245fcaa 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luanode.w +++ b/Build/source/texk/web2c/luatexdir/lua/luanode.w @@ -51,6 +51,7 @@ void lua_node_filter_s(int filterid, int extrainfo) } @ @c +/* void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node) { halfword ret; @@ -66,10 +67,10 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * lua_settop(L, s_top); return; } - alink(vlink(head_node)) = null ; /* hh-ls */ - nodelist_to_lua(L, vlink(head_node)); /* arg 1 */ - lua_push_group_code(L,extrainfo); /* arg 2 */ - if (lua_pcall(L, 2, 1, 0) != 0) { /* no arg, 1 result */ + alink(vlink(head_node)) = null ; + nodelist_to_lua(L, vlink(head_node)); + lua_push_group_code(L,extrainfo); + if (lua_pcall(L, 2, 1, 0) != 0) { fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); lua_settop(L, s_top); error(); @@ -84,7 +85,7 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * a = nodelist_from_lua(L); try_couple_nodes(head_node,a); } - lua_pop(L, 2); /* result and callback container table */ + lua_pop(L, 2); if (fix_node_lists) fix_node_list(head_node); ret = vlink(head_node); @@ -98,6 +99,78 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * lua_settop(L, s_top); return; } +*/ + +void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node) +{ + halfword start_node, start_done, last_node; + lua_State *L = Luas; + int s_top = lua_gettop(L); + int callback_id = callback_defined(filterid); + if (head_node == null || callback_id <= 0) { + lua_settop(L, s_top); + return; + } + /* we start after head */ + start_node = vlink(head_node); + if (start_node == null || !get_callback(L, callback_id)) { + lua_settop(L, s_top); + return; + } + /* we make sure we have no prev */ + alink(start_node) = null ; + /* the action */ + nodelist_to_lua(L, start_node); + lua_push_group_code(L,extrainfo); + if (lua_pcall(L, 2, 1, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_settop(L, s_top); + error(); + return; + } + /* the result */ + if (lua_isboolean(L, -1)) { + if (lua_toboolean(L, -1) != 1) { + /* discard */ + flush_node_list(start_node); + vlink(head_node) = null; + } else { + /* keep */ + } + } else { + /* append to old head */ + start_done = nodelist_from_lua(L); + try_couple_nodes(head_node,start_done); + } + /* redundant as we set top anyway */ + lua_pop(L, 2); + /* find tail in order to update tail */ + start_node = vlink(head_node); + if (start_node != null) { + /* maybe just always slide (harmless and fast) */ + last_node = vlink(start_node); + if (fix_node_lists) { + while (last_node != null) { + alink(last_node) = start_node; + start_node = last_node; + last_node = vlink(start_node); + } + } else { + while (last_node != null) { + start_node = last_node; + last_node = vlink(start_node); + } + } + /* we're at the end now */ + *tail_node = start_node; + } else { + /* we're already at the end */ + *tail_node = head_node; + } + /* clean up */ + lua_settop(L, s_top); + return; +} @ @c int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head) @@ -176,7 +249,7 @@ int lua_appendtovlist_callback(halfword box, int location, halfword prev_depth, } @ @c -halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, int pack_direction) +halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, int pack_direction, halfword attr) { halfword ret; lua_State *L = Luas; @@ -195,11 +268,17 @@ halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int ex lua_push_group_code(L,extrainfo); lua_pushinteger(L, size); lua_push_pack_type(L,pack_type); - if (pack_direction >= 0) + if (pack_direction >= 0) { lua_push_dir_par(L, pack_direction); - else + } else { + lua_pushnil(L); + } + if (attr != null) { + nodelist_to_lua(L, attr); + } else { lua_pushnil(L); - if (lua_pcall(L, 5, 1, 0) != 0) { /* no arg, 1 result */ + } + if (lua_pcall(L, 6, 1, 0) != 0) { fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); lua_settop(L, s_top); error(); @@ -225,7 +304,7 @@ halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int ex @ @c halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd, - int extrainfo, int pack_direction) + int extrainfo, int pack_direction, halfword attr) { halfword ret; int callback_id; @@ -254,11 +333,17 @@ halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled lua_pushinteger(L, size); lua_push_pack_type(L,pack_type); lua_pushinteger(L, maxd); - if (pack_direction >= 0) + if (pack_direction >= 0) { lua_push_dir_par(L, pack_direction); - else + } else { lua_pushnil(L); - if (lua_pcall(L, 6, 1, 0) != 0) { /* no arg, 1 result */ + } + if (attr != null) { + nodelist_to_lua(L, attr); + } else { + lua_pushnil(L); + } + if (lua_pcall(L, 7, 1, 0) != 0) { fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); lua_settop(L, s_top); error(); diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c index d61666e34d6..2140d4c96a0 100644 --- a/Build/source/texk/web2c/luatexdir/luatex.c +++ b/Build/source/texk/web2c/luatexdir/luatex.c @@ -29,9 +29,9 @@ #define TeX int luatex_version = 89; /* \.{\\luatexversion} */ -int luatex_revision = '4'; /* \.{\\luatexrevision} */ -int luatex_date_info = 2016031100; /* the compile date is now hardwired */ -const char *luatex_version_string = "beta-0.89.4"; +int luatex_revision = '5'; /* \.{\\luatexrevision} */ +int luatex_date_info = 2016031115; /* the compile date is now hardwired */ +const char *luatex_version_string = "beta-0.89.5"; const char *engine_name = my_name; /* the name of this engine */ #include <kpathsea/c-ctype.h> diff --git a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h index b1d3449fc44..4a02f05d058 100644 --- a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h +++ b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h @@ -65,6 +65,7 @@ typedef enum { hpack_quality_callback, vpack_quality_callback, process_rule_callback, insert_local_par_callback, + contribute_filter_callback, total_callbacks } callback_callback_types; @@ -145,3 +146,7 @@ static const char *const filetypes_right[] = { "?", ")", "}", ">", ">", ">>" } ; } while (0) #endif + +#define normal_page_filter(A) lua_node_filter_s(buildpage_filter_callback,lua_key_index(A)) +#define checked_page_filter(A) if (!output_active) lua_node_filter_s(buildpage_filter_callback,lua_key_index(A)) +#define checked_break_filter(A) if (!output_active) lua_node_filter_s(contribute_filter_callback,lua_key_index(A)) diff --git a/Build/source/texk/web2c/luatexdir/ptexlib.h b/Build/source/texk/web2c/luatexdir/ptexlib.h index e282e1774cc..a70bcfb2d92 100644 --- a/Build/source/texk/web2c/luatexdir/ptexlib.h +++ b/Build/source/texk/web2c/luatexdir/ptexlib.h @@ -240,12 +240,12 @@ extern halfword handle_ligaturing(halfword head, halfword tail); extern halfword handle_kerning(halfword head, halfword tail); halfword lua_hpack_filter( - halfword head_node, scaled size, int pack_type, int extrainfo, int d); + halfword head_node, scaled size, int pack_type, int extrainfo, int d, halfword a); void lua_node_filter( int filterid, int extrainfo, halfword head_node, halfword * tail_node); halfword lua_vpack_filter( - halfword head_node, scaled size, int pack_type, scaled maxd, int extrainfo, int d); + halfword head_node, scaled size, int pack_type, scaled maxd, int extrainfo, int d, halfword a); void lua_node_filter_s( int filterid, int extrainfo); int lua_linebreak_callback( diff --git a/Build/source/texk/web2c/luatexdir/tex/align.w b/Build/source/texk/web2c/luatexdir/tex/align.w index f1984a88c50..d54eabac131 100644 --- a/Build/source/texk/web2c/luatexdir/tex/align.w +++ b/Build/source/texk/web2c/luatexdir/tex/align.w @@ -671,7 +671,7 @@ boolean fin_col(void) adjust_tail = cur_tail; pre_adjust_tail = cur_pre_tail; u = filtered_hpack(cur_list.head_field, cur_list.tail_field, 0, - additional, align_set_group, -1, 0); + additional, align_set_group, -1, 0, 0); w = width(u); cur_tail = adjust_tail; adjust_tail = null; @@ -679,7 +679,7 @@ boolean fin_col(void) pre_adjust_tail = null; } else { u = filtered_vpackage(vlink(cur_list.head_field), - 0, additional, 0, align_set_group, -1, 0); + 0, additional, 0, align_set_group, -1, 0, 0); w = height(u); } n = min_quarterword; /* this represents a span count of 1 */ @@ -772,7 +772,7 @@ void fin_row(void) pointer p; /* the new unset box */ if (cur_list.mode_field == -hmode) { p = filtered_hpack(cur_list.head_field, cur_list.tail_field, 0, - additional, fin_row_group, -1, 0); + additional, fin_row_group, -1, 0, 0); pop_nest(); if (cur_pre_head != cur_pre_tail) append_list(cur_pre_head, cur_pre_tail); @@ -781,7 +781,7 @@ void fin_row(void) append_list(cur_head, cur_tail); } else { p = filtered_vpackage(vlink(cur_list.head_field), - 0, additional, max_depth, fin_row_group, -1, 0); + 0, additional, max_depth, fin_row_group, -1, 0, 0); pop_nest(); vlink(cur_list.tail_field) = p; cur_list.tail_field = p; @@ -809,6 +809,7 @@ void fin_align(void) halfword n; /* matching span amount */ scaled rule_save; /* temporary storage for |overfull_rule| */ halfword pd; /* temporary storage for |prev_depth| */ + halfword ng; /* temporary storage for |new_glue| */ if (cur_group != align_group) confusion("align1"); unsave(); /* that |align_group| was for individual entries */ @@ -933,7 +934,7 @@ value is changed to zero and so is the next tabskip. q = vlink(vlink(q)); } while (q != null); p = filtered_vpackage(preamble, - saved_value(0), saved_level(0), max_depth, preamble_group, -1, 0); + saved_value(0), saved_level(0), max_depth, preamble_group, -1, 0, 0); q = vlink(preamble); do { width(q) = height(q); @@ -987,7 +988,8 @@ value is changed to zero and so is the next tabskip. s = vlink(s); v = glue_ptr(s); - vlink(u) = new_glue(v); + ng = new_glue(v); + vlink(u) = ng; u = vlink(u); subtype(u) = tab_skip_code + 1; t = t + width(v); diff --git a/Build/source/texk/web2c/luatexdir/tex/buildpage.w b/Build/source/texk/web2c/luatexdir/tex/buildpage.w index 409a10c33ba..4c61a510a9c 100644 --- a/Build/source/texk/web2c/luatexdir/tex/buildpage.w +++ b/Build/source/texk/web2c/luatexdir/tex/buildpage.w @@ -906,7 +906,7 @@ void fire_up(halfword c) save_vfuzz = vfuzz; vfuzz = max_dimen; /* inhibit error messages */ box(output_box) = filtered_vpackage(vlink(page_head), - best_size, exactly, page_max_depth, output_group, body_direction, 0); + best_size, exactly, page_max_depth, output_group, body_direction, 0, 0); vbadness = save_vbadness; vfuzz = save_vfuzz; if (last_glue != max_halfword) @@ -1029,6 +1029,6 @@ void resume_after_output(void) flush_node_list(page_disc); page_disc = null; pop_nest(); - lua_node_filter_s(buildpage_filter_callback,lua_key_index(after_output)); + normal_page_filter(after_output); build_page(); } diff --git a/Build/source/texk/web2c/luatexdir/tex/equivalents.h b/Build/source/texk/web2c/luatexdir/tex/equivalents.h index fe3907c0241..cc74fa829a1 100644 --- a/Build/source/texk/web2c/luatexdir/tex/equivalents.h +++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.h @@ -143,10 +143,10 @@ the |number_regs| \.{\\dimen} registers. # define space_skip_code 12 /* glue between words (if not |zero_glue|) */ # define xspace_skip_code 13 /* glue after sentences (if not |zero_glue|) */ # define par_fill_skip_code 14 /* glue on last line of paragraph */ -# define thin_mu_skip_code 15 /* thin space in math formula */ -# define med_mu_skip_code 16 /* medium space in math formula */ -# define thick_mu_skip_code 17 /* thick space in math formula */ -# define math_skip_code 18 +# define math_skip_code 15 +# define thin_mu_skip_code 16 /* thin space in math formula */ +# define med_mu_skip_code 17 /* medium space in math formula */ +# define thick_mu_skip_code 18 /* thick space in math formula */ # define glue_pars 19 /* total number of glue parameters */ # define skip_base (glue_base+glue_pars) /* table of |number_regs| ``skip'' registers */ diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.w b/Build/source/texk/web2c/luatexdir/tex/linebreak.w index 29146424fe4..58afdb8e535 100644 --- a/Build/source/texk/web2c/luatexdir/tex/linebreak.w +++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.w @@ -118,8 +118,7 @@ void line_break(boolean d, int line_break_context) couple_nodes(cur_list.tail_field, final_par_glue); cur_list.tail_field = vlink(cur_list.tail_field); lua_node_filter(pre_linebreak_filter_callback, - line_break_context, - temp_head, + line_break_context, temp_head, addressof(cur_list.tail_field)); last_line_fill = cur_list.tail_field; pop_nest(); diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.h b/Build/source/texk/web2c/luatexdir/tex/mainbody.h index d54acc43caf..fdef20ab882 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mainbody.h +++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.h @@ -49,7 +49,7 @@ in production versions of \TeX. # define sup_nest_size 4000 # define inf_max_in_open 6 -# define sup_max_in_open 127 +# define sup_max_in_open 600 /* was 127. now okay for some 512 nested lua calls */ # define inf_param_size 60 # define sup_param_size 32767 diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.w b/Build/source/texk/web2c/luatexdir/tex/mainbody.w index 5936def5b9f..a8d35d7ac56 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mainbody.w +++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.w @@ -350,7 +350,7 @@ int main_initialize(void) bad = 3; if (hash_prime > hash_size) bad = 5; - if (max_in_open >= 128) + if (max_in_open >= (sup_max_in_open+1)) /* 128 */ bad = 6; /* Here are the inequalities that the quarterword and halfword values must satisfy (or rather, the inequalities that they mustn't satisfy): */ diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w index 12a4bbab583..bf432e308da 100644 --- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w +++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w @@ -87,8 +87,6 @@ #define prev_graf cur_list.pg_field #define dir_save cur_list.dirs_field -#define check_filter(A) if (!output_active) lua_node_filter_s(buildpage_filter_callback,lua_key_index(A)) - #define var_code 7 /* math code meaning ``use the current family'' */ @ We come now to the |main_control| routine, which contains the master @@ -238,6 +236,8 @@ static void run_app_space (void) { } else { temp_ptr = new_param_glue(space_skip_code); } +/* so from now we have a subtype with spaces: */ +subtype(temp_ptr) = space_skip_code + 1 ; couple_nodes(tail,temp_ptr); tail = temp_ptr; } @@ -484,7 +484,7 @@ like \.{\\vbox}, \.{\\insert}, or \.{\\output}. static void run_par_end_vmode (void) { normal_paragraph(); if (mode > 0) { - check_filter(vmode_par); + checked_page_filter(vmode_par); build_page(); } } @@ -495,7 +495,7 @@ static void run_par_end_hmode (void) { off_save(); /* this tries to recover from an alignment that didn't end properly */ end_graf(bottom_level); /* this takes us to the enclosing mode, if |mode>0| */ if (mode == vmode) { - check_filter(hmode_par); + checked_page_filter(hmode_par); build_page(); } } @@ -1003,6 +1003,8 @@ void app_space(void) halfword q; /* glue node */ if ((space_factor >= 2000) && (xspace_skip != zero_glue)) { q = new_param_glue(xspace_skip_code); +/* so from now we have a subtype with spaces: */ +subtype(q) = xspace_skip_code + 1; } else { if (space_skip != zero_glue) { main_p = new_spec(space_skip); @@ -1019,6 +1021,8 @@ void app_space(void) shrink(main_p) = xn_over_d(shrink(main_p), 1000, space_factor); q = new_glue(main_p); glue_ref_count(main_p) = null; +/* so from now we have a subtype with spaces: */ +subtype(q) = space_skip_code + 1; } couple_nodes(tail, q); tail = q; @@ -1114,7 +1118,7 @@ boolean its_all_over(void) width(tail) = hsize; tail_append(new_glue(fill_glue)); tail_append(new_penalty(-010000000000)); - lua_node_filter_s(buildpage_filter_callback,lua_key_index(end)); + normal_page_filter(end); build_page(); /* append \.{\\hbox to \\hsize\{\}\\vfill\\penalty-'10000000000} */ } return false; @@ -1309,7 +1313,7 @@ void handle_right_brace(void) list_ptr(p) = null; flush_node(p); if (nest_ptr == 0) { - check_filter(insert); + checked_page_filter(insert); build_page(); } break; @@ -1435,7 +1439,7 @@ void box_end(int box_context) adjust_tail = null; } if (mode > 0) { - check_filter(box); + checked_page_filter(box); build_page(); } } else { @@ -1545,7 +1549,7 @@ void new_graf(boolean indented) if (every_par != null) begin_token_list(every_par, every_par_text); if (nest_ptr == 1) { - check_filter(new_graf); + checked_page_filter(new_graf); build_page(); /* put |par_skip| glue on current page */ } } @@ -1679,7 +1683,7 @@ void append_penalty(void) scan_int(); tail_append(new_penalty(cur_val)); if (mode == vmode) { - check_filter(penalty); + checked_page_filter(penalty); build_page(); } } diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.h b/Build/source/texk/web2c/luatexdir/tex/mlist.h index 30bfa19fb8f..bd156212220 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mlist.h +++ b/Build/source/texk/web2c/luatexdir/tex/mlist.h @@ -28,7 +28,8 @@ extern void run_mlist_to_hlist(halfword, boolean, int); extern void mlist_to_hlist(halfword, boolean, int); extern void fixup_math_parameters(int fam_id, int size_id, int f, int lvl); -extern scaled get_math_quad(int a); +extern scaled get_math_quad_style(int a); +extern scaled get_math_quad_size(int a); #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.w b/Build/source/texk/web2c/luatexdir/tex/mlist.w index 3499a6714f3..5932a9f9dbe 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mlist.w +++ b/Build/source/texk/web2c/luatexdir/tex/mlist.w @@ -223,24 +223,27 @@ static scaled accent_base_height(int f) return a; } -@ the non-staticness of this function is for the benefit of |texmath.w| +@ The non-staticness of this function is for the benefit of |texmath.w|. Watch out, +this one uses the style! The style and size numbers don't match because we have +cramped styles. @c -scaled get_math_quad(int var) +scaled get_math_quad_style(int var) { scaled a = get_math_param(math_param_quad, var); if (a == undefined_math_parameter) { math_param_error("quad", var); - a = 0; + return 0; + } else { + return a; } - return a; } -@ this parameter is different because it is called with a size +@ For this reason the next one is different because it is called with a size specifier instead of a style specifier. @c -static scaled math_axis(int b) +static scaled math_axis_size(int b) { scaled a; int var; @@ -253,13 +256,14 @@ static scaled math_axis(int b) a = get_math_param(math_param_axis, var); if (a == undefined_math_parameter) { math_param_error("axis", var); - a = 0; + return 0; + } else { + return a; } - return a; } @ @c -static scaled get_math_quad_size(int b) +scaled get_math_quad_size(int b) { int var; if (b == script_size) @@ -309,7 +313,7 @@ static scaled do_get_math_param_or_error(int var, int param, const char *name) static scaled get_delimiter_height(scaled max_d, scaled max_h, boolean axis) { scaled delta, delta1, delta2; if (axis) { - delta2 = max_d + math_axis(cur_size); + delta2 = max_d + math_axis_size(cur_size); } else { delta2 = max_d; } @@ -361,7 +365,6 @@ static scaled get_delimiter_height(scaled max_d, scaled max_h, boolean axis) { #define fraction_num_up(a) get_math_param_or_error(a, fraction_num_up) #define fraction_denom_down(a) get_math_param_or_error(a, fraction_denom_down) #define fraction_del_size_new(a) get_math_param_or_error(a, fraction_del_size) -#define fraction_del_size_new(a) get_math_param_or_error(a, fraction_del_size) /* #define fraction_del_size_old(a) get_math_param(a, math_param_fraction_del_size) */ @@ -393,6 +396,7 @@ static scaled get_delimiter_height(scaled max_d, scaled max_h, boolean axis) { @ @c void fixup_math_parameters(int fam_id, int size_id, int f, int lvl) { + if (is_new_mathfont(f)) { /* fix all known parameters */ DEFINE_MATH_PARAMETERS(math_param_quad, size_id, @@ -927,15 +931,14 @@ static const char *math_size_string(int s) information: @c -#define setup_cur_size(a) do { \ - if (a==script_style || \ - a==cramped_script_style) \ - cur_size=script_size; \ - else if (a==script_script_style || \ - a==cramped_script_script_style) \ - cur_size=script_script_size; \ - else cur_size=text_size; \ - } while (0) +#define setup_cur_size(a) do { \ + if (a==script_style || a==cramped_script_style) \ + cur_size = script_size; \ + else if (a==script_script_style || a==cramped_script_script_style) \ + cur_size = script_script_size; \ + else \ + cur_size = text_size; \ +} while (0) @ a simple routine that creates a flat copy of a nucleus @@ -1458,7 +1461,7 @@ static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat, /* vertical variant */ shift_amount(b) = half(height(b) - depth(b)); if (shift) { - shift_amount(b) -= math_axis(s); + shift_amount(b) -= math_axis_size(s); } } delete_attribute_ref(att); @@ -1808,7 +1811,7 @@ static void make_vcenter(pointer q) if (type(v) != vlist_node) confusion("vcenter"); delta = height(v) + depth(v); - height(v) = math_axis(cur_size) + half(delta); + height(v) = math_axis_size(cur_size) + half(delta); depth(v) = delta - height(v); } @@ -2421,14 +2424,14 @@ static void make_fraction(pointer q, int cur_style) clr2 = fraction_denom_vgap(cur_style); delta = half(thickness(q)); if (fractionexact(q)) { - delta1 = clr1 - ((shift_up - depth(x) ) - (math_axis(cur_size) + delta)); - delta2 = clr2 - ((shift_down - height(z)) + (math_axis(cur_size) - delta)); + delta1 = clr1 - ((shift_up - depth(x) ) - (math_axis_size(cur_size) + delta)); + delta2 = clr2 - ((shift_down - height(z)) + (math_axis_size(cur_size) - delta)); } else { delta = half(thickness(q)); clr1 = ext_xn_over_d(clr1, thickness(q), fraction_rule(cur_style)); clr2 = ext_xn_over_d(clr2, thickness(q), fraction_rule(cur_style)); - delta1 = clr1 - ((shift_up - depth(x) ) - (math_axis(cur_size) + delta)); - delta2 = clr2 - ((shift_down - height(z)) + (math_axis(cur_size) - delta)); + delta1 = clr1 - ((shift_up - depth(x) ) - (math_axis_size(cur_size) + delta)); + delta2 = clr2 - ((shift_down - height(z)) + (math_axis_size(cur_size) - delta)); } if (delta1 > 0) { shift_up = shift_up + delta1; @@ -2444,7 +2447,7 @@ static void make_fraction(pointer q, int cur_style) shift_up = skewed_fraction_vgap(cur_style); if (!fractionnoaxis(q)) { - shift_up += half(math_axis(cur_size)); + shift_up += half(math_axis_size(cur_size)); } shift_down = shift_up; @@ -2525,11 +2528,11 @@ static void make_fraction(pointer q, int cur_style) couple_nodes(p,z); } else { y = do_fraction_rule(thickness(q), node_attr(q)); - p = new_kern((math_axis(cur_size) - delta) - (height(z) - shift_down)); + p = new_kern((math_axis_size(cur_size) - delta) - (height(z) - shift_down)); reset_attributes(p, node_attr(q)); couple_nodes(y,p); couple_nodes(p,z); - p = new_kern((shift_up - depth(x)) - (math_axis(cur_size) + delta)); + p = new_kern((shift_up - depth(x)) - (math_axis_size(cur_size) + delta)); couple_nodes(p,y); } reset_attributes(p, node_attr(q)); @@ -2552,7 +2555,6 @@ static void make_fraction(pointer q, int cur_style) } else { delta = fraction_del_size_old(cur_style); } - l = do_delimiter(q, left_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL); left_delimiter(q) = null; r = do_delimiter(q, right_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL); @@ -2649,7 +2651,7 @@ static scaled make_op(pointer q, int cur_style) } if (axis_shift) { /* center vertically */ - shift_amount(x) = half(height(x) - depth(x)) - math_axis(cur_size); + shift_amount(x) = half(height(x) - depth(x)) - math_axis_size(cur_size); } type(nucleus(q)) = sub_box_node; math_list(nucleus(q)) = x; @@ -3470,9 +3472,9 @@ static small_number make_left_right(pointer q, int style, scaled max_d, scaled m delimiterdepth(q) = depth(tmp) + shift_amount(tmp); } if (delimiteraxis(q)) { - delimiterheight(q) += math_axis(cur_size); - delimiterdepth(q) -= math_axis(cur_size); - shift_amount(tmp) -= math_axis(cur_size); + delimiterheight(q) += math_axis_size(cur_size); + delimiterdepth(q) -= math_axis_size(cur_size); + shift_amount(tmp) -= math_axis_size(cur_size); } lst = new_node(hlist_node,0); reset_attributes(lst, node_attr(q)); @@ -3801,7 +3803,7 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style) scaled cur_mu; /* the math unit width corresponding to |cur_size| */ r_subtype = op_noad_type_normal; setup_cur_size(cur_style); - cur_mu = x_over_n(get_math_quad(cur_size), 18); + cur_mu = x_over_n(get_math_quad_size(cur_size), 18); while (q != null) { /* we use the fact that no character nodes appear in an mlist, hence @@ -3905,7 +3907,7 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style) case style_node: cur_style = subtype(q); setup_cur_size(cur_style); - cur_mu = x_over_n(get_math_quad(cur_style), 18); + cur_mu = x_over_n(get_math_quad_style(cur_style), 18); goto DONE_WITH_NODE; break; case choice_node: @@ -4026,7 +4028,7 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style) r_subtype = left_noad_side; cur_style = style; setup_cur_size(cur_style); - cur_mu = x_over_n(get_math_quad(cur_size), 18); + cur_mu = x_over_n(get_math_quad_size(cur_size), 18); /* style */ } DONE_WITH_NODE: q = vlink(q); @@ -4052,7 +4054,7 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style) r_subtype = 0; cur_style = style; setup_cur_size(cur_style); - cur_mu = x_over_n(get_math_quad(cur_size), 18); + cur_mu = x_over_n(get_math_quad_size(cur_size), 18); NEXT_NODE: while (q != null) { /* @@ -4099,7 +4101,7 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style) /* Change the current style and |goto delete_q| */ cur_style = subtype(q); setup_cur_size(cur_style); - cur_mu = x_over_n(get_math_quad(cur_size), 18); + cur_mu = x_over_n(get_math_quad_style(cur_style), 18); goto DELETE_Q; break; case whatsit_node: diff --git a/Build/source/texk/web2c/luatexdir/tex/packaging.h b/Build/source/texk/web2c/luatexdir/tex/packaging.h index 6c909d64680..21845d5d0aa 100644 --- a/Build/source/texk/web2c/luatexdir/tex/packaging.h +++ b/Build/source/texk/web2c/luatexdir/tex/packaging.h @@ -63,14 +63,14 @@ extern halfword new_margin_kern(scaled w, halfword p, int side); A = vlink(A); \ } while (0) -extern halfword filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, int d, int just_pack); +extern halfword filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, int d, int just_pack, halfword attr); extern scaled_whd natural_sizes(halfword p, halfword pp, glue_ratio g_mult, int g_sign, int g_order, int d); extern halfword hpack(halfword p, scaled w, int m, int d); extern int pack_begin_line; extern halfword vpackage(halfword p, scaled h, int m, scaled l, int d); -extern halfword filtered_vpackage(halfword p, scaled h, int m, scaled l, int grp, int d, int just_pack); +extern halfword filtered_vpackage(halfword p, scaled h, int m, scaled l, int grp, int d, int just_pack, halfword attr); extern void finish_vcenter(void); extern void package(int c); extern void append_to_vlist(halfword b, int location); diff --git a/Build/source/texk/web2c/luatexdir/tex/packaging.w b/Build/source/texk/web2c/luatexdir/tex/packaging.w index 8c692ae7975..0c474a50add 100644 --- a/Build/source/texk/web2c/luatexdir/tex/packaging.w +++ b/Build/source/texk/web2c/luatexdir/tex/packaging.w @@ -1112,19 +1112,7 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction) } @ @c -/* -halfword filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, int pac) -{ - halfword q; - new_hyphenation(p, qt); - (void) new_ligkern(p, qt); // we don't care about the tail in this case - q = vlink(p); - q = lua_hpack_filter(q, w, m, grp, pac); - return hpack(q, w, m, pac); -} -*/ - -halfword filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, int pac, int just_pack) +halfword filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, int pac, int just_pack, halfword attr) { halfword q; if (just_pack) { @@ -1142,7 +1130,7 @@ halfword filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, int p (void) new_ligkern(p, qt); /* we don't care about the tail in this case */ q = vlink(p); /* maybe here: alink(p) = null */ - q = lua_hpack_filter(q, w, m, grp, pac); /* ignores empty anyway */ /* maybe also pass tail */ + q = lua_hpack_filter(q, w, m, grp, pac, attr); /* ignores empty anyway */ /* maybe also pass tail */ } return hpack(q, w, m, pac); } @@ -1555,12 +1543,12 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction) } @ @c -halfword filtered_vpackage(halfword p, scaled h, int m, scaled l, int grp, int pack_direction, int just_pack) +halfword filtered_vpackage(halfword p, scaled h, int m, scaled l, int grp, int pack_direction, int just_pack, halfword attr) { halfword q = p; if (!just_pack) /* if (q != null) */ - q = lua_vpack_filter(q, h, m, l, grp, pack_direction); + q = lua_vpack_filter(q, h, m, l, grp, pack_direction, attr); return vpackage(q, h, m, l, pack_direction); } @@ -1590,11 +1578,11 @@ void package(int c) saved4 = saved_value(4); if (cur_list.mode_field == -hmode) { cur_box = filtered_hpack(cur_list.head_field, cur_list.tail_field, - saved_value(1), saved_level(1), grp, saved_level(2), saved4); + saved_value(1), saved_level(1), grp, saved_level(2), saved4, saved3); subtype(cur_box) = hbox_list; } else { cur_box = filtered_vpackage(vlink(cur_list.head_field), - saved_value(1), saved_level(1), d, grp, saved_level(2), saved4); + saved_value(1), saved_level(1), d, grp, saved_level(2), saved4, saved3); if (c == vtop_code) { /* Read just the height and depth of |cur_box|, for \.{\\vtop}. The @@ -2010,12 +1998,12 @@ halfword vsplit(halfword n, scaled h, int m) /* the |eq_level| of the box stays the same */ box(n) = null; } else { - box(n) = filtered_vpackage(q, 0, additional, dimen_par(max_depth_code), split_keep_group, vdir, 0); + box(n) = filtered_vpackage(q, 0, additional, dimen_par(max_depth_code), split_keep_group, vdir, 0, 0); } if (m == exactly) { - return filtered_vpackage(p, h, exactly, dimen_par(split_max_depth_code), split_off_group, vdir, 0); + return filtered_vpackage(p, h, exactly, dimen_par(split_max_depth_code), split_off_group, vdir, 0, 0); } else { - return filtered_vpackage(p, 0, additional, dimen_par(max_depth_code), split_off_group, vdir, 0); + return filtered_vpackage(p, 0, additional, dimen_par(max_depth_code), split_off_group, vdir, 0, 0); } } diff --git a/Build/source/texk/web2c/luatexdir/tex/postlinebreak.w b/Build/source/texk/web2c/luatexdir/tex/postlinebreak.w index b78b599aac6..43ceadcca28 100644 --- a/Build/source/texk/web2c/luatexdir/tex/postlinebreak.w +++ b/Build/source/texk/web2c/luatexdir/tex/postlinebreak.w @@ -451,21 +451,17 @@ void ext_post_line_break(int paragraph_dir, /* /Call the packaging subroutine, setting |just_box| to the justified box; */ if ((vlink(contrib_head) != null)) - if (!output_active) - lua_node_filter_s(buildpage_filter_callback, lua_key_index(pre_box)); + checked_break_filter(pre_box); if (pre_adjust_head != pre_adjust_tail) { append_list(pre_adjust_head, pre_adjust_tail); - if (!output_active) - lua_node_filter_s(buildpage_filter_callback, lua_key_index(pre_adjust)); + checked_break_filter(pre_adjust); } pre_adjust_tail = null; append_to_vlist(just_box,lua_key_index(post_linebreak)); - if (!output_active) - lua_node_filter_s(buildpage_filter_callback, lua_key_index(box)); + checked_break_filter(box); if (adjust_head != adjust_tail) { append_list(adjust_head, adjust_tail); - if (!output_active) - lua_node_filter_s(buildpage_filter_callback, lua_key_index(adjust)); + checked_break_filter(adjust); } adjust_tail = null; diff --git a/Build/source/texk/web2c/luatexdir/tex/scanning.w b/Build/source/texk/web2c/luatexdir/tex/scanning.w index 0a9276c7db7..99e9ca5e893 100644 --- a/Build/source/texk/web2c/luatexdir/tex/scanning.w +++ b/Build/source/texk/web2c/luatexdir/tex/scanning.w @@ -1300,20 +1300,37 @@ void scan_dimen(boolean mu, boolean inf, boolean shortcut) \TeX, a specification like `\.{filllll}' or `\.{fill L L L}' will lead to two error messages (one for each additional keyword \.{"l"}). Not so for \LuaTeX, it just parses the construct in reverse. - */ - if (scan_keyword("filll")) { - cur_order = filll; - goto ATTACH_FRACTION; - } else if (scan_keyword("fill")) { - cur_order = fill; - goto ATTACH_FRACTION; - } else if (scan_keyword("fil")) { - cur_order = fil; - goto ATTACH_FRACTION; - } else if (scan_keyword("fi")) { - cur_order = sfi; + + if (scan_keyword("filll")) { + cur_order = filll; + goto ATTACH_FRACTION; + } else if (scan_keyword("fill")) { + cur_order = fill; + goto ATTACH_FRACTION; + } else if (scan_keyword("fil")) { + cur_order = fil; + goto ATTACH_FRACTION; + } else if (scan_keyword("fi")) { + cur_order = sfi; + goto ATTACH_FRACTION; + } + + But ... it failed in alignments so now we do this. And, as we support an extra + l we don't issue an error message (we didn't do that anyway). + */ + if (scan_keyword("fi")) { + cur_order = sfi; + if (scan_keyword("l")) { + cur_order = fil; + if (scan_keyword("l")) { + cur_order = fill; + if (scan_keyword("l")) { + cur_order = filll; + } + } + } goto ATTACH_FRACTION; - } + } } /* Scan for (u)units that are internal dimensions; |goto attach_sign| with diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.w b/Build/source/texk/web2c/luatexdir/tex/texmath.w index f501d403597..216d2364984 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texmath.w +++ b/Build/source/texk/web2c/luatexdir/tex/texmath.w @@ -1079,8 +1079,7 @@ void enter_display_math(void) if (every_display != null) begin_token_list(every_display, every_display_text); if (nest_ptr == 1) { - if (!output_active) - lua_node_filter_s(buildpage_filter_callback,lua_key_index(before_display)); + checked_page_filter(before_display); build_page(); } } @@ -2144,7 +2143,7 @@ static void resume_after_display(void) if (cur_cmd != spacer_cmd) back_input(); if (nest_ptr == 1) { - lua_node_filter_s(buildpage_filter_callback,lua_key_index(after_display)); + normal_page_filter(after_display); build_page(); } } @@ -2197,7 +2196,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p) } else { eqno_w = width(eqno_box); eqno_width = eqno_w; - eqno_w2 = eqno_w + round_xn_over_d(math_eqno_gap_step, get_math_quad(text_size), 1000); + eqno_w2 = eqno_w + round_xn_over_d(math_eqno_gap_step, get_math_quad_style(text_style), 1000); subtype(eqno_box) = equation_number_list; /* new */ /* build_attribute_list(eqno_box); */ /* probably already set */ } diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h index cbf983d9736..1f1a4e82964 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h @@ -834,6 +834,7 @@ extern node_info node_data[]; extern node_info whatsit_node_data[]; extern const char *node_subtypes_glue[]; +extern const char *node_subtypes_mathglue[]; extern const char *node_subtypes_leader[]; extern const char *node_subtypes_fill[]; extern const char *node_subtypes_penalty[]; diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.w b/Build/source/texk/web2c/luatexdir/tex/texnodes.w index 698fb76e82d..a201c6da714 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.w +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.w @@ -267,8 +267,11 @@ const char *node_fields_whatsit_pdf_restore[] = { const char *node_subtypes_glue[] = { "userskip", "lineskip", "baselineskip", "parskip", "abovedisplayskip", "belowdisplayskip", "abovedisplayshortskip", "belowdisplayshortskip", "leftskip", "rightskip", "topskip", - "splittopskip", "tabskip", "spaceskip", "xspaceskip", "parfillskip", "thinmuskip", - "medmuskip", "thickmuskip", "mathskip", NULL + "splittopskip", "tabskip", "spaceskip", "xspaceskip", "parfillskip", + "mathskip", "thinmuskip", "medmuskip", "thickmuskip", NULL +}; +const char *node_subtypes_mathglue[] = { /* 98+ */ + "conditionalmathskip", "muglue", NULL }; const char *node_subtypes_leader[] = { /* 100+ */ "leaders", "cleaders", "xleaders", "gleaders", NULL diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.w b/Build/source/texk/web2c/luatexdir/tex/textoken.w index 53220836f9b..41c9293336a 100644 --- a/Build/source/texk/web2c/luatexdir/tex/textoken.w +++ b/Build/source/texk/web2c/luatexdir/tex/textoken.w @@ -503,7 +503,6 @@ boolean scan_keyword(const char *s) halfword q; /* new node being added to the token list via |store_new_token| */ const char *k; /* index into |str_pool| */ halfword save_cur_cs = cur_cs; - int saved_align_state = align_state; if (strlen(s) == 0) /* was assert (strlen(s) > 1); */ return false ; /* but not with newtokenlib zero keyword simply doesn't match */ p = backup_head; @@ -511,8 +510,7 @@ boolean scan_keyword(const char *s) k = s; while (*k) { get_x_token(); /* recursion is possible here */ - if ((cur_cs == 0) && - ((cur_chr == *k) || (cur_chr == *k - 'a' + 'A'))) { + if ((cur_cs == 0) && ((cur_chr == *k) || (cur_chr == *k - 'a' + 'A'))) { store_new_token(cur_tok); k++; } else if ((cur_cmd != spacer_cmd) || (p != backup_head)) { @@ -522,8 +520,6 @@ boolean scan_keyword(const char *s) token_link(q) = null; token_link(p) = q; begin_token_list(token_link(backup_head), backed_up); - if (cur_cmd != endv_cmd) - align_state = saved_align_state; } else { back_input(); } @@ -534,8 +530,6 @@ boolean scan_keyword(const char *s) if (token_link(backup_head) != null) flush_list(token_link(backup_head)); cur_cs = save_cur_cs; - if (cur_cmd != endv_cmd) - align_state = saved_align_state; return true; } |