From b155eafa1e2d73692eed08ecabeb5ad589ac11dc Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 15 Apr 2022 20:34:40 +0200 Subject: 2022-04-15 20:15:00 --- .../manuals/luametatex/luametatex-nodes.tex | 26 +-- .../general/manuals/ontarget/ontarget-math.tex | 7 +- metapost/context/base/mpiv/mp-tool.mpiv | 12 +- metapost/context/base/mpxl/mp-cont.mpxl | 11 ++ metapost/context/base/mpxl/mp-tool.mpxl | 29 +++- 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/font-otc.lua | 3 + tex/context/base/mkiv/status-files.pdf | Bin 24635 -> 24625 bytes tex/context/base/mkiv/status-lua.pdf | Bin 257022 -> 257116 bytes tex/context/base/mkxl/cont-new.mkxl | 2 +- tex/context/base/mkxl/context.mkxl | 3 +- tex/context/base/mkxl/font-imp-digits.lmt | 62 ++++++++ tex/context/base/mkxl/font-lib.mklx | 2 +- tex/context/base/mkxl/font-pre.mkxl | 1 + tex/context/base/mkxl/math-frc.mkxl | 6 - tex/context/base/mkxl/math-ini.mkxl | 3 + tex/context/base/mkxl/math-rad.mklx | 14 +- tex/context/base/mkxl/mlib-int.lmt | 8 + tex/context/base/mkxl/mlib-lmp.lmt | 13 +- tex/context/base/mkxl/pack-rul.mkxl | 10 +- tex/context/base/mkxl/supp-box.mkxl | 52 +++--- tex/context/base/mkxl/task-ini.lmt | 4 +- tex/context/base/mkxl/typo-ada.lmt | 107 +++++++++++++ tex/context/base/mkxl/typo-ada.mkxl | 175 +++++++++++++++++++++ tex/context/modules/mkxl/m-json.mkxl | 112 +++++++++++++ tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 29 files changed, 594 insertions(+), 78 deletions(-) create mode 100644 tex/context/base/mkxl/font-imp-digits.lmt create mode 100644 tex/context/base/mkxl/typo-ada.lmt create mode 100644 tex/context/base/mkxl/typo-ada.mkxl create mode 100644 tex/context/modules/mkxl/m-json.mkxl diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-nodes.tex b/doc/context/sources/general/manuals/luametatex/luametatex-nodes.tex index 7b2374347..f575700de 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-nodes.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-nodes.tex @@ -319,7 +319,7 @@ The glue fields only kick in when the \type {surround} fields is zero. Skips are about the only type of data objects in traditional \TEX\ that are not a simple value. They are inserted when \TEX\ sees a space in the text flow but also by \prm {hskip} and \prm {vskip}. The structure that represents the glue -components of a skip internally is called a \nod {glue_spec}. In \LUAMETATEX\ we +components of a skip internally is called a \nod {gluespec}. In \LUAMETATEX\ we don't use the spec itself but just its values. A glue node has the fields: \showfields {glue}. @@ -350,7 +350,7 @@ rounded. \stopsubsection -\startsubsection[title={\nod {glue_spec} nodes}] +\startsubsection[title={\nod {gluespec} nodes}] \topicindex {nodes+glue} \topicindex {gluespec} @@ -361,7 +361,7 @@ is not seen in node lists. For instance the state of expression scanning (\type nodes. A glue, which has five components, is stored in a node as well, so, where most registers store just a number, a skip register (of internal quantity) uses a pointer to a glue spec node. It has similar fields as glue nodes: \showfields -{glue_spec}, which is not surprising because in the past (and other engines than +{gluespec}, which is not surprising because in the past (and other engines than \LUATEX) a glue node also has its values stored in a glue spec. This has some advantages because often the values are the same, so for instance spacing related skips were not resolved immediately but pointed to the current value of a space @@ -610,8 +610,8 @@ into a single node type with separate subtypes for differentiation: \showfields {noad}. Many object fields in math mode are either simple characters in a specific family -or math lists or node lists: \type {math_char}, \type {math_text_char}, {sub_box} -and \type {sub_mlist} and \type {delimiter}. These are endpoints and therefore the +or math lists or node lists: \type {mathchar}, \type {mathtextchar}, {subbox} +and \type {submlist} and \type {delimiter}. These are endpoints and therefore the \type {next} and \type {prev} fields of these these subnodes are unused. Some of the more elaborate noads have an option field. The values in this bitset @@ -637,10 +637,10 @@ are common: \stopsubsubsection -\startsubsubsection[title={\nod {math_char} and \nod {math_text_char} subnodes}] +\startsubsubsection[title={\nod {mathchar} and \nod {mathtextchar} subnodes}] These are the most common ones, as they represent characters, and they both have -the same fields: \showfields {math_char}. +the same fields: \showfields {mathchar}. \starttabulate[|l|l|p|] \DB field \BC type \BC explanation \NC \NR @@ -651,20 +651,20 @@ the same fields: \showfields {math_char}. \LL \stoptabulate -The \nod {math_char} is the simplest subnode field, it contains the character and +The \nod {mathchar} is the simplest subnode field, it contains the character and family for a single glyph object. The family eventually resolves on a reference -to a font. The \nod {math_text_char} is a special case that you will not normally +to a font. The \nod {mathtextchar} is a special case that you will not normally encounter, it arises temporarily during math list conversion (its sole function is to suppress a following italic correction). \stopsubsubsection -\startsubsubsection[title={\nod {sub_box} and \nod {sub_mlist} subnodes}] +\startsubsubsection[title={\nod {subbox} and \nod {submlist} subnodes}] -These two subnode types are used for subsidiary list items. For \nod {sub_box}, -the \type {list} points to a \quote {normal} vbox or hbox. For \nod {sub_mlist}, +These two subnode types are used for subsidiary list items. For \nod {subbox}, +the \type {list} points to a \quote {normal} vbox or hbox. For \nod {submlist}, the \type {list} points to a math list that is yet to be converted. Their fields -are: \showfields {sub_box}. +are: \showfields {subbox}. \starttabulate[|l|l|p|] \DB field \BC type \BC explanation \NC \NR diff --git a/doc/context/sources/general/manuals/ontarget/ontarget-math.tex b/doc/context/sources/general/manuals/ontarget/ontarget-math.tex index a64bb049c..50e5dff5f 100644 --- a/doc/context/sources/general/manuals/ontarget/ontarget-math.tex +++ b/doc/context/sources/general/manuals/ontarget/ontarget-math.tex @@ -635,6 +635,8 @@ at all, while the second has this setup: \setupmathematics[threshold=medium] \stopbuffer +\typebuffer + That setting set the threshold to \typ {4em plus 0.75em minus 0.50em} and when the formula size exceeds the four quads the line break code will use the real formula width but with the given stretch and shrink. Eventually the calculated @@ -1099,8 +1101,9 @@ specific classes at the edges. These options are a bitset and \type {1} means \scale[width=\textwidth]{\getbuffer} \stoplinecorrection -Because this overall niling is not granular enough a while later we introduced a -way to set this per class, as is demonstrated in the following example. +Because this overall removal of slack is not granular enough a while later we +introduced a way to set this per class, as is demonstrated in the following +example. \startbuffer \def\TestSlack#1% diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index f41811413..6c02323c3 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -3754,13 +3754,15 @@ numeric mfun_dash_on, mfun_dash_off ; primarydef p withdashes len = hide ( - save l, t, n, m ; pair t ; + save l, t, n, m, don, doff; pair t ; l := arclength p ; - t := paired(len) ; + t := paired (len) ; m := xpart t + ypart t ; - n := l / (l div m) / m ; - mfun_dash_on := n * xpart t ; - mfun_dash_off := n * ypart t ; + n := (l if not cycle p : - xpart t fi) div m ; + (n if not cycle p : + 1 fi) * don + n * doff = l ; + don*(ypart t) = doff*(xpart t) ; + mfun_dash_on := don ; + mfun_dash_off := doff ; ) p dashed dashpattern (on mfun_dash_on off mfun_dash_off) enddef ; diff --git a/metapost/context/base/mpxl/mp-cont.mpxl b/metapost/context/base/mpxl/mp-cont.mpxl index a89265224..d08a24272 100644 --- a/metapost/context/base/mpxl/mp-cont.mpxl +++ b/metapost/context/base/mpxl/mp-cont.mpxl @@ -199,3 +199,14 @@ immutable % permanent InnerMarginDistance, OuterEdgeWidth, InnerEdgeWidth, OuterEdgeDistance, InnerEdgeDistance, OuterSpaceWidth, InnerSpaceWidth, OuterMargin, InnerMargin, OuterEdge, InnerEdge ; + +% see typo-ada.* + +newscriptindex mfid_AdaptiveWidth ; mfid_AdaptiveWidth := scriptindex "AdaptiveWidth" ; vardef AdaptiveWidth = runscript mfid_AdaptiveWidth enddef ; +newscriptindex mfid_AdaptiveHeight ; mfid_AdaptiveHeight := scriptindex "AdaptiveHeight" ; vardef AdaptiveHeight = runscript mfid_AdaptiveHeight enddef ; +newscriptindex mfid_AdaptiveDepth ; mfid_AdaptiveDepth := scriptindex "AdaptiveDepth" ; vardef AdaptiveDepth = runscript mfid_AdaptiveDepth enddef ; +newscriptindex mfid_AdaptiveThickness ; mfid_AdaptiveThickness := scriptindex "AdaptiveThickness" ; vardef AdaptiveThickness = runscript mfid_AdaptiveThickness enddef ; +newscriptindex mfid_AdaptiveColor ; mfid_AdaptiveColor := scriptindex "AdaptiveColor" ; vardef AdaptiveColor = runscript mfid_AdaptiveColor enddef ; + +immutable % permanent + AdaptiveWidth, AdaptiveHeight, AdaptiveDepth, AdaptiveThickness, AdaptiveColor ; diff --git a/metapost/context/base/mpxl/mp-tool.mpxl b/metapost/context/base/mpxl/mp-tool.mpxl index d99439c5b..749f3d657 100644 --- a/metapost/context/base/mpxl/mp-tool.mpxl +++ b/metapost/context/base/mpxl/mp-tool.mpxl @@ -3932,15 +3932,30 @@ permanent hatched ; numeric mfun_dash_on, mfun_dash_off ; +% primarydef p withdashes len = +% hide ( +% save l, t, n, m ; pair t ; +% l := arclength p ; +% t := paired(len) ; +% m := xpart t + ypart t ; +% n := l / (l div m) / m ; +% mfun_dash_on := n * xpart t ; +% mfun_dash_off := n * ypart t ; +% ) +% p dashed dashpattern (on mfun_dash_on off mfun_dash_off) +% enddef ; + primarydef p withdashes len = hide ( - save l, t, n, m ; pair t ; + save l, t, n, m, don, doff; pair t ; l := arclength p ; - t := paired(len) ; + t := paired (len) ; m := xpart t + ypart t ; - n := l / (l div m) / m ; - mfun_dash_on := n * xpart t ; - mfun_dash_off := n * ypart t ; + n := (l if not cycle p : - xpart t fi) div m ; + (n if not cycle p : + 1 fi) * don + n * doff = l ; + don*(ypart t) = doff*(xpart t) ; + mfun_dash_on := don ; + mfun_dash_off := doff ; ) p dashed dashpattern (on mfun_dash_on off mfun_dash_off) enddef ; @@ -3952,6 +3967,10 @@ permanent withdashes ; path mfun_b ; pair mfun_k ; +tertiarydef p sortedintersectiontimes q = + sortedpath (p intersectiontimeslist q) +enddef ; + tertiarydef p intersectionpath q = begingroup ; save mfun_b ; path mfun_b ; mfun_b := sortedpath (p intersectiontimeslist q) ; diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 6a834d8e7..c4a402aba 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{2022.04.11 19:20} +\newcontextversion{2022.04.15 20:13} %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 6b362dab4..5855fa19f 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{2022.04.11 19:20} +\edef\contextversion{2022.04.15 20:13} %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 ec2d04ae7..da58655a3 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{2022.04.11 19:20} +\newcontextversion{2022.04.15 20:13} %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 03a5382f6..70f35d7d6 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{2022.04.11 19:20} +\edef\contextversion{2022.04.15 20:13} %D Kind of special: diff --git a/tex/context/base/mkiv/font-otc.lua b/tex/context/base/mkiv/font-otc.lua index 342541f12..943bb7e38 100644 --- a/tex/context/base/mkiv/font-otc.lua +++ b/tex/context/base/mkiv/font-otc.lua @@ -226,6 +226,9 @@ local function addfeature(data,feature,specifications,prepareonly) local stepkey = coverup.stepkey local register = coverup.register + -- todo: directly pass a coverage i.e. for privates that later will be + -- set + local function prepare_substitution(list,featuretype,nocheck) local coverage = { } local cover = coveractions[featuretype] diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index dbef85fbf..e12289f4f 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 ecb56dfb8..d77df12eb 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 0619285e5..0b9cb38b8 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{2022.04.11 19:20} +\newcontextversion{2022.04.15 20:13} %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 fc1997c33..9ae6ef38f 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{2022.04.11 19:20} +\immutable\edef\contextversion{2022.04.15 20:13} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -391,6 +391,7 @@ \loadmkxlfile{typo-par} % par builders (uses fonts) %loadmkxlfile{typo-lbx} \loadmkxlfile{typo-adj} +\loadmkxlfile{typo-ada} \loadmkxlfile{tabl-com} %loadmarkfile{tabl-pln} diff --git a/tex/context/base/mkxl/font-imp-digits.lmt b/tex/context/base/mkxl/font-imp-digits.lmt new file mode 100644 index 000000000..b350b7745 --- /dev/null +++ b/tex/context/base/mkxl/font-imp-digits.lmt @@ -0,0 +1,62 @@ +if not modules then modules = { } end modules ['font-imp-digits'] = { + version = 1.001, + comment = "companion to font-ini.mkiv", + author = "Hans Hagen, PRAGMA ADE", + copyright = "ConTeXt Development Team", + license = "see context related readme files" +} + +if not context then return end + +local equaldigits = { } + +-- for i=48,57 do +-- equaldigits[i] = fonts.helpers.newprivateslot(tonumber(i)..".equaldigits") +-- end + +local function initialize(tfmdata,value) + if value then + local characters = tfmdata.characters + local wd, ht, dp = 0, 0, 0 + for i=48,57 do + if not equaldigits[i] then + equaldigits[i] = fonts.helpers.newprivateslot(tonumber(i)..".equaldigits") + end + local c = characters[i] + local w = c.width or 0 + local h = c.height or 0 + local d = c.depth or 0 + if w > wd then wd = w end + if h > ht then ht = h end + if d > dp then dp = d end + end + for i=48,57 do + -- fonts.helpers.addprivate(tfmdata,tonumber(i)..".equaldigits") + local u = equaldigits[i] + local c = characters[i] + characters[u] = table.setmetatableindex( { + height = ht, + depth = dp, + width = wd, + xoffset = (wd - (c.width or 0)) / 2, + }, c) + end + end +end + +fonts.handlers.otf.features.register { + name = "equaldigits", + description = "equaldigits", + manipulators = { + base = initialize, + node = initialize, + } +} + +fonts.handlers.otf.addfeature { + -- name = "tnum", -- let's not waste that one + name = "tabledigits", + type = "substitution", + nocheck = true, + data = equaldigits, +} diff --git a/tex/context/base/mkxl/font-lib.mklx b/tex/context/base/mkxl/font-lib.mklx index 485ed1041..953ff06fb 100644 --- a/tex/context/base/mkxl/font-lib.mklx +++ b/tex/context/base/mkxl/font-lib.mklx @@ -118,10 +118,10 @@ \registerctxluafile{font-imp-combining}{} \registerctxluafile{font-imp-scripts}{autosuffix} \registerctxluafile{font-imp-sanitize}{autosuffix} % fixes for indic fonts +\registerctxluafile{font-imp-digits}{autosuffix} \registerctxluafile{font-imp-tracing}{autosuffix} % comes last! - \registerctxluafile{font-fbk}{autosuffix} \registerctxluafile{font-aux}{} diff --git a/tex/context/base/mkxl/font-pre.mkxl b/tex/context/base/mkxl/font-pre.mkxl index 60351ff53..d77869e27 100644 --- a/tex/context/base/mkxl/font-pre.mkxl +++ b/tex/context/base/mkxl/font-pre.mkxl @@ -514,6 +514,7 @@ \definefontfeature[uppercasing][uppercasing=yes] \definefontfeature[lowercasing][lowercasing=yes] \definefontfeature[camelcasing][camelcasing=yes] +\definefontfeature[tabledigits][tabledigits=yes,tnum=yes] %D Neat: diff --git a/tex/context/base/mkxl/math-frc.mkxl b/tex/context/base/mkxl/math-frc.mkxl index ab43299e0..4a912aace 100644 --- a/tex/context/base/mkxl/math-frc.mkxl +++ b/tex/context/base/mkxl/math-frc.mkxl @@ -15,12 +15,6 @@ \unprotect -%D I need to check it all again as there was a bug in luatex with dimensions that could -%D resulted in side effects that made me mess with spacing. - -\permanent\protected\def\topstrut{\srule\s!width\zeropoint\s!height\strutht \s!depth\zeropoint\relax} -\permanent\protected\def\botstrut{\srule\s!width\zeropoint\s!height\zeropoint\s!depth\strutdp \relax} - %D This module is reimplemented in \MKIV\ style. \registerctxluafile{math-frc}{autosuffix} diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index a7ec2abba..f63827906 100644 --- a/tex/context/base/mkxl/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -1412,6 +1412,9 @@ \permanent\protected\def\mathdepthstrut {\math_strut_depth} \popoverloadmode +\permanent\protected\def\topstrut{\srule\s!width\zeropoint\s!height\strutht \s!depth\zeropoint\relax} +\permanent\protected\def\botstrut{\srule\s!width\zeropoint\s!height\zeropoint\s!depth\strutdp \relax} + %D We could have a arg variant \unknown\ but not now. \permanent\protected\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits} diff --git a/tex/context/base/mkxl/math-rad.mklx b/tex/context/base/mkxl/math-rad.mklx index de8c2e9a6..ddd6a0cbb 100644 --- a/tex/context/base/mkxl/math-rad.mklx +++ b/tex/context/base/mkxl/math-rad.mklx @@ -90,6 +90,7 @@ \setupmathradical [\c!alternative=\v!normal, \c!mpoffset=.25\exheight, + \c!strut=\v!height, \c!source=\zerocount] \appendtoks @@ -101,6 +102,14 @@ \setmathignore\Umathradicaldegreebefore\plusone +\installcorenamespace{mathwhateverstrut} + +\defcsname\??mathwhateverstrut\v!height\endcsname{\mathheightstrut} +\defcsname\??mathwhateverstrut\v!depth \endcsname{\mathdepthstrut} +\defcsname\??mathwhateverstrut\v!math \endcsname{\mathstrut} +\defcsname\??mathwhateverstrut\v!yes \endcsname{\strut} +%letcsname\??mathwhateverstrut\v!no \endcsname\relax + \tolerant\protected\def\math_radical_handle#tag#*[#settings]#*[#degree]#:#body% {\begingroup \edef\currentmathradical{#tag}% @@ -113,7 +122,10 @@ \ifempty\currentmathradicaldegree \let\currentmathradicaldegree\m_math_no_degree \fi - \math_radical_alternative{#body}% + \math_radical_alternative{% + \begincsname\??mathwhateverstrut\mathradicalparameter\c!strut\endcsname + #body% + }% \endgroup} \def\m_math_no_degree{{}} diff --git a/tex/context/base/mkxl/mlib-int.lmt b/tex/context/base/mkxl/mlib-int.lmt index e294a4fe5..ae883b1e8 100644 --- a/tex/context/base/mkxl/mlib-int.lmt +++ b/tex/context/base/mkxl/mlib-int.lmt @@ -168,3 +168,11 @@ registerdirect("InPageBody", in_body_page ) -- registerdirect("LayoutHasChanged", layout_has_changed) registerdirect("defaultcolormodel", defaultcolormodel) + +-- see typo-ada.* + +registerdirect("AdaptiveWidth", function() return getdimen("d_adaptive_width") * factor end) +registerdirect("AdaptiveHeight", function() return getdimen("d_adaptive_height") * factor end) +registerdirect("AdaptiveDepth", function() return getdimen("d_adaptive_depth") * factor end) +registerdirect("AdaptiveThickness", function() return getdimen("d_adaptive_line") * factor end) +registerdirect("AdaptiveColor", function() return getmacro("m_adaptive_color") end) diff --git a/tex/context/base/mkxl/mlib-lmp.lmt b/tex/context/base/mkxl/mlib-lmp.lmt index b895d9ffd..61346bc73 100644 --- a/tex/context/base/mkxl/mlib-lmp.lmt +++ b/tex/context/base/mkxl/mlib-lmp.lmt @@ -10,7 +10,7 @@ if not modules then modules = { } end modules ['mlib-lmp'] = { local type, tonumber, tostring = type, tonumber, tostring local find, match = string.find, string.match -local insert, remove = table.insert, table.remove +local insert, remove, sort = table.insert, table.remove, table.sort local aux = mp.aux local mpnumeric = aux.numeric @@ -61,11 +61,10 @@ do local function s(a,b) local aa = a[1] local bb = b[1] - if aa ~= bb then - return aa < bb + if aa == bb then + aa = a[2] + bb = b[2] end - aa = a[2] - bb = b[2] return aa < bb end @@ -75,7 +74,7 @@ do local pi = p[i] p[i] = { pi[1], pi[2] } end - table.sort(p,s) + sort(p,s) injectpath(p) end) @@ -85,7 +84,7 @@ do local n = 0 local xx = nil local yy = nil - table.sort(p,s) + sort(p,s) for i=1,#p do local pi = p[i] local x = pi[1] diff --git a/tex/context/base/mkxl/pack-rul.mkxl b/tex/context/base/mkxl/pack-rul.mkxl index 96872647a..cce05e985 100644 --- a/tex/context/base/mkxl/pack-rul.mkxl +++ b/tex/context/base/mkxl/pack-rul.mkxl @@ -430,11 +430,11 @@ %mutable \edef\overlaycorner {\framedparameter\c!backgroundcorner} %mutable \edef\overlayradius {\framedparameter\c!backgroundradius} -\permanent\def\usedoverlaywidth {\dimexpr\d_overlay_width \relax} -\permanent\def\usedoverlayheight {\dimexpr\d_overlay_height \relax} -\permanent\def\usedoverlaydepth {\dimexpr\d_overlay_depth \relax} -\permanent\def\usedoverlayoffset {\dimexpr\d_overlay_offset \relax} -\permanent\def\usedoverlaylinewidth{\dimexpr\d_overlay_linewidth\relax} +\aliased\let\usedoverlaywidth \d_overlay_width +\aliased\let\usedoverlayheight \d_overlay_height +\aliased\let\usedoverlaydepth \d_overlay_depth +\aliased\let\usedoverlayoffset \d_overlay_offset +\aliased\let\usedoverlaylinewidth\d_overlay_linewidth %D The next register is used to initialize overlays. diff --git a/tex/context/base/mkxl/supp-box.mkxl b/tex/context/base/mkxl/supp-box.mkxl index deb2699d7..ed5668ce3 100644 --- a/tex/context/base/mkxl/supp-box.mkxl +++ b/tex/context/base/mkxl/supp-box.mkxl @@ -1604,31 +1604,33 @@ % since in practice we also use this macro for % funny lineheights and border cases \setbox0=\box\rigidcolumnbox - \doloop - {\setbox\rigidcolumnbox=\copy0 - \setbox\scratchbox\hpack to \rigidhsize - {\dorecurse\rigidcolumns - {\setbox\scratchbox\vsplit\rigidcolumnbox to \scratchdimen - \dp\scratchbox\openstrutdepth - \setbox\scratchbox\vtop - \ifalignrigidcolumns to - \ifstretchrigidcolumns\vsize\else\scratchdimen\fi - \fi - {\unvbox\scratchbox}% - \wd\scratchbox\hsize - \box\scratchbox - \hfill}% - \hfillneg}% - \ifvoid\rigidcolumnbox\exitloop\else\advance\scratchdimen\lineheight\fi}% - \iftightrigidcolumns - \setbox\scratchbox\hpack{\raise\dp\scratchbox\box\scratchbox}% - \else - \advance\scratchdimen -\openstrutdepth - \setbox\scratchbox\hpack{\raise\scratchdimen\box\scratchbox}% - \dp\scratchbox\openstrutdepth - \ht\scratchbox\scratchdimen - \fi - \box\scratchbox}% + \ifvoid0\else + \doloop + {\setbox\rigidcolumnbox=\copy0 + \setbox\scratchbox\hpack to \rigidhsize + {\dorecurse\rigidcolumns + {\setbox\scratchbox\vsplit\rigidcolumnbox to \scratchdimen + \dp\scratchbox\openstrutdepth + \setbox\scratchbox\vtop + \ifalignrigidcolumns to + \ifstretchrigidcolumns\vsize\else\scratchdimen\fi + \fi + {\unvbox\scratchbox}% + \wd\scratchbox\hsize + \box\scratchbox + \hfill}% + \hfillneg}% + \ifvoid\rigidcolumnbox\exitloop\else\advance\scratchdimen\lineheight\fi}% + \iftightrigidcolumns + \setbox\scratchbox\hpack{\raise\dp\scratchbox\box\scratchbox}% + \else + \advance\scratchdimen -\openstrutdepth + \setbox\scratchbox\hpack{\raise\scratchdimen\box\scratchbox}% + \dp\scratchbox\openstrutdepth + \ht\scratchbox\scratchdimen + \fi + \box\scratchbox + \fi}% \fi} %D \macros diff --git a/tex/context/base/mkxl/task-ini.lmt b/tex/context/base/mkxl/task-ini.lmt index eda40d356..9e06dac99 100644 --- a/tex/context/base/mkxl/task-ini.lmt +++ b/tex/context/base/mkxl/task-ini.lmt @@ -134,8 +134,9 @@ appendaction("contributers", "normalizers", "nodes.handlers.flattenline", appendaction("contributers", "normalizers", "nodes.handlers.textbackgrounds", nil, "nut", "disabled" ) appendaction("contributers", "normalizers", "nodes.handlers.wipe", nil, "nut", "disabled" ) -appendaction("adjusters", "normalizers", "nodes.handlers.adjusters", nil, "nut", "enabled") +appendaction("adjusters", "normalizers", "nodes.handlers.adjusters", nil, "nut", "enabled" ) +appendaction("vboxbuilders", "normalizers", "nodes.adaptive.handle", nil, "nut", "disabled" ) appendaction("vboxbuilders", "normalizers", "nodes.handlers.backgroundsvbox", nil, "nut", "disabled" ) ------------("vboxbuilders", "normalizers", "typesetters.margins.localhandler", nil, "nut", "disabled" ) appendaction("vboxbuilders", "normalizers", "builders.vspacing.vboxhandler", nil, "nut", "enabled" ) @@ -143,6 +144,7 @@ appendaction("vboxbuilders", "normalizers", "builders.profiling.vboxhandler", appendaction("vboxbuilders", "normalizers", "typesetters.checkers.handler", nil, "nut", "disabled" ) appendaction("vboxbuilders", "normalizers", "typesetters.synchronize.handler", nil, "nut", "disabled" ) +appendaction("mvlbuilders", "normalizers", "nodes.adaptive.handle", nil, "nut", "disabled" ) appendaction("mvlbuilders", "normalizers", "nodes.handlers.backgroundspage", nil, "nut", "disabled" ) appendaction("mvlbuilders", "normalizers", "typesetters.margins.globalhandler", nil, "nut", "disabled" ) appendaction("mvlbuilders", "normalizers", "nodes.handlers.migrate", nil, "nut", "disabled" ) diff --git a/tex/context/base/mkxl/typo-ada.lmt b/tex/context/base/mkxl/typo-ada.lmt new file mode 100644 index 000000000..813c3ada2 --- /dev/null +++ b/tex/context/base/mkxl/typo-ada.lmt @@ -0,0 +1,107 @@ +if not modules then modules = { } end modules ['typo-adj'] = { + version = 1.001, + optimize = true, + comment = "companion to typo-adj.mkxl", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local setdimen = tex.setdimen +local setcount = tex.setcount +local setmacro = tokens.setters.macro +local expandmacro = token.expandmacro + +local nuts = nodes.nuts +local getwhd = nuts.getwhd +local getattr = nuts.getattr +local getwidth = nuts.getwidth +local setlist = nuts.setlist +local setlink = nuts.setlink +local setstate = nuts.setstate + +local takebox = nuts.takebox + +local new_kern = nuts.pool.kern + +local traverselist = node.direct.traverselist +local traverseleader = node.direct.traverseleader + +local a_adaptive = attributes.private("adaptive") + +local registervalue = attributes.registervalue +local getvalue = attributes.getvalue +local hasvalues = attributes.hasvalues +local texsetattribute = tex.setattribute + +local adaptive = nodes.adaptive or { } +nodes.adaptive = adaptive +local enabled = false + +local enableaction = nodes.tasks.enableaction + +function adaptive.set(settings) + if not enabled then + enableaction("vboxbuilders","nodes.adaptive.handle") + enabled = true + end + texsetattribute(a_adaptive,registervalue(a_adaptive,settings)) +end + +local function setadaptive(w,h,d,l,c) + setdimen("d_adaptive_width",w) + setdimen("d_adaptive_height",h) + setdimen("d_adaptive_depth",d) + setdimen("d_adaptive_line",l) + setmacro("m_adaptive_color",c) +end + +local methods = { + -- overlay + [1] = function(settings,hlist,list) + local setups = settings.setups + if setups and setups ~= "" then + local w, h, d = getwhd(hlist) + setadaptive(w,h,d,settings.rulethickness,settings.color) + expandmacro("setup",true,setups) + local l = takebox("b_adaptive_box") + if l then + setlist(hlist, setlink(l,new_kern(-getwidth(l)),list)) + end + end + end +} + +function adaptive.handle(n) + if hasvalues(a_adaptive) then + for _, _, _, l in traverselist(n) do + for m, _, _, ll in traverseleader(l) do + local settings = getvalue(a_adaptive,getattr(m,a_adaptive)) + if settings then + setstate(m,0) + local action = methods[settings.method or 1] + if action then + action(settings,m,ll) + end + end + end + end + end + return n +end + +interfaces.implement { + name = "setadaptive", + actions = adaptive.set, + arguments = { + { + { "setups", "string" }, + { "method", "integer" }, + { "mp", "string" }, + { "color", "string" }, + { "rulethickness", "dimension" }, + } + } +} + +nodes.tasks.prependaction("vboxbuilders", "normalizers", "nodes.adaptive.handle", nil, "nut", "disabled") diff --git a/tex/context/base/mkxl/typo-ada.mkxl b/tex/context/base/mkxl/typo-ada.mkxl new file mode 100644 index 000000000..6b7ce3902 --- /dev/null +++ b/tex/context/base/mkxl/typo-ada.mkxl @@ -0,0 +1,175 @@ +%D \module +%D [ file=typo-ada, +%D version=2022.04.04, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Adaptive, +%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. + +\writestatus{loading}{ConTeXt Typesetting Macros / Adaptive} + +\registerctxluafile{typo-ada}{autosuffix} + +% Musical timestamp: the postponed by COVID concert of Gazpacho in Zwolle NL: a joy +% to see dedicated and talented musicians perform their work in perfection and as a +% well balanced and equiped team. + +\unprotect + +\newdimen\d_adaptive_width +\newdimen\d_adaptive_height +\newdimen\d_adaptive_depth +\newdimen\d_adaptive_line + +\mutable\let\m_adaptive_color\empty + +\newbox\b_adaptive_box + +\aliased\let\usedadaptivewidth \d_adaptive_width +\aliased\let\usedadaptiveheight \d_adaptive_height +\aliased\let\usedadaptivedepth \d_adaptive_depth +\aliased\let\usedadaptivelinewidth\d_adaptive_linewidth +\aliased\let\usedadaptivebox \b_adaptive_box + +\definesystemattribute[adaptive][public] + +\installcorenamespace{adaptive} + +\installcommandhandler \??adaptive {adaptive} \??adaptive + +% \appendtoks +% % +% \to \everydefineadaptive + +\setupadaptive + [\c!foregroundstyle=, + \c!foregroundcolor=, + \c!color=gray, + \c!rulethickness=\linewidth, + \c!method=1, + \c!stretch=, + \c!shrink=, + %\c!strut=\v!no, + \c!margin=2\emwidth] + +\permanent\tolerant\protected\def\adaptivebox[#1]#*[#2]% + {\dontleavehmode + \begingroup + \ifhastok={#1}% + \let\currentadaptive\empty + \setupcurrentadaptive[#1]% + \else + \edef\currentadaptive{#1}% + \setupcurrentadaptive[#2]% + \fi + \edef\p_setups{\adaptiveparameter\c!setups}% + \dowithnextboxcontent + {\useadaptivestyleandcolor\c!foregroundstyle\c!foregroundcolor + \ifcstok{\adaptiveparameter\c!strut}\v!yes\strut\fi % for now + } + {\ifempty\p_setups + % there is no need for postprocessing + \else + \clf_setadaptive { + method \adaptiveparameter\c!method + setups {\p_setups}% + color {\adaptiveparameter\c!color}% + rulethickness \adaptiveparameter\c!rulethickness + }% + \fi + \scratchdimen\adaptiveparameter\c!margin\relax + \edef\p_stretch{\adaptiveparameter\c!stretch}% + \edef\p_shrink {\adaptiveparameter\c!shrink}% + \uleaders + \hbox + \s!spread \scratchdimen + \bgroup + \hss\box\nextbox\hss + \egroup + \hskip + \zeropoint + \s!plus \ifempty\p_stretch\scratchdimen\else\p_stretch\fi + \s!minus \ifempty\p_shrink \scratchdimen\else\p_shrink \fi + \endgroup}% + \hbox} + +%D Here is a test case, expect more: +%D +%D \starttyping +%D \startMPdefinitions +%D def TickTock = +%D interim linecap := squared; +%D save p ; path p ; p := fullsquare xysized(AdaptiveWidth,.9(AdaptiveHeight+AdaptiveDepth)) ; +%D fill p withcolor AdaptiveColor ; +%D draw bottomboundary (p enlarged (-AdaptiveThickness) ) +%D withdashes (3*AdaptiveThickness) +%D withpen pencircle scaled AdaptiveThickness +%D withcolor white ; +%D enddef ; +%D \stopMPdefinitions +%D +%D \startsetups adaptive:test +%D \setbox\usedadaptivebox\hbox to \usedadaptivewidth yoffset -.9\usedadaptivedepth \bgroup +%D \hss +%D \startMPcode +%D TickTock ; +%D \stopMPcode +%D \hss +%D \egroup +%D \stopsetups +%D +%D \definecolor[adaptive:tick][.25(blue,green)] +%D \definecolor[adaptive:tock][.75(blue,green)] +%D +%D \defineadaptive +%D [tick] +%D [setups=adaptive:test, +%D color=adaptive:tick, +%D foregroundcolor=white, +%D foregroundstyle=\infofont, +%D strut=yes] +%D +%D \defineadaptive +%D [tock] +%D [tick] +%D [color=adaptive:tock] +%D +%D \dorecurse{5}{ +%D \dostepwiserecurse{1}{150}{1}{% +%D this~#1.##1 is~#1.##1 test~#1.##1 +%D \ifodd##1\relax +%D \adaptivebox[tick]{\hss tick #1.##1\hss} +%D \else +%D \adaptivebox[tock]{\hss tock #1.##1\hss} +%D \fi +%D } +%D \blank +%D } +%D +%D \setupexternalfigures +%D [location={default,global}] +%D +%D \startsetups adaptive:test +%D \setbox\usedadaptivebox\hbox to \usedadaptivewidth yoffset -\usedadaptivedepth \bgroup +%D \externalfigure +%D [cow.pdf] +%D [width=\usedadaptivewidth, +%D height=\dimexpr\usedadaptiveheight+\usedadaptivedepth\relax]% +%D \egroup +%D \stopsetups +%D +%D \dorecurse{5}{ +%D \dostepwiserecurse{1}{150}{1}{% +%D this~#1.##1 is~#1.##1 test~#1.##1 +%D {\adaptivebox[strut=yes,setups=adaptive:test]{}} +%D } +%D \blank +%D } +%D \stoptyping + +\protect diff --git a/tex/context/modules/mkxl/m-json.mkxl b/tex/context/modules/mkxl/m-json.mkxl new file mode 100644 index 000000000..061a15ba0 --- /dev/null +++ b/tex/context/modules/mkxl/m-json.mkxl @@ -0,0 +1,112 @@ +%D \module +%D [ file=m-json, +%D version=2022.04.11, % 2012.08.03, +%D title=\CONTEXT\ Modules, +%D subtitle=Json, +%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. + +%D This module is a side effect of looking into json. Currently there are +%D only a few helpers: +%D +%D \starttyping +%D moduledata.json.tolua (str) +%D moduledata.json.tostring(val) +%D \stoptyping +%D +%D Nothing spectacular but maybe handy to have around. + +\startmodule [json] + +% check for: utilities.json + +\registerctxluafile{util-jsn}{} + +% \def\u#1#2#3#4{\cldcontext{utf.char(0x#1#2#3#4)}} + +\startluacode + + -- when we are at the lua end we can just use the table directly but + -- otherwise we can use accessors at the tex end and if needed some + -- special formatters + -- + -- we can actually map the json to xml and then use xml accessors + -- which has some benefits + + local tonumber = tonumber + local context = context + local gmatch = string.gmatch + + local loaded = { } + local current = nil + local json = utilities.json + + local function loadjsonfile(namespace,filename) + local data = loaded[namespace] + if not data then + local fullname = resolvers.findfile(filename) + if fullname and fullname ~= "" then + data = io.loaddata(fullname) + if data then + data = utilities.json.tolua(data) + end + end + if not data then + data = { } + end + loaded[namespace] = data + metapost.setparameterset(namespace,data) + end + current = data + return data + end + + local function jsonfield(namespace,name,default) + local data = loaded[namespace] or current + if current then + for s in gmatch(name,"[^%.]+") do + data = data[s] or data[tonumber(s) or 0] + if not data then + return + end + end + return data + end + end + + json.field = jsonfield + + function json.loaded(namespace) + return (namespace and loaded[namespace]) or current or { } + end + + interfaces.implement { + name = "loadjsonfile", + actions = loadjsonfile, + arguments = { "optional", "optional" }, + public = true, + protected = true, + } + + interfaces.implement { + name = "jsonfield", + actions = { jsonfield, context }, + arguments = "2 arguments", + public = true, + } + + interfaces.implement { + name = "jsonfielddefault", + actions = { jsonfield, context }, + arguments = "3 arguments", + public = true, + } + +\stopluacode + +\stopmodule diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 8449d0bc1..2feb254cc 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 : 2022-04-11 19:20 +-- merge date : 2022-04-15 20:13 do -- begin closure to overcome local limits and interference -- cgit v1.2.3