From ca9e3e4bd07d6d644818ffcfe746030923031afd Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sat, 27 May 2023 23:41:49 +0200 Subject: 2023-05-27 23:25:00 --- source/luametatex/source/tex/texcommands.h | 4 +- source/luametatex/source/tex/texrules.c | 8 +- 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 24659 -> 24658 bytes tex/context/base/mkiv/status-lua.pdf | Bin 270690 -> 270731 bytes tex/context/base/mkxl/cont-new.mkxl | 2 +- tex/context/base/mkxl/context.mkxl | 4 +- tex/context/base/mkxl/spac-brk.lmt | 235 +++++++++++++++++++++ tex/context/base/mkxl/spac-brk.mkxl | 43 ++++ tex/context/base/mkxl/toks-aux.lmt | 9 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 14 files changed, 298 insertions(+), 17 deletions(-) create mode 100644 tex/context/base/mkxl/spac-brk.lmt create mode 100644 tex/context/base/mkxl/spac-brk.mkxl diff --git a/source/luametatex/source/tex/texcommands.h b/source/luametatex/source/tex/texcommands.h index 372066049..04f8fb606 100644 --- a/source/luametatex/source/tex/texcommands.h +++ b/source/luametatex/source/tex/texcommands.h @@ -247,8 +247,8 @@ typedef enum tex_command_code { set_interaction_cmd, /*tex define level of interaction (|\batchmode|, etc.) */ /*tex Here ends the section that is part of the big switch. What follows are commands that are - intercepted when expanding tokens. The strint one came from a todo list and moved to a - maybe list. + intercepted when expanding tokens. The |string_cmd| came from a todo list and moved to a + maybe list and finally became obsolete. */ undefined_cs_cmd, /*tex initial state of most |eq_type| fields */ expand_after_cmd, /*tex special expansion (|\expandafter|) */ diff --git a/source/luametatex/source/tex/texrules.c b/source/luametatex/source/tex/texrules.c index 560ca73df..7d9adb7ef 100644 --- a/source/luametatex/source/tex/texrules.c +++ b/source/luametatex/source/tex/texrules.c @@ -236,7 +236,7 @@ void tex_aux_check_text_strut_rule(halfword rule, halfword style) halfword tex_get_rule_font(halfword n, halfword style) { - if (node_subtype(n) == virtual_rule_subtype) { + if (node_subtype(n) != virtual_rule_subtype) { halfword fnt = rule_strut_font(n); if (fnt >= rule_font_fam_offset) { halfword fam = fnt - rule_font_fam_offset; @@ -256,7 +256,7 @@ halfword tex_get_rule_font(halfword n, halfword style) halfword tex_get_rule_family(halfword n) { - if (node_subtype(n) == virtual_rule_subtype) { + if (node_subtype(n) != virtual_rule_subtype) { halfword fnt = rule_strut_font(n); if (fnt >= rule_font_fam_offset) { halfword fam = fnt - rule_font_fam_offset; @@ -270,7 +270,7 @@ halfword tex_get_rule_family(halfword n) void tex_set_rule_font(halfword n, halfword fnt) { - if (node_subtype(n) == virtual_rule_subtype) { + if (node_subtype(n) != virtual_rule_subtype) { if (fnt < 0 || fnt >= rule_font_fam_offset) { rule_strut_font(n) = 0; } else { @@ -281,7 +281,7 @@ void tex_set_rule_font(halfword n, halfword fnt) void tex_set_rule_family(halfword n, halfword fam) { - if (node_subtype(n) == virtual_rule_subtype) { + if (node_subtype(n) != virtual_rule_subtype) { if (fam < 0 || fam >= max_n_of_math_families) { rule_strut_font(n) = rule_font_fam_offset; } else { diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 35e9fb615..e2f277db9 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.27 12:11} +\newcontextversion{2023.05.27 23:23} %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 8737d7c70..459078b2f 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.27 12:11} +\edef\contextversion{2023.05.27 23:23} %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 596dd0299..b3ef836ce 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.27 12:11} +\newcontextversion{2023.05.27 23:23} %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 c5be65048..c564ee74c 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.27 12:11} +\edef\contextversion{2023.05.27 23:23} %D Kind of special: diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index dff0084d6..a3b95216b 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 3c16a859d..85a68d14d 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 fb9c31af8..81d56e507 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.27 12:11} +\newcontextversion{2023.05.27 23:23} %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 73864fbe6..74f8b3bfc 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.27 12:11} +\immutable\edef\contextversion{2023.05.27 23:23} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -448,6 +448,8 @@ \loadmklxfile{type-ini} \loadmkxlfile{type-set} +\loadmkxlfile{spac-brk} + \loadmkxlfile{scrp-ini} \loadmkxlfile{symb-emj} diff --git a/tex/context/base/mkxl/spac-brk.lmt b/tex/context/base/mkxl/spac-brk.lmt new file mode 100644 index 000000000..e534faa0e --- /dev/null +++ b/tex/context/base/mkxl/spac-brk.lmt @@ -0,0 +1,235 @@ +if not modules then modules = { } end modules ['spac-brk'] = { + version = 1.001, + comment = "companion to spac-brk.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local next, type, tonumber, tostring = next, type, tonumber, tostring + +local settings_to_array = utilities.parsers.settings_to_array +local settings_to_hash = utilities.parsers.settings_to_hash + +local nuts = nodes.nuts +local tonut = nodes.tonut + +local newrule = nuts.pool.virtualrule +local insertbefore = nuts.insertbefore +local insertafter = nuts.insertafter +local hpack_string = nuts.typesetters.tohpack +local getwidth = nuts.getwidth +local getid = nuts.getid +local getprev = nuts.getprev +local getnext = nuts.getnext +local setwhd = nuts.setwhd +local getlist = nuts.getlist +local setoffsets = nuts.setoffsets + +local setcolor = nodes.tracers.colors.set +local settransparency = nodes.tracers.transparencies.set + +local texgetnest = tex.getnest +local texgetcount = tex.getcount + +local nodecodes = nodes.nodecodes + +local penalty_code = nodecodes.penalty +local glue_code = nodecodes.glue +local disc_code = nodecodes.disc +local math_code = nodecodes.math + +local breakcodes = tex.breakcodes + +local registercallback = callback.register + +local c_tracinglousiness = tex.iscount("tracinglousiness") + +local alignments = { } +typesetters.alignments = alignments + +typesetters = typesetters or { } +local breakpoints = typesetters.breakpoints or { } +typesetters.breakpoints = breakpoints + +local width = 65536 / 2 +local height = 9 * 65536 +local depth = 3 * 65536 +local xoffset = 1 * 65536 +local yoffset = -3 * 65536 + +local serial = false +local usedfont = false +local nestlevel = false +local overload = false +local order = 0 + +local report = logs.reporter("linebreaks") + +local actions = { + [breakcodes.initialize] = function() + if texgetnest("ptr") == nestlevel then + usedfont = nodes.visualizers.getusedfont() + serial = false + order = order + 1 + end + end, + [breakcodes.start] = function(pass) + if texgetnest("ptr") == nestlevel then + if pass == 2 then + serial = { } + end + end + end, + [breakcodes.report] = function(pass,currentserial,previousserial,line,kind,class,demerits,breakpoint,short,glue) + if serial and breakpoint and texgetnest("ptr") == nestlevel then + local s = { + serial = currentserial, + demerits = demerits, + breakpoint = breakpoint, + } + serial[currentserial] = s + local found = overload and overload[currentserial] + if found then + report("pass %i, overloading serial %i.%i demerits from %i to %i",2,order,currentserial,demerits,found) + return found + end + end + return demerits + end, + [breakcodes.collect] = function() + if serial and texgetnest("ptr") == nestlevel and texgetcount(c_tracinglousiness) >= 1 then + for currentserial=1,#serial do + local data = serial[currentserial] + local breakpoint = data.breakpoint + local current = tonut(breakpoint) + while current do + local id = getid(current) + if id == penalty_code or id == glue_code or id == kern_code or id == math_code then + current = getprev(current) + else + break + end + end + if current then + local rule = newrule(width,height,depth,currentserial) + data.rule = rule + insertafter(current,current,rule) + end + end + end + end, + [breakcodes.wrapup] = function() + if serial and texgetnest("ptr") == nestlevel then + local n = #serial + local trace = texgetcount(c_tracinglousiness) + if trace >= 2 then + report("%i demerits in set %i",n,order) + end + for currentserial=1,n do + local data = serial[currentserial] + local demerits = data.demerits + if trace >= 1 then + local rule = data.rule + if rule then + local tag = tostring(order).."."..tostring(currentserial) + local text = hpack_string(tag,usedfont) + local size = getwidth(text) + setwhd(text,0,0,0) + setoffsets(text,-size-xoffset,yoffset) + insertafter(rule,rule,text) + end + end + serial[currentserial] = demerits + if trace >= 2 then + report("% 4i : %8i",currentserial,demerits) + end + end + overload = false + registercallback("show_break") + end + end, +} + +local function action(what,...) + local action = actions[what] + if action then + return action(...) + end +end + +local function show(str) + nestlevel = texgetnest("ptr") + if str and str ~= "" then + if type(str) == "table" then + overload = str + else + overload = settings_to_hash(str) + for k, v in next, overload do + overload[tonumber(k)] = tonumber(v) or -1 + end + end + else + overload = false + end + registercallback("show_break", action) +end + +local function last() + return serial or { } +end + +typesetters.breakpoints.show = show +typesetters.breakpoints.last = last + +-- interface + +local context = context +local scaninteger = tokens.scanners.integer + +local function feedback() + local l = last() + local n = #l + if n > 0 then + local t = { n } + local m = 1 + for i=1,#l do + m = m + 1 ; t[m] = i + m = m + 1 ; t[m] = l[i] + end + context("% t",t) + end +end + +interfaces.implement { + name = "lousiness", + public = true, + protected = true, + usage = "value", + actions = function(what) + if what == "value" then + feedback() + else + local n = scaninteger() + local t = { } + for i=1,n do + t[scaninteger()] = scaninteger() + end + show(t) + end + end, +} + +interfaces.implement { + name = "silliness", + public = true, + protected = true, + usage = "value", + actions = function(what) + if what == "value" then + feedback() + else + show { [scaninteger()] = 0 } + end + end, +} diff --git a/tex/context/base/mkxl/spac-brk.mkxl b/tex/context/base/mkxl/spac-brk.mkxl new file mode 100644 index 000000000..8926e1b4d --- /dev/null +++ b/tex/context/base/mkxl/spac-brk.mkxl @@ -0,0 +1,43 @@ +%D \module +%D [ file=spac-brk, +%D version=2023.05.23, +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Breaking lines, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\ifdefined\tracinglousiness \endinput \fi + +\writestatus{loading}{ConTeXt Spacing Macros / Breakpoints} + +\newcount\tracinglousiness + +\registerctxluafile{spac-brk}{} + +%D This is a very experimental feature and a by product of improving inline math +%D crossing lines. As it might evolve: use with care. + +% \setuplayout[width=8cm] +% \starttext +% \setupalign[verytolerant] +% \tracinglousiness1 +% % \tracinglousiness2 +% \samplefile{ward} \blank +% % \ctxlua{typesetters.breakpoints.show("11=0")} \samplefile{ward} \blank +% % \ctxlua{typesetters.breakpoints.show{ [11] = 0 }} \samplefile{ward} \blank +% \lousiness 1 11 0 \samplefile{ward} \blank +% \silliness 11 \samplefile{ward} \blank +% {\tt \the\lousiness} +% \stoptext + + +\unprotect + +% nothing hereyet + +\protect \endinput diff --git a/tex/context/base/mkxl/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt index d9adb1d67..d2b47ba27 100644 --- a/tex/context/base/mkxl/toks-aux.lmt +++ b/tex/context/base/mkxl/toks-aux.lmt @@ -197,10 +197,11 @@ tex.listanchorcodes = getthem(tex.getlistanchorvalues, "listanchorco 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 ) -- only at lua end -tex.directioncodes = getthem(tex.getdirectionvalues ) -- only at lua end (todo tex) -tex.fillcodes = getthem(tex.getfillvalues ) -- only at lua end (todo tex) -tex.mathparametercodes = getthem(tex.getmathparametervalues ) -- only at lua end (todo tex) +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 function tex.stringtocodesbitmap(str,codes) local bitmap = 0 diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 29ab7c585..3dfd09687 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-27 12:11 +-- merge date : 2023-05-27 23:23 do -- begin closure to overcome local limits and interference -- cgit v1.2.3