From 9111ac6d97d7931a2a9bbdad69f5c54de4172318 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 30 May 2023 23:06:58 +0200 Subject: 2023-05-30 22:20:00 --- scripts/context/lua/mtx-install.lua | 38 ++++-- source/luametatex/source/lua/lmtnodelib.c | 18 +++ source/luametatex/source/lua/lmttexlib.c | 21 +++ source/luametatex/source/luametatex.h | 2 +- source/luametatex/source/tex/texcommands.c | 1 + source/luametatex/source/tex/texequivalents.h | 2 + source/luametatex/source/tex/texlinebreak.c | 146 ++++++++++++++++++--- source/luametatex/source/tex/texmath.c | 2 + source/luametatex/source/tex/texmlist.c | 38 +++--- source/luametatex/source/tex/texnodes.h | 16 ++- source/luametatex/source/tex/texpackaging.c | 2 +- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/status-files.pdf | Bin 24639 -> 24677 bytes tex/context/base/mkiv/status-lua.pdf | Bin 270724 -> 270812 bytes tex/context/base/mkxl/cont-new.mkxl | 2 +- tex/context/base/mkxl/context.mkxl | 2 +- tex/context/base/mkxl/toks-aux.lmt | 25 ++-- tex/context/base/mkxl/trac-vis.lmt | 80 ++++++++--- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 22 files changed, 313 insertions(+), 92 deletions(-) diff --git a/scripts/context/lua/mtx-install.lua b/scripts/context/lua/mtx-install.lua index ad2e629dc..fc164cc6a 100644 --- a/scripts/context/lua/mtx-install.lua +++ b/scripts/context/lua/mtx-install.lua @@ -40,14 +40,15 @@ local gsub, find, escapedpattern = string.gsub, string.find, string.escapedpatte local round = math.round local savetable, loadtable, sortedhash = table.save, table.load, table.sortedhash local copyfile, joinfile, filesize, dirname, addsuffix, basename = file.copy, file.join, file.size, file.dirname, file.addsuffix, file.basename -local isdir, isfile, walkdir, pushdir, popdir, currentdir = lfs.isdir, lfs.isfile, lfs.dir, lfs.chdir, dir.push, dir.pop, currentdir +local isdir, isfile, walkdir, pushdir, popdir, currentdir = lfs.isdir, lfs.isfile, lfs.dir, dir.push, dir.pop, dir.current local mkdirs, globdir = dir.mkdirs, dir.glob local osremove, osexecute, ostype, resultof = os.remove, os.execute, os.type, os.resultof -local savedata = io.savedata +local savedata, loaddata = io.savedata, io.loaddata local formatters = string.formatters local httprequest = socket.http.request -local usecurl = false +local usecurl = false +local protocol = "http" local function checkcurl() local s = resultof("curl --version") @@ -191,7 +192,7 @@ function install.identify() local name = files[i] local size = filesize(name) local base = gsub(name,pattern,"") - local data = io.loaddata(name) + local data = loaddata(name) if data and #data > 0 then local stamp = hashdata(data) details[i] = { base, size, stamp } @@ -222,6 +223,8 @@ function install.identify() date = os.date("%Y-%m-%d"), }) + os.exit() + end local function disclaimer() @@ -249,15 +252,15 @@ function install.update() return ok end - local function download(what,url,target,total,done,oldhash) + local function download(what,url,target,total,done,hash) local data = fetch(url .. "/" .. target) - if data then + if type(data) == "string" and #data > 0 then if total and done then report("%-8s : %3i %% : %8i : %s",what,round(100*done/total),#data,target) else report("%-8s : %8i : %s",what,#data,target) end - if oldhash and oldhash ~= hashdata(data) then + if hash and hash ~= hashdata(data) then return "different hash value" elseif not validdir(dirname(target)) then return "wrong target directory" @@ -340,8 +343,9 @@ function install.update() report("fetching %a",zipurl) local zipdata = fetch(zipurl) if zipdata then - io.savedata(zipfile,zipdata) + savedata(zipfile,zipdata) else + osremove(zipfile) zipfile = false end end @@ -357,6 +361,7 @@ function install.update() path = ".", -- verbose = true, verbose = "steps", + collect = true, -- sort of a check } if utilities.zipfiles.unzipdir(specification) then @@ -365,7 +370,6 @@ function install.update() else osremove(zipfile) end - end count = #new @@ -383,7 +387,10 @@ function install.update() local target = joinfile(tree,name) done = done + size if not skiplist or not skiplist[basename(name)] then - download("new",url,target,total,done) + local message = download("new",url,target,total,done) + if message then + report("%s",message) + end else report("skipping %s",target) end @@ -494,7 +501,7 @@ function install.update() for i=1,#list do local host = list[i] - local data, status, detail = fetch("http://" .. host .. "/" .. instance .. "/tex/status.tma") + local data, status, detail = fetch(protocol .. "://" .. host .. "/" .. instance .. "/tex/status.tma") if status == 200 and type(data) == "string" then local t = loadstring(data) if type(t) == "function" then @@ -512,7 +519,7 @@ function install.update() return end - local url = "http://" .. server .. "/" .. instance .. "/" + local url = protocol .. "://" .. server .. "/" .. instance .. "/" local texmfplatform = "texmf-" .. platform @@ -638,6 +645,7 @@ function install.update() report("") report("update, done") + end function install.modules() @@ -654,12 +662,16 @@ end if environment.argument("secure") then usecurl = checkcurl() - if not usecurl then + if usecurl then + protocol = "https" + else report("no curl installed, quitting") os.exit() end end +io.output():setvbuf("no") + if environment.argument("identify") then install.identify() elseif environment.argument("install") then diff --git a/source/luametatex/source/lua/lmtnodelib.c b/source/luametatex/source/lua/lmtnodelib.c index 58c3bb0a7..66cf528fc 100644 --- a/source/luametatex/source/lua/lmtnodelib.c +++ b/source/luametatex/source/lua/lmtnodelib.c @@ -2647,6 +2647,15 @@ static int nodelib_direct_getoptions(lua_State *L) case disc_node: lua_pushinteger(L, disc_options(n)); return 1; + case glue_node: + lua_pushinteger(L, glue_options(n)); + return 1; + case math_node: + lua_pushinteger(L, math_options(n)); + return 1; + case penalty_node: + lua_pushinteger(L, penalty_options(n)); + return 1; case simple_noad: case radical_noad: case fraction_noad: @@ -2674,6 +2683,15 @@ static int nodelib_direct_setoptions(lua_State *L) case disc_node: set_disc_options(n, lmt_tohalfword(L, 2)); break; + case glue_node: + tex_add_glue_option(n, lmt_tohalfword(L, 2)); + return 1; + case math_node: + tex_add_math_option(n, lmt_tohalfword(L, 2)); + return 1; + case penalty_node: + tex_add_penalty_option(n, lmt_tohalfword(L, 2)); + return 1; case simple_noad: case radical_noad: case fraction_noad: diff --git a/source/luametatex/source/lua/lmttexlib.c b/source/luametatex/source/lua/lmttexlib.c index 1bfd2c38c..4f2ecbb5c 100644 --- a/source/luametatex/source/lua/lmttexlib.c +++ b/source/luametatex/source/lua/lmttexlib.c @@ -5015,6 +5015,24 @@ static int texlib_getglyphoptionvalues(lua_State *L) return 1; } +static int texlib_getglueoptionvalues(lua_State *L) +{ + lua_createtable(L, 3, 0); + lua_set_string_by_index(L, glue_option_normal, "normal"); + lua_set_string_by_index(L, glue_option_no_auto_break, "noautobreak"); + lua_set_string_by_index(L, glue_option_short_math, "shortmath"); + return 1; +} + +static int texlib_getpenaltyoptionvalues(lua_State *L) +{ + lua_createtable(L, 3, 0); + lua_set_string_by_index(L, penalty_option_normal, "normal"); + lua_set_string_by_index(L, penalty_option_math_forward, "mathforward");; + lua_set_string_by_index(L, penalty_option_math_backward, "mathbackward"); + return 1; +} + static int texlib_getnoadoptionvalues(lua_State *L) { lua_createtable(L, 2, 37); @@ -5780,6 +5798,9 @@ static const struct luaL_Reg texlib_function_list[] = { { "setrunstate", texlib_setrunstate }, { "gethyphenationvalues", texlib_gethyphenationvalues }, { "getglyphoptionvalues", texlib_getglyphoptionvalues }, + { "getglueoptionvalues", texlib_getglueoptionvalues }, + { "getmathoptionvalues", texlib_getglueoptionvalues }, + { "getpenaltyoptionvalues", texlib_getpenaltyoptionvalues }, { "getnoadoptionvalues", texlib_getnoadoptionvalues }, { "getdiscoptionvalues", texlib_getdiscoptionvalues }, { "getlistanchorvalues", texlib_getlistanchorvalues }, diff --git a/source/luametatex/source/luametatex.h b/source/luametatex/source/luametatex.h index d9df0e14c..a6e9b5295 100644 --- a/source/luametatex/source/luametatex.h +++ b/source/luametatex/source/luametatex.h @@ -92,7 +92,7 @@ # define luametatex_version 210 # define luametatex_revision 9 # define luametatex_version_string "2.10.09" -# define luametatex_development_id 20230529 +# define luametatex_development_id 20230530 # define luametatex_name_camelcase "LuaMetaTeX" # define luametatex_name_lowercase "luametatex" diff --git a/source/luametatex/source/tex/texcommands.c b/source/luametatex/source/tex/texcommands.c index 26ae7cef9..1423c80d0 100644 --- a/source/luametatex/source/tex/texcommands.c +++ b/source/luametatex/source/tex/texcommands.c @@ -167,6 +167,7 @@ void tex_initialize_commands(void) tex_primitive(luatex_command, "preinlinepenalty", internal_int_cmd, pre_inline_penalty_code, internal_int_base); tex_primitive(luatex_command, "postshortinlinepenalty", internal_int_cmd, post_short_inline_penalty_code, internal_int_base); tex_primitive(luatex_command, "preshortinlinepenalty", internal_int_cmd, pre_short_inline_penalty_code, internal_int_base); + tex_primitive(luatex_command, "shortinlineorphanpenalty", internal_int_cmd, short_inline_orphan_penalty_code, internal_int_base); tex_primitive(tex_command, "pretolerance", internal_int_cmd, pre_tolerance_code, internal_int_base); tex_primitive(tex_command, "relpenalty", internal_int_cmd, post_relation_penalty_code, internal_int_base); /*tex For old times sake. */ tex_primitive(tex_command, "righthyphenmin", internal_int_cmd, right_hyphen_min_code, internal_int_base); diff --git a/source/luametatex/source/tex/texequivalents.h b/source/luametatex/source/tex/texequivalents.h index b129cb047..384a17e06 100644 --- a/source/luametatex/source/tex/texequivalents.h +++ b/source/luametatex/source/tex/texequivalents.h @@ -437,6 +437,7 @@ typedef enum int_codes { post_inline_penalty_code, /*tex penalty for breaking just after an inlined formula */ pre_short_inline_penalty_code, /*tex penalty for breaking just before a single character inlined formula */ post_short_inline_penalty_code, /*tex penalty for breaking just after a single character inlined formula */ + short_inline_orphan_penalty_code, inter_line_penalty_code, /*tex additional penalty between lines */ double_hyphen_demerits_code, /*tex demerits for double hyphen break */ final_hyphen_demerits_code, /*tex demerits for final hyphen break */ @@ -1411,6 +1412,7 @@ extern void tex_forced_word_define (int g, halfword p, singleword flag, halfword # define post_inline_penalty_par count_parameter(post_inline_penalty_code) # define pre_short_inline_penalty_par count_parameter(pre_short_inline_penalty_code) # define post_short_inline_penalty_par count_parameter(post_short_inline_penalty_code) +# define short_inline_orphan_penalty_par count_parameter(short_inline_orphan_penalty_code) # define local_interline_penalty_par count_parameter(local_interline_penalty_code) # define local_broken_penalty_par count_parameter(local_broken_penalty_code) diff --git a/source/luametatex/source/tex/texlinebreak.c b/source/luametatex/source/tex/texlinebreak.c index 0c2445ffe..93a537ca7 100644 --- a/source/luametatex/source/tex/texlinebreak.c +++ b/source/luametatex/source/tex/texlinebreak.c @@ -2051,7 +2051,7 @@ static void tex_aux_try_break( } else { demerits = demerits * demerits; } - if (penalty != 0) { + if (penalty) { if (penalty > 0) { demerits += (penalty * penalty); } else if (penalty > eject_penalty) { @@ -2198,6 +2198,30 @@ inline static halfword tex_aux_upcoming_penalty(halfword p) { # define max_prev_graf (max_integer/2) +static inline int tex_aux_short_math(halfword m) { + return m && node_subtype(m) == begin_inline_math && math_penalty(m) > 0 && tex_has_math_option(m, glue_option_short_math); +} + +static inline void tex_aux_adapt_short_math_penalty(halfword m, halfword p1, halfword p2) { + if (p1 > math_penalty(m)) { + math_penalty(m) = p1; + } + if (p2 > math_penalty(m)) { + math_penalty(m) = p2; + } +} + +static inline halfword tex_aux_backtrack_over_math(halfword m) +{ + if (node_subtype(m) == end_inline_math) { + do { + m = node_prev(m); + } while (m && node_type(m) != math_node); + } + return m; +} + + void tex_do_line_break(line_break_properties *properties) { /*tex Miscellaneous nodes of temporary interest. */ @@ -2256,7 +2280,7 @@ void tex_do_line_break(line_break_properties *properties) also skip a penalty in the list. */ - if (properties->orphan_penalties || properties->orphan_penalty) { + if (properties->orphan_penalties || properties->orphan_penalty || short_inline_orphan_penalty_par) { halfword current = node_prev(properties->parfill_right_skip); if (current) { /*tex Skip over trailing glue and penalties. */ @@ -2272,37 +2296,119 @@ void tex_do_line_break(line_break_properties *properties) } INJECT: if (properties->orphan_penalties) { - /*tex Inject specified penalties before spaces. */ + /*tex + Inject specified penalties before spaces. When wwe see a math node with a penalty + set then we take the max and jump over a (preceding) skip. Maybe at some point + the |short_inline_orphan_penalty_par| value will also move into the par state. + */ int n = specification_count(properties->orphan_penalties); if (n > 0) { + int skip = 0; halfword i = 0; while (current) { - if (node_type(current) == glue_node) { - switch (node_subtype(current)) { - case space_skip_glue: - case xspace_skip_glue: - case zero_space_skip_glue: - current = tex_aux_inject_orphan_penalty(current, tex_get_specification_penalty(properties->orphan_penalties, ++i)); + switch (node_type(current)) { + case glue_node: + switch (node_subtype(current)) { + case space_skip_glue: + case xspace_skip_glue: + case zero_space_skip_glue: + if (skip) { + skip = 0; + } else { + current = tex_aux_inject_orphan_penalty(current, tex_get_specification_penalty(properties->orphan_penalties, ++i)); + } + if (i == n) { + goto ALLDONE; + } else { + break; + } + } + break; + case math_node: + current = tex_aux_backtrack_over_math(current); + if (tex_aux_short_math(current)) { + halfword p = tex_get_specification_penalty(properties->orphan_penalties, ++i); + tex_aux_adapt_short_math_penalty(current, short_inline_orphan_penalty_par, p); if (i == n) { goto ALLDONE; } else { - break; + skip = 1; } - } + } else { + goto ALLDONE; + } + break; + default: + skip = 0; + break; } current = node_prev(current); } } - } else { + } else if (properties->orphan_penalty) { + /*tex + We inject a penalty before the space but we need to intercept the math penalty + that actually is set on the math mode. If no math orphan penalty is set of when + we have wider math then we assume it's okay. We don't want interference in math + penalties. + + */ while (current) { - if (node_type(current) == glue_node) { - switch (node_subtype(current)) { - case space_skip_glue: - case xspace_skip_glue: - case zero_space_skip_glue: - tex_aux_inject_orphan_penalty(current, properties->orphan_penalty); - goto ALLDONE; - } + switch (node_type(current)) { + case glue_node: + switch (node_subtype(current)) { + case space_skip_glue: + case xspace_skip_glue: + case zero_space_skip_glue: + tex_aux_inject_orphan_penalty(current, properties->orphan_penalty); + goto ALLDONE; + default: + /* maybe we should always quit here */ + break; + } + break; + case math_node: + current = tex_aux_backtrack_over_math(current); + if (tex_aux_short_math(current)) { + tex_aux_adapt_short_math_penalty(current, short_inline_orphan_penalty_par, properties->orphan_penalty); + } + goto ALLDONE; + case disc_node: + /* + This is (or has been) actually an old \CONTEXT\ feature doen in \LUA, + so what should we do here: set the penalty and quit or maybe run till we + hit a non glyph, disc or font kern? Hyphens already get penalties. So, + we do nothong. + */ + break; + } + current = node_prev(current); + } + } else if (short_inline_orphan_penalty_par) { + /*tex + Short formulas at the end of a line are normally not followed by something other + than punctuation. In practice one can set this penalty to e.g. a relatively low + 200 to get the desired effect. We definitely quit on a space and take for granted + what comes before we see the formula. + + */ + while (current) { + switch (node_type(current)) { + case glue_node: + switch (node_subtype(current)) { + case space_skip_glue: + case xspace_skip_glue: + case zero_space_skip_glue: + goto ALLDONE; + } + break; + case math_node: + current = tex_aux_backtrack_over_math(current); + if (tex_aux_short_math(current)) { + tex_aux_adapt_short_math_penalty(current, short_inline_orphan_penalty_par, 0); + } + goto ALLDONE; + } current = node_prev(current); } diff --git a/source/luametatex/source/tex/texmath.c b/source/luametatex/source/tex/texmath.c index e2b4f9c39..923ffa56e 100644 --- a/source/luametatex/source/tex/texmath.c +++ b/source/luametatex/source/tex/texmath.c @@ -5010,6 +5010,8 @@ void tex_run_math_shift(void) if (post_short_inline_penalty_par != max_integer) { math_penalty(endmath) = post_short_inline_penalty_par; } + tex_add_math_option(beginmath, glue_option_short_math); + tex_add_math_option(endmath, glue_option_short_math); } cur_list.space_factor = default_space_factor; mathleft = cur_list.math_begin; diff --git a/source/luametatex/source/tex/texmlist.c b/source/luametatex/source/tex/texmlist.c index 1b9201172..d91ee50ae 100644 --- a/source/luametatex/source/tex/texmlist.c +++ b/source/luametatex/source/tex/texmlist.c @@ -1981,7 +1981,7 @@ void tex_run_mlist_to_hlist(halfword mlist, halfword penalties, halfword style, node_next(temp_head) = null; } if (penalties) { // && tex_in_main_math_style(style) - /*tex This makes no sense in display math not in script styles. */ + /*tex This makes no sense in display math nor in script styles. */ switch (style) { case text_style: case cramped_text_style: @@ -1992,8 +1992,8 @@ void tex_run_mlist_to_hlist(halfword mlist, halfword penalties, halfword style, halfword i = 1; while (h && i <= n) { if (tex_aux_is_math_penalty(h)) { - penalty_amount(h) += tex_get_specification_penalty(math_forward_penalties_par, i); - ++i; + penalty_amount(h) += tex_get_specification_penalty(math_forward_penalties_par, i++); + tex_add_penalty_option(h, penalty_option_math_forward); } h = node_next(h); } @@ -2006,8 +2006,8 @@ void tex_run_mlist_to_hlist(halfword mlist, halfword penalties, halfword style, halfword i = 1; while (t && i <= n) { if (tex_aux_is_math_penalty(t)) { - penalty_amount(t) += tex_get_specification_penalty(math_backward_penalties_par, i); - ++i; + penalty_amount(t) += tex_get_specification_penalty(math_backward_penalties_par, i++); + tex_add_penalty_option(t, penalty_option_math_backward); } t = node_prev(t); } @@ -7304,13 +7304,13 @@ static void tex_mlist_to_hlist_finalize_list(mliststate *state) recent_subtype = node_subtype(recent); /* todo: maybe also check the mainclass of the recent */ if ((recent_type != penalty_node) && ! (recent_type == simple_noad && tex_math_has_class_option(recent_subtype, omit_penalty_class_option))) { - halfword z = tex_new_penalty_node(post_penalty, math_post_penalty_subtype); - tex_attach_attribute_list_copy(z, current); - tex_couple_nodes(p, z); - p = z; + halfword penalty = tex_new_penalty_node(post_penalty, math_post_penalty_subtype); + tex_attach_attribute_list_copy(penalty, current); + tex_couple_nodes(p, penalty); + p = penalty; if (tracing_math_par >= 2) { tex_begin_diagnostic(); - tex_print_format("[math: post penalty, left %n, right %n, amount %i]", recent_subtype, current_subtype, penalty_amount(z)); + tex_print_format("[math: post penalty, left %n, right %n, amount %i]", recent_subtype, current_subtype, penalty_amount(penalty)); tex_end_diagnostic(); } } @@ -7330,11 +7330,11 @@ static void tex_mlist_to_hlist_finalize_list(mliststate *state) recent_plus_glyph = current_plus_glyph; // if (first && recent_left_slack) { if (p == temp_head && recent_left_slack) { - halfword k = tex_new_kern_node(-recent_left_slack, horizontal_math_kern_subtype); - halfword h = node_next(temp_head); - tex_attach_attribute_list_copy(k, p); - tex_couple_nodes(k, h); - node_next(temp_head) = k; + halfword kern = tex_new_kern_node(-recent_left_slack, horizontal_math_kern_subtype); + halfword head = node_next(temp_head); + tex_attach_attribute_list_copy(kern, p); + tex_couple_nodes(kern, head); + node_next(temp_head) = kern; if (tracing_math_par >= 2) { tex_begin_diagnostic(); tex_print_format("[math: nilling recent left slack %p]", recent_left_slack); @@ -7344,10 +7344,10 @@ static void tex_mlist_to_hlist_finalize_list(mliststate *state) recent = current; current = node_next(current); if (! current && recent_right_slack) { - halfword k = tex_new_kern_node(-recent_right_slack, horizontal_math_kern_subtype); - tex_attach_attribute_list_copy(k, p); - tex_couple_nodes(p, k); - p = k; + halfword kern = tex_new_kern_node(-recent_right_slack, horizontal_math_kern_subtype); + tex_attach_attribute_list_copy(kern, p); + tex_couple_nodes(p, kern); + p = kern; if (tracing_math_par >= 2) { tex_begin_diagnostic(); tex_print_format("[math: nilling recent right slack %p]", recent_right_slack); diff --git a/source/luametatex/source/tex/texnodes.h b/source/luametatex/source/tex/texnodes.h index 80ab40f03..3550e7345 100644 --- a/source/luametatex/source/tex/texnodes.h +++ b/source/luametatex/source/tex/texnodes.h @@ -422,8 +422,19 @@ typedef enum attribute_subtypes { with arguments. */ -# define penalty_node_size 3 -# define penalty_amount(a) vlink(a,2) +# define penalty_node_size 3 +# define penalty_amount(a) vlink(a,2) +# define penalty_options(a) vinfo(a,2) + +inline static void tex_add_penalty_option (halfword a, halfword r) { penalty_options(a) |= r; } +inline static void tex_remove_penalty_option (halfword a, halfword r) { penalty_options(a) &= ~(r | penalty_options(a)); } +inline static int tex_has_penalty_option (halfword a, halfword r) { return (penalty_options(a) & r) == r; } + +typedef enum penalty_option_codes { + penalty_option_normal = 0x0000, + penalty_option_math_forward = 0x0001, + penalty_option_math_backward = 0x0002, +} penalty_option_codes; typedef enum penalty_subtypes { user_penalty_subtype, @@ -522,6 +533,7 @@ typedef enum glue_option_codes { // glue_force_auto_break = 0x0001, // glue_originates_in_math = 0x0002, glue_option_no_auto_break = 0x0001, + glue_option_short_math = 0x0002, } glue_option_codes; typedef enum math_subtypes { diff --git a/source/luametatex/source/tex/texpackaging.c b/source/luametatex/source/tex/texpackaging.c index 83ace07fa..9f66232a7 100644 --- a/source/luametatex/source/tex/texpackaging.c +++ b/source/luametatex/source/tex/texpackaging.c @@ -2781,7 +2781,7 @@ static halfword tex_aux_depth_correction(halfword b, const line_break_properties p = tex_new_param_glue_node(line_skip_code, line_skip_glue); } else { p = tex_new_param_glue_node(baseline_skip_code, baseline_skip_glue); - glue_amount(p) = d; + glue_amount(p) = d; /* we keep the stretch and shrink */ } } return p; diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 34c07df79..736c98195 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2023.05.29 14:13} +\newcontextversion{2023.05.30 22:18} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index c37563b0c..b31c3e50c 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2023.05.29 14:13} +\edef\contextversion{2023.05.30 22:18} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index a3e2d79a8..b2edbb806 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2023.05.29 14:13} +\newcontextversion{2023.05.30 22:18} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index df5e61459..621dbf2fc 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2023.05.29 14:13} +\edef\contextversion{2023.05.30 22:18} %D Kind of special: diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index e18daff1b..ea03d6007 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index 02cdf5c3a..efa1d8a31 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 8267f0fa8..fd8513ae7 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2023.05.29 14:13} +\newcontextversion{2023.05.30 22:18} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 9712e28c1..261dd6e8d 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2023.05.29 14:13} +\immutable\edef\contextversion{2023.05.30 22:18} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt index d2b47ba27..15aae08f2 100644 --- a/tex/context/base/mkxl/toks-aux.lmt +++ b/tex/context/base/mkxl/toks-aux.lmt @@ -178,30 +178,35 @@ local function getthem(getter,post) return utilities.storage.allocate(table.swapped(codes,codes)) end +-- Not all of these make sense at the tex end (can't be set). + +tex.glyphoptioncodes = getthem(tex.getglyphoptionvalues, "glyphoptioncode") tex.discoptioncodes = getthem(tex.getdiscoptionvalues, "discoptioncode") +tex.glueoptioncodes = getthem(tex.getglueoptionvalues ) +tex.mathoptioncodes = getthem(tex.getmathoptionvalues ) +tex.penaltyoptioncodes = getthem(tex.getpenaltyoptionvalues ) tex.flagcodes = getthem(tex.getflagvalues, "flagcode" ) tex.frozenparcodes = getthem(tex.getfrozenparvalues, "frozenparcode") -tex.glyphoptioncodes = getthem(tex.getglyphoptionvalues, "glyphoptioncode") tex.groupcodes = getthem(tex.getgroupvalues, "groupcode") tex.hyphenationcodes = getthem(tex.gethyphenationvalues, "hyphenationcode") tex.mathcontrolcodes = getthem(tex.getmathcontrolvalues, "mathcontrolcode") ---.mathflattencodes = getthem(tex.getmathflattenvalues, "mathflattencode") -tex.noadoptioncodes = getthem(tex.getnoadoptionvalues ) -- only at lua end +tex.noadoptioncodes = getthem(tex.getnoadoptionvalues ) tex.normalizelinecodes = getthem(tex.getnormalizelinevalues, "normalizecode") -- we keep the short name tex.normalizeparcodes = getthem(tex.getnormalizeparvalues, "normalizeparcode") tex.automigrationcodes = getthem(tex.getautomigrationvalues, "automigrationcode") tex.parcontextcodes = getthem(tex.getparcontextvalues, "parcontextcode") -tex.textcontrolcodes = getthem(tex.gettextcontrolvalues ) -- only at lua end -tex.fitnesscodes = getthem(tex.getfitnessvalues ) -- only at lua end +tex.textcontrolcodes = getthem(tex.gettextcontrolvalues ) +tex.fitnesscodes = getthem(tex.getfitnessvalues ) tex.listanchorcodes = getthem(tex.getlistanchorvalues, "listanchorcode") tex.listsigncodes = getthem(tex.getlistsignvalues, "listsigncode") tex.classoptioncodes = getthem(tex.getmathclassoptionvalues, "classoptioncode") ----.alignmentcontextcodes = getthem(tex.getalignmentcontextvalues ) -- only at lua end -tex.specialmathclasscodes = getthem(tex.getspecialmathclassvalues ) -- idem -tex.directioncodes = getthem(tex.getdirectionvalues ) -- idem -tex.fillcodes = getthem(tex.getfillvalues ) -- idem -tex.mathparametercodes = getthem(tex.getmathparametervalues ) -- idem -tex.breakcodes = getthem(tex.getbreakcontextvalues ) -- idem +---.alignmentcontextcodes = getthem(tex.getalignmentcontextvalues ) +tex.specialmathclasscodes = getthem(tex.getspecialmathclassvalues ) +tex.directioncodes = getthem(tex.getdirectionvalues ) +tex.fillcodes = getthem(tex.getfillvalues ) +tex.mathparametercodes = getthem(tex.getmathparametervalues ) +tex.breakcodes = getthem(tex.getbreakcontextvalues ) function tex.stringtocodesbitmap(str,codes) local bitmap = 0 diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index b97a8d7d1..1309f38f1 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -1564,9 +1564,14 @@ end local ruledpenalty do - local p_cache_v = caches["vpenalty"] - local p_cache_h = caches["hpenalty"] - local p_cache_m = caches["mpenalty"] + local cachehash = { + ["MP=%s"] = caches["MP=%s"], + ["MP>%s"] = caches["MP>%s"], + ["MP<%s"] = caches["MP<%s"], + ["MP:%s"] = caches["MP:%s"], + ["VP:%s"] = caches["VP:%s"], + ["HP:%s"] = caches["HP:%s"], + } local raisepenalties = false @@ -1576,15 +1581,41 @@ local ruledpenalty do directives.register("visualizers.raisepenalties",function(v) raisepenalties = v end) + local getoptions = nuts.getoptions + + local mathforward = tex.penaltyoptioncodes.mathforward + local mathbackward = tex.penaltyoptioncodes.mathbackward + ruledpenalty = function(head,current,vertical,subtype) local penalty = getpenalty(current) local ismath = subtype == pre_penalty_code or subtype == post_penalty_code or subtype == true - local cache = (ismath and p_cache_m) or (vertical and p_cache_v) or p_cache_h - local info = cache[penalty] + local amount + if ismath then + local options = getoptions(current) + local forward = (options & mathforward) ~= 0 + local backward = (options & mathbackward) ~= 0 + if forward then + if backward then + amount = "MP=%s" + else + amount = "MP>%s" + end + elseif backward then + amount = "MP<%s" + else + amount = "MP:%s" + end + elseif vertical then + amount = "VP:%s" + else + amount = "HP:%s" + end + local cache = cachehash[amount] + local info = cache[penalty] if info then -- print("penalty hit") else - local amount = formatters["%s:%s"]((ismath and "MP") or (vertical and "VP") or "HP",penalty) + amount = formatters[amount](penalty) if ismath then info = sometext(amount,l_penalty,"trace:s") elseif penalty > 0 then @@ -1613,32 +1644,43 @@ end local ruledmath do local mathcodes = nodes.mathcodes - local m_cache = { - beginmath = caches["bmath"], - endmath = caches["emath"], - } local tags = { - beginmath = "B", - endmath = "E", + [true] = { + math = { "SM:?", caches["SM:?"] }, + beginmath = { "SM:B", caches["SM:B"] }, + endmath = { "SM:E", caches["SM:E"] }, + }, + [false] = { + math = { "M:?", caches["M:?"] }, + beginmath = { "M:B", caches["M:B"] }, + endmath = { "M:E", caches["M:E"] }, + }, } + local getoptions = nuts.getoptions + local shortmath = tex.mathoptioncodes.shortmath + ruledmath = function(head,current) - local what = getsubtype(current) - local tag = mathcodes[what] - local skip = getkern(current) + getwidth(current) -- surround - local info = m_cache[tag][skip] + local what = getsubtype(current) + local mtag = mathcodes[what] + local skip = getkern(current) + getwidth(current) -- surround + local short = (getoptions(current) & shortmath) ~= 0 + local htag = tags[short][mtag or "math"] or tags[false].math + local ttag = htag[1] + local cache = htag[2] + local info = cache[skip] if info then -- print("hit math") else - local text, width = sometext(formatters["M:%s"](tag and tags[tag] or what),usedfont,nil,"trace:dr") + local text, width = sometext(ttag,usedfont,nil,"trace:dr") local rule = new_rule(skip,-655360/fraction,2*655360/fraction) - local dist = tag == "beginmath" and width or skip + local dist = mtag == "beginmath" and width or skip setcolor(rule,"trace:dr") settransparency(rule,"trace:dr") setattr(rule,a_layer,l_math) info = new_hlist(setlink(new_glue(-skip),rule,new_glue(-dist),text)) setattr(info,a_layer,l_math) - m_cache[tag][skip] = info + cache[skip] = info end local saved = current head, current = insertnodeafter(head,current,copylist(info)) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index a0cde4d80..28412da6d 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2023-05-29 14:13 +-- merge date : 2023-05-30 22:18 do -- begin closure to overcome local limits and interference -- cgit v1.2.3