diff options
Diffstat (limited to 'tex')
24 files changed, 534 insertions, 53 deletions
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 Binary files differindex dbef85fbf..e12289f4f 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex ecb56dfb8..d77df12eb 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf 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 |