diff options
Diffstat (limited to 'tex/context/base/mkxl')
95 files changed, 6427 insertions, 2199 deletions
diff --git a/tex/context/base/mkxl/anch-pos.lmt b/tex/context/base/mkxl/anch-pos.lmt index 5a9ffaa3d..07e338cb6 100644 --- a/tex/context/base/mkxl/anch-pos.lmt +++ b/tex/context/base/mkxl/anch-pos.lmt @@ -62,6 +62,7 @@ local context = context local ctx_latelua = context.latelua local tex = tex +local texgetdimen = tex.getdimen local texgetcount = tex.getcount local texgetinteger = tex.getintegervalue or tex.getcount local texsetcount = tex.setcount @@ -1269,8 +1270,8 @@ do nofparagraphs = nofparagraphs + 1 texsetcount("global","c_anch_positions_paragraph",nofparagraphs) local name = f_p_tag(nofparagraphs) - local box = getbox("strutbox") - local w, h, d = getwhd(box) + local h = texgetdimen("strutht") + local d = texgetdimen("strutdp") -- local top = texgetnest("top","head") local nxt = top.next @@ -1428,8 +1429,8 @@ do public = true, protected = true, actions = function(name) - local box = getbox("strutbox") - local w, h, d = getwhd(box) + local h = texgetdimen("strutht") + local d = texgetdimen("strutdp") local spec = { p = true, c = column, @@ -1452,8 +1453,8 @@ do public = true, protected = true, actions = function(name,kind) - local box = getbox("strutbox") - local w, h, d = getwhd(box) + local h = texgetdimen("strutht") + local d = texgetdimen("strutdp") local spec = { k = kind, p = true, diff --git a/tex/context/base/mkxl/attr-ini.lmt b/tex/context/base/mkxl/attr-ini.lmt index 2a4805a01..059de8fd7 100644 --- a/tex/context/base/mkxl/attr-ini.lmt +++ b/tex/context/base/mkxl/attr-ini.lmt @@ -54,10 +54,12 @@ storage.register("attributes/list", list, "attributes.list") storage.register("attributes/values", values, "attributes.values") storage.register("attributes/counts", counts, "attributes.counts") -local report_attribute = logs.reporter("attributes") -local report_value = logs.reporter("attributes","values") +local report_attribute = logs.reporter("attributes") +local report_value = logs.reporter("attributes","values") -local trace_values = false +local trace_values = false + +local max_register_index = tex.magicconstants.max_attribute_register_index trackers.register("attributes.values", function(v) trace_values = v end) @@ -105,7 +107,7 @@ function attributes.public(name) -- at the lua end (hidden from user) local number = numbers[name] if not number then local last = sharedstorage.attributes_last_public - if last < 65535 then + if last < max_register_index then last = last + 1 sharedstorage.attributes_last_public = last else diff --git a/tex/context/base/mkxl/back-exp-imp-mth.lmt b/tex/context/base/mkxl/back-exp-imp-mth.lmt index 8751ca89d..a70ea8511 100644 --- a/tex/context/base/mkxl/back-exp-imp-mth.lmt +++ b/tex/context/base/mkxl/back-exp-imp-mth.lmt @@ -279,7 +279,13 @@ do -- todo: p.topfixed if t then -- mover - d[1].data[1].content = utfchar(t) + if true then -- we don't go here any more + local dd = d[1].data + if dd then + dd[1].content = utfchar(t) + end + end + -- di.data = { d[2], d[1] } end else @@ -299,7 +305,12 @@ do -- todo: p.bottomfixed if b then -- munder - d[2].data[1].content = utfchar(b) + if true then -- we don't go here any more + local dd = d[2].data + if dd then + dd[1].content = utfchar(b) + end + end end else -- can't happen @@ -322,8 +333,16 @@ do -- todo: p.bottomfixed if t and b then -- munderover - d[1].data[1].content = utfchar(t) - d[3].data[1].content = utfchar(b) + if true then -- we don't go here any more + local dd = d[1].data + if dd then + dd[1].content = utfchar(t) + end + local dd = d[3].data + if dd then + dd[1].content = utfchar(b) + end + end di.data = { d[2], d[3], d[1] } else -- can't happen diff --git a/tex/context/base/mkxl/colo-ini.mkxl b/tex/context/base/mkxl/colo-ini.mkxl index 21f1e1174..e9504e0eb 100644 --- a/tex/context/base/mkxl/colo-ini.mkxl +++ b/tex/context/base/mkxl/colo-ini.mkxl @@ -386,6 +386,16 @@ {\c_attr_color \c_colo_saved_attribute_color \c_attr_transparency\c_colo_saved_attribute_transparency} +%D Nasty: + +\permanent\def\usedcolorparameterattributes#1% + {\beginlocalcontrol\begingroup + \dousecolorparameter{#1}% + \normalexpanded{\endgroup\noexpand\endlocalcontrol + \noexpand\s!attr \colorattribute \the\c_attr_color + \noexpand\s!attr \colormodelattribute \the\c_attr_colormodel + \noexpand\s!attr \transparencyattribute \the\c_attr_transparency}} + %D In this documentation we will not go into too much details on palets. Curious %D users can find more information on this topic in \from[use of color]. %D diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 77ef89d5d..91c21c84d 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.01.21 20:10} +\newcontextversion{2022.03.12 11:24} %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 ca6e796c1..57fc8e155 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.01.21 20:10} +\immutable\edef\contextversion{2022.03.12 11:24} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -486,6 +486,7 @@ \loadmkxlfile{math-int} \loadmkxlfile{math-del} \loadmkxlfile{math-fen} +\loadmkxlfile{math-lop} \loadmklxfile{math-acc} \loadmklxfile{math-rad} \loadmkxlfile{math-inl} @@ -522,6 +523,7 @@ \loadmkxlfile{grph-pat} \loadmkxlfile{pack-box} +\loadmkxlfile{pack-mat} \loadmkxlfile{pack-bar} \loadmkxlfile{page-app} \loadmkxlfile{meta-fig} diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt index 2cb351880..6c4ca79cc 100644 --- a/tex/context/base/mkxl/driv-shp.lmt +++ b/tex/context/base/mkxl/driv-shp.lmt @@ -13,6 +13,7 @@ local setmetatableindex = table.setmetatableindex local formatters = string.formatters local concat = table.concat local keys = table.keys +local insert = table.insert local sortedhash = table.sortedhash local find = string.find local stripstring = string.strip @@ -620,8 +621,9 @@ end local dirstack = { } local anchors = { } ------ befores = setmetatableindex("table") ------ afters = setmetatableindex("table") +local befores = setmetatableindex("table") +local afters = setmetatableindex("table") +local stired = false local function reset_directions() dirstack = { } @@ -631,53 +633,55 @@ local function reset_anchors() anchors = { } end --- interfaces.implement { --- name = "registeranchorbox", --- arguments = { "integer", "integer", "box" }, --- actions = function(anchor,where,box) --- box = tonut(box) --- if where < 0 then --- table.insert(befores[anchor],box) --- else --- table.insert(afters[anchor],box) --- end --- end --- } +interfaces.implement { + name = "registeranchorbox", + public = true, + protected = true, + arguments = { "integer", "integer", "box" }, + actions = function(anchor,where,box) + box = tonut(box) + if where < 0 then + insert(befores[anchor],box) + else + insert(afters[anchor],box) + end + stored = true + end +} local hlist_out, vlist_out do local finalize = nodes.handlers.finalizelist - -- local takebox = nuts.takebox local flushnode = nuts.flushnode - -- local function flushstored(current,source,before) - -- local s = nil - -- if before then - -- s = rawget(befores,source) - -- else - -- s = rawget(afters,source) - -- end - -- if s then - -- for i=1,#s do - -- local si = s[i] - -- if si then - -- finalize(si) -- tricky: we might need to group - -- if getid(si) == vlist_code then - -- vlist_out(current,si) - -- else - -- hlist_out(current,si) - -- end - -- flushnode(si) - -- s[i] = false - -- end - -- end - -- if before then - -- rawset(befores,source,nil) - -- else - -- rawset(afters,source,nil) - -- end - -- end - -- end + local function flushstored(current,source,before) + local s = nil + if before then + s = rawget(befores,source) + else + s = rawget(afters,source) + end + if s then + for i=1,#s do + local si = s[i] + if si then + finalize(si) -- tricky: we might need to group + if getid(si) == vlist_code then + vlist_out(current,si) + else + hlist_out(current,si) + end + flushnode(si) + s[i] = false + end + end + if before then + rawset(befores,source,nil) + else + rawset(afters,source,nil) + end + end + end local function applyorientation(orientation,x,y,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) local ot = (orientation >> 0) & 0x0F @@ -1098,11 +1102,17 @@ local hlist_out, vlist_out do if usedorientation then pushorientation(usedorientation,pos_h,pos_v,pos_r) end + if source and stored then + flushstored(current,source,true) + end if id == vlist_code then vlist_out(current,list) else hlist_out(current,list) end + if source and stored then + flushstored(current,source,false) + end if usedorientation then poporientation(usedorientation,pos_h,pos_v,pos_r) end @@ -1136,19 +1146,19 @@ local hlist_out, vlist_out do end local total = height + depth if total > 0 then - local xoffset, yoffset, left, right = getoffsets(current) -- top bottom - if left ~= 0 then - pos_v = pos_v + left - total = total - left - end - if right ~= 0 then - depth = depth - right - total = total - right - end + local xoffset, yoffset, top, bottom = getoffsets(current) if pos_r == righttoleft_code then pos_h = pos_h - width xoffset = - xoffset end + if top ~= 0 then + -- height = height - top + total = total - top + end + if bottom ~= 0 then + depth = depth - bottom + total = total - bottom + end pos_v = pos_v - depth flushrule(current,pos_h + xoffset,pos_v + yoffset,pos_r,width,total,subtype) end @@ -1486,17 +1496,17 @@ local hlist_out, vlist_out do if usedorientation then pushorientation(usedorientation,pos_h,pos_v,pos_r) end - -- if source then - -- flushstored(current,source,true) - -- end + if source and stored then + flushstored(current,source,true) + end if id == vlist_code then vlist_out(current,list) else hlist_out(current,list) end - -- if source then - -- flushstored(current,source,false) - -- end + if source and stored then + flushstored(current,source,false) + end if usedorientation then poporientation(usedorientation,pos_h,pos_v,pos_r) end diff --git a/tex/context/base/mkxl/font-chk.lmt b/tex/context/base/mkxl/font-chk.lmt index 008b9bb41..089e68f9f 100644 --- a/tex/context/base/mkxl/font-chk.lmt +++ b/tex/context/base/mkxl/font-chk.lmt @@ -379,13 +379,13 @@ local function expandglyph(characters,index,done) if n then d.next = expandglyph(characters,n,done) end - local h = d.hvariants + local h = d.hparts if h then for i=1,#h do h[i].glyph = expandglyph(characters,h[i].glyph,done) end end - local v = d.vvariants + local v = d.vparts if v then for i=1,#v do v[i].glyph = expandglyph(characters,v[i].glyph,done) diff --git a/tex/context/base/mkxl/font-con.lmt b/tex/context/base/mkxl/font-con.lmt index 3310242a8..b36f18dfa 100644 --- a/tex/context/base/mkxl/font-con.lmt +++ b/tex/context/base/mkxl/font-con.lmt @@ -254,6 +254,24 @@ local function fixedpsname(psname,fallback) return usedname, psname ~= usedname end +local function scaleparts(parts,delta) + local t = { } + for i=1,#parts do + local p = parts[i] + local s = p["start"] or 0 + local e = p["end"] or 0 + local a = p["advance"] or 0 + t[i] = { + ["start"] = s == 0 and 0 or s * delta, + ["end"] = e == 0 and 0 or e * delta, + ["advance"] = a == 0 and 0 or a * delta, + ["extender"] = p["extender"], + ["glyph"] = p["glyph"], + } + end + return t +end + function constructors.scale(tfmdata,specification) local target = { } -- the new table -- @@ -567,9 +585,7 @@ function constructors.scale(tfmdata,specification) -- for unicode, character in next, characters do local chr, description, index - -- todo: add description entry to char entry instead of index ... saves elsewhere too - if changed then local c = changed[unicode] if c and c ~= unicode then @@ -670,48 +686,17 @@ function constructors.scale(tfmdata,specification) if hasmath then -- -- todo, just operate on descriptions.math - local vn = character.next - if vn then - chr.next = vn - else - local vv = character.vvariants - if vv then - local t = { } - for i=1,#vv do - local vvi = vv[i] - local s = vvi["start"] or 0 - local e = vvi["end"] or 0 - local a = vvi["advance"] or 0 - t[i] = { -- zero check nicer for 5.3 - ["start"] = s == 0 and 0 or s * vdelta, - ["end"] = e == 0 and 0 or e * vdelta, - ["advance"] = a == 0 and 0 or a * vdelta, - ["extender"] = vvi["extender"], - ["glyph"] = vvi["glyph"], - } - end - chr.vvariants = t - else - local hv = character.hvariants - if hv then - local t = { } - for i=1,#hv do - local hvi = hv[i] - local s = hvi["start"] or 0 - local e = hvi["end"] or 0 - local a = hvi["advance"] or 0 - t[i] = { -- zero check nicer for 5.3 - ["start"] = s == 0 and 0 or s * hdelta, - ["end"] = e == 0 and 0 or e * hdelta, - ["advance"] = a == 0 and 0 or a * hdelta, - ["extender"] = hvi["extender"], - ["glyph"] = hvi["glyph"], - } - end - chr.hvariants = t - end - end - -- todo also check mathitalics (or that one can go away) + local nxt = character.next + if nxt then + chr.next = nxt + end + local vparts = character.vparts + if vparts then + chr.vparts = scaleparts(vparts,vdelta) + end + local hparts = character.hparts + if hparts then + chr.hparts = scaleparts(hparts,hdelta) end local vi = character.vitalic if vi and vi ~= 0 then @@ -742,14 +727,18 @@ function constructors.scale(tfmdata,specification) chr.italic = vi*hdelta end end - local ft = character.options - if ft then - chr.options = ft - end + -- local ft = character.options + -- if ft then + -- chr.options = ft + -- end local sm = character.smaller if sm then chr.smaller = sm end + local fa = character.flataccent + if fa then + chr.flataccent = fa + end elseif autoitalicamount then -- itlc feature local vi = description.italic if not vi then diff --git a/tex/context/base/mkxl/font-imp-math.lmt b/tex/context/base/mkxl/font-imp-math.lmt index 68dddf33d..2f9c94d16 100644 --- a/tex/context/base/mkxl/font-imp-math.lmt +++ b/tex/context/base/mkxl/font-imp-math.lmt @@ -26,7 +26,7 @@ local function initialize(tfmdata,value) if mathparameters then local sup, sub if type(value) == "string" then - sup, sub = lpegmatch(splitter,value) + sup, sub = lpegmatch(splitter,value) -- settings_to_array if not sup then sub, sup = 0, 0 elseif not sub then @@ -267,3 +267,43 @@ registerotffeature { node = initialize, } } + +local function initialize(tfmdata,value) + if value then + local validlookups, lookuplist = fonts.handlers.otf.collectlookups(tfmdata.shared.rawdata,"flac","math","dflt") + if validlookups then + -- it's quite likely just one step + local characters = tfmdata.characters + local changed = tfmdata.changed + for i=1,#lookuplist do + local lookup = lookuplist[i] + local steps = lookup.steps + local nofsteps = lookup.nofsteps + for i=1,nofsteps do + local coverage = steps[i].coverage + if coverage then + for k, v in next, coverage do + local c = characters[k] + local f = characters[v] + if c and f then + c.flataccent = v + if not f.unicode then + f.unicode = c.unicode + end + end + end + end + end + end + end + end +end + +registerotffeature { + name = "flattenaccents", + description = "mapping accents to flat ones", + initializers = { + base = initialize, + node = initialize, + } +} diff --git a/tex/context/base/mkxl/font-imp-sanitize.lmt b/tex/context/base/mkxl/font-imp-sanitize.lmt new file mode 100644 index 000000000..84c42e78f --- /dev/null +++ b/tex/context/base/mkxl/font-imp-sanitize.lmt @@ -0,0 +1,197 @@ +if not modules then modules = { } end modules ['font-san'] = { + version = 1.001, + comment = "companion to font-ini.mkiv", + author = "Hans Hagen, PRAGMA ADE & śrīrāma", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- \definefontfeature[demo][sanitizer=demo] +-- \definedfont[Serif*default,demo] test context test +-- \definedfont[Serif*default] test context test + +local keys, insert, copytable = table.keys, table.insert, table.copy +local utfvalues, utfbyte = utf.values, utf.byte + +local sanitizers = { } + +local trace = false +local report = logs.reporter("fonts", "sanitizers") + +trackers.register("fonts.sanitizers", function(v) trace = v end) + +function fonts.registersanitizer(name,vector) + sanitizers[name] = vector +end + +local function split(s) + local t = { } + for value in utfvalues(s) do + t[#t+1] = value + end + return t +end + +local function wrap(t) + for i=1,#t do + t[i] = { t[i] } + end + return t +end + +local function initializesanitizer(tfmdata,value) + local resources = tfmdata.resources + local sanitized = resources.sanitized + if not sanitized then + local sanitizer = false + local goodies = tfmdata.goodies + if goodies then + for i=1,#goodies do + local goodie = goodies[i] + local sanitizers = goodie.sanitizers + sanitizer = sanitizers and sanitizers[value] + if sanitizer then + report("using sanitizer %a from goodie file",value) + break + end + end + end + if not sanitizer then + sanitizer = sanitizers[value] + if sanitizer then + report("using sanitizer %a",value) + end + end + resources.sanitized = true + if sanitizer then + local mapping = sanitizer.mapping + if mapping then + local keys = keys(mapping) + local maps = { } + table.sort(keys, function(a,b) return a > b end) + for i = 1,#keys do + local k = keys[i] + keys[i] = split(k) + maps[i] = split(mapping[k]) + end + for i=1,#maps do + local k = keys[i] + local m = maps[i] + if trace then + -- m = copytable(m) + -- insert(m,1,utfbyte("[")) + -- insert(m, utfbyte("]")) + local t = { utfbyte("[") } + t[#t+1] = 0x200D -- zwnj + for i=1,#m do + t[#t+1] = m[i] + t[#t+1] = 0x200D -- zwnj + end + t[#t+1] = utfbyte("]") + end + maps[i] = { type = "multiple", data = { [k[1]] = m } } + keys[i] = { current = wrap(k) , lookups = { i } } + end + local specification = { + name = "sanitizer", + type = "chainsubstitution", + prepend = 1, + nocheck = true, + default = true, + lookups = maps, + data = { rules = keys }, + } + local s = fonts.handlers.otf.enhancers.addfeature( + tfmdata,"sanitizer",specification, true + ) + insert(resources.sequences,1,s) + end + end + end +end + +-- has to come *after* devanagari because we need to push it in front +-- ... it could be a built-in + +fonts.constructors.features.otf.register { + name = "sanitizer", + description = "inject sanitizer features", + initializers = { + node = initializesanitizer, + }, +} + +local dev2rkrf = { + ["के्र"] = "क्रे", + ["कै्र"] = "क्रै", + ["खे्र"] = "ख्रे", + ["खै्र"] = "ख्रै", + ["गे्र"] = "ग्रे", + ["गै्र"] = "ग्रै", + ["घे्र"] = "घ्रे", + ["घै्र"] = "घ्रै", + -- not required: placed here just to show how bad some fonts are :( + -- ["ङे्र"] = "ङ्रे", + -- ["ङै्र"] = "ङ्रै", + ["चे्र"] = "च्रे", + ["चै्र"] = "च्रै", + ["छे्र"] = "छ्रे", + ["छै्र"] = "छ्रै", + ["जे्र"] = "ज्रे", + ["जै्र"] = "ज्रै", + ["झे्र"] = "झ्रे", + ["झै्र"] = "झ्रै", + ["ञे्र"] = "ञ्रे", + ["ञै्र"] = "ञ्रै", + ["णे्र"] = "ण्रे", + ["णै्र"] = "ण्रै", + ["ते्र"] = "त्रे", + ["तै्र"] = "त्रै", + ["थे्र"] = "थ्रे", + ["थै्र"] = "थ्रै", + ["दे्र"] = "द्रे", + ["दै्र"] = "द्रै", + ["धे्र"] = "ध्रे", + ["धै्र"] = "ध्रै", + ["ने्र"] = "न्रे", + ["नै्र"] = "न्रै", + ["पे्र"] = "प्रे", + ["पै्र"] = "प्रै", + ["फे्र"] = "फ्रे", + ["फै्र"] = "फ्रै", + ["बे्र"] = "ब्रे", + ["बै्र"] = "ब्रै", + ["भे्र"] = "भ्रे", + ["भै्र"] = "भ्रै", + ["मे्र"] = "म्रे", + ["मै्र"] = "म्रै", + ["ये्र"] = "य्रे", + ["यै्र"] = "य्रै", + -- some fonts might need this, some might not: weird + -- for example: Shobhika does not need it but Noto Serif does :( + -- ["ले्र"] = "ल्रे", + -- ["लै्र"] = "ल्रै", + ["वे्र"] = "व्रे", + ["वै्र"] = "व्रै", + ["से्र"] = "स्रे", + ["सै्र"] = "स्रै", + ["शे्र"] = "श्रे", + ["शै्र"] = "श्रै", + ["षे्र"] = "ष्रे", + ["षै्र"] = "ष्रै", + ["हे्र"] = "ह्रे", + ["है्र"] = "ह्रै", + -- some fonts might need this, some might not: weird + -- ["ळे्र"] = "ळ्रे", + -- ["ळै्र"] = "ळ्रै", +} + +local demomapping = { + luatex = "LuaTeX", + metapost = "MetaPost", + context = "ConTeXt", + metafun = "MetaFun", +} + +fonts.registersanitizer("dev2rkrf", { mapping = dev2rkrf }) +fonts.registersanitizer("demo", { mapping = demomapping }) diff --git a/tex/context/base/mkxl/font-imp-tracing.lmt b/tex/context/base/mkxl/font-imp-tracing.lmt index 2187b9497..749a3c964 100644 --- a/tex/context/base/mkxl/font-imp-tracing.lmt +++ b/tex/context/base/mkxl/font-imp-tracing.lmt @@ -130,7 +130,12 @@ local function initialize(tfmdata,key,value) elseif v == v_none then rule[9] = false else - rule[9] = v + local thickness = string.todimen(v) + if thickness and thickness > 0 then + rule[5] = thickness + else + rule[9] = v + end end end end diff --git a/tex/context/base/mkxl/font-lib.mklx b/tex/context/base/mkxl/font-lib.mklx index c5543a107..485ed1041 100644 --- a/tex/context/base/mkxl/font-lib.mklx +++ b/tex/context/base/mkxl/font-lib.mklx @@ -117,9 +117,11 @@ \registerctxluafile{font-imp-tweaks}{} \registerctxluafile{font-imp-combining}{} \registerctxluafile{font-imp-scripts}{autosuffix} +\registerctxluafile{font-imp-sanitize}{autosuffix} % fixes for indic fonts \registerctxluafile{font-imp-tracing}{autosuffix} % comes last! + \registerctxluafile{font-fbk}{autosuffix} \registerctxluafile{font-aux}{} diff --git a/tex/context/base/mkxl/font-mat.mklx b/tex/context/base/mkxl/font-mat.mklx index cca22c497..7d72c5618 100644 --- a/tex/context/base/mkxl/font-mat.mklx +++ b/tex/context/base/mkxl/font-mat.mklx @@ -126,7 +126,7 @@ \def\font_helpers_set_math_family_set_scales_compact {% these are used when no font setting is there, the settings come before setting the parameters - % and are stored with the family + % and are stored with the family ... this is not really needed because the size is used otherwise \glyphtextscale \plusthousand \glyphscriptscale \numexpr\plusthousand*\dimexpr\scriptface \relax/\dimexpr\textface\relax\relax \glyphscriptscriptscale \numexpr\plusthousand*\dimexpr\scriptscriptface\relax/\dimexpr\textface\relax\relax} diff --git a/tex/context/base/mkxl/font-ogr.lmt b/tex/context/base/mkxl/font-ogr.lmt index 87166b36d..662c75b15 100644 --- a/tex/context/base/mkxl/font-ogr.lmt +++ b/tex/context/base/mkxl/font-ogr.lmt @@ -555,6 +555,7 @@ local initializeoverlay do manipulators = { base = initializeoverlay, node = initializeoverlay, + plug = initializeoverlay, } } @@ -632,6 +633,7 @@ local initializesvg do manipulators = { base = initializesvg, node = initializesvg, + plug = initializesvg, } } @@ -673,6 +675,7 @@ local initializepng do manipulators = { base = initializepng, node = initializepng, + plug = initializepng, } } @@ -682,6 +685,7 @@ local initializepng do manipulators = { base = initializepng, node = initializepng, + plug = initializepng, } } @@ -715,6 +719,7 @@ do manipulators = { base = initializecolor, node = initializecolor, + plug = initializecolor, } } diff --git a/tex/context/base/mkxl/font-otl.lmt b/tex/context/base/mkxl/font-otl.lmt index f493bc327..a68988e87 100644 --- a/tex/context/base/mkxl/font-otl.lmt +++ b/tex/context/base/mkxl/font-otl.lmt @@ -311,6 +311,41 @@ end -- instance protruding info and loop over characters; one is not supposed -- to change descriptions and if one does so one should make a copy! +-- local function best_done_here(tfmdata,characters,descriptions) +-- local validlookups, lookuplist = fonts.handlers.otf.collectlookups( +-- { resources = tfmdata.resources },"flac","math","dflt" +-- ) +-- if validlookups then +-- -- it's quite likely just one step +-- for i=1,#lookuplist do +-- local lookup = lookuplist[i] +-- local steps = lookup.steps +-- local nofsteps = lookup.nofsteps +-- for i=1,nofsteps do +-- local coverage = steps[i].coverage +-- if coverage then +-- for k, v in next, coverage do +-- local f = characters[v] +-- if f then +-- local d = descriptions[k] +-- local c = characters[k] +-- if c then +-- c.flataccent = v +-- end +-- if d then +-- d.flataccent = v +-- end +-- if not f.unicode then +-- f.unicode = c.unicode +-- end +-- end +-- end +-- end +-- end +-- end +-- end +-- end + local function copytotfm(data,cache_id) if data then local metadata = data.metadata @@ -348,7 +383,6 @@ local function copytotfm(data,cache_id) local d = descriptions[unicode] -- we could use parent table here local m = d.math if m then - -- watch out: luatex uses hvariants for the parts -- local italic = m.italic local vitalic = m.vitalic @@ -363,9 +397,9 @@ local function copytotfm(data,cache_id) c.next = un c = characters[un] end -- c is now last in chain - c.hvariants = parts + c.hparts = parts elseif parts then - character.hvariants = parts + character.hparts = parts italic = m.hitalic end -- @@ -379,9 +413,9 @@ local function copytotfm(data,cache_id) c.next = un c = characters[un] end -- c is now last in chain - c.vvariants = parts + c.vparts = parts elseif parts then - character.vvariants = parts + character.vparts = parts end -- if italic and italic ~= 0 then @@ -403,6 +437,7 @@ local function copytotfm(data,cache_id) end end end +-- best_done_here(data,characters,descriptions) end -- we need a runtime lookup because of running from cdrom or zip, brrr (shouldn't -- we use the basename then?) diff --git a/tex/context/base/mkxl/font-ots.lmt b/tex/context/base/mkxl/font-ots.lmt index c668c86d1..f9c6b2fae 100644 --- a/tex/context/base/mkxl/font-ots.lmt +++ b/tex/context/base/mkxl/font-ots.lmt @@ -8,6 +8,11 @@ if not modules then modules = { } end modules ['font-ots'] = { -- sequences } --[[ldx-- +<p>I need to check the description at the microsoft site ... it has been improved +so maybe there are some interesting details there. Most below is based on old and +incomplete documentation and involved quite a bit of guesswork (checking with the +abstract uniscribe of those days. But changing things is tricky!</p> + <p>This module is a bit more split up that I'd like but since we also want to test with plain <l n='tex'/> it has to be so. This module is part of <l n='context'/> and discussion about improvements and functionality mostly happens on the diff --git a/tex/context/base/mkxl/font-pre.mkxl b/tex/context/base/mkxl/font-pre.mkxl index aba14d8b2..60351ff53 100644 --- a/tex/context/base/mkxl/font-pre.mkxl +++ b/tex/context/base/mkxl/font-pre.mkxl @@ -404,14 +404,17 @@ [mode=base, % mode=none, % better, maybe do this last kern=yes, - % liga=yes, % makes no sense - mathnolimitsmode={0,800}, % this looks okay on the average font +% flac=yes, +% liga=yes, % makes no sense +% mode=node, +% mathnolimitsmode={0,800}, % now in lfg files mathalternates=yes, mathitalics=yes, % we pass them mathdimensions=all, % mathkerns=yes, % staircase=yes, compactmath=yes, + flattenaccents=yes, % mathgaps=yes, language=dflt, script=math] @@ -889,6 +892,12 @@ \permanent\protected\def\setsuperiors{\doaddfeature{f:superiors}} \permanent\protected\def\setfractions{\doaddfeature{f:fractions}} +\permanent\protected\def\resetsmallcaps{\dosubtractfeature{f:smallcaps}} +\permanent\protected\def\resetoldstyle {\dosubtractfeature{f:oldstyle}} +\permanent\protected\def\resettabular {\dosubtractfeature{f:tabular}} +\permanent\protected\def\resetsuperiors{\dosubtractfeature{f:superiors}} +\permanent\protected\def\resetfractions{\dosubtractfeature{f:fractions}} + % \permanent\protected\def\frc#1#2% % {\dontleavehmode % \begingroup diff --git a/tex/context/base/mkxl/font-tfm.lmt b/tex/context/base/mkxl/font-tfm.lmt index dcb76ba80..5f1c7bf2a 100644 --- a/tex/context/base/mkxl/font-tfm.lmt +++ b/tex/context/base/mkxl/font-tfm.lmt @@ -258,6 +258,8 @@ end -- shared.processes = next(features) and tfm.setfeatures(tfmdata,features) or nil -- + fonts.loggers.register(tfmdata,'tfm',specification) + -- if size < 0 then size = idiv(65536 * -size,100) end diff --git a/tex/context/base/mkxl/font-vfc.lmt b/tex/context/base/mkxl/font-vfc.lmt index 57344d18e..aff647dd1 100644 --- a/tex/context/base/mkxl/font-vfc.lmt +++ b/tex/context/base/mkxl/font-vfc.lmt @@ -91,7 +91,7 @@ helpers.vfinjectors = { -- stopcolor = function(h,v,packet) codeinjections.vfstartcolor(h,v,packet) end, -- literal = function(h,v,packet) codeinjections.vfliteral (h,v,packer) end, startcolor = function(h,v,packet) vfstartcolor(h,v,packet) end, - stopcolor = function(h,v,packet) vfstartcolor(h,v,packet) end, + stopcolor = function(h,v,packet) vfstopcolor (h,v,packet) end, -- literal = function(h,v,packet) vfliteral (h,v,packer) end, } diff --git a/tex/context/base/mkxl/lang-def.mkxl b/tex/context/base/mkxl/lang-def.mkxl index e50be9afc..b7919a29b 100644 --- a/tex/context/base/mkxl/lang-def.mkxl +++ b/tex/context/base/mkxl/lang-def.mkxl @@ -826,12 +826,12 @@ \installlanguage [\s!thai] [\s!th] -%D Indic languages (Kauśika) +%D Indic languages (śrīrāman) % % %D Sanskit (someone needs to define the parameters): -%D -%D The file \type {lang-sa.lua} contains sanskrit hyphenation patterns for devanagari, +%D +%D The file \type {lang-sa.lua} contains sanskrit hyphenation patterns for devanagari, %D bengali, telugu, kannada, malayalam and roman(iast. \installlanguage diff --git a/tex/context/base/mkxl/lang-tra.lmt b/tex/context/base/mkxl/lang-tra.lmt index b3fedc7c1..259165928 100644 --- a/tex/context/base/mkxl/lang-tra.lmt +++ b/tex/context/base/mkxl/lang-tra.lmt @@ -9,7 +9,11 @@ if not modules then modules = { } end modules ['lang-tra'] = { -- The indic transliterations was researched by kauśika and after some experiments -- we settled on the current approach (mappings and a more specific lpeg). -local concat = table.concat +-- Todo: initial and final in addition to mapping so that we can do hebrew and +-- such. + +local concat, setmetatableindex = table.concat, table.setmetatableindex +local nospaces = string.nospaces local utfbyte, utfchar, utfsplit, utfvalues = utf.byte, utf.char, utf.split, utf.values local C, Cc, Cs, lpegmatch = lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.match local utfchartabletopattern = lpeg.utfchartabletopattern @@ -30,6 +34,9 @@ local removenode = nuts.remove local texsetattribute = tex.setattribute +local registervalue = attributes.registervalue +local getvalue = attributes.getvalue + local transliteration = { } languages.transliteration = transliteration @@ -41,9 +48,10 @@ local context = context local zwj = utf.char(0x200D) -local lastmapping = 0 +-- local lastmapping = 0 local loadedmappings = { } local loadedlibraries = { } +local exceptions = { } local report = logs.reporter("transliteration") local trace = false trackers.register("languages.transliteration", function(v) trace = v end) @@ -80,21 +88,23 @@ local converters = { ["mapping"] = function(m) local t_mapping = m.mapping if t_mapping then + local t_exceptions = m.exceptions local p = Cs ( ( utfchartabletopattern(t_mapping) / t_mapping + C(utfcharacterpattern) )^0 ) -- lpeg.print(p) - return function(s) - return lpegmatch(p,s) or s + return function(s,e) + return (e and e[s]) or t_exceptions[s] or lpegmatch(p,s) or s end else return false end end, ["default"] = function(m) - return function(s) - return s + local t_exceptions = m.exceptions + return function(s,e) + return (e and e[s]) or t_exceptions[s] or s end end, } @@ -109,19 +119,21 @@ function transliteration.use(library) if transliterations then for name, d in table.sortedhash(transliterations) do local vector = d.vector + if not d.exceptions then + d.exceptions = { } + end if vector then - report("vector %a in %a is %sloaded with index %i",name,library," already",d.attribute) + report("vector %a in %a is %sloaded",name,library," already") else - lastmapping = lastmapping + 1 d.vector = (converters[name] or converters.mapping or converters.default)(d) or (converters.default)(d) - report("vector %a in set %a is %sloaded with index %i",name,library,"",lastmapping) + report("vector %a in set %a is %sloaded",name,library,"") end - d.attribute = lastmapping d.library = library d.name = name + d.mapping = nil -- for now, saves memory loadedmappings[name] = d - loadedmappings[lastmapping] = d + loadedmappings[nospaces(name)] = d end else report("library %a has no transliterations",library) @@ -140,28 +152,47 @@ enable = function() enable = false end -function transliteration.set(vector) +function transliteration.register(parent,name) + local p = exceptions[parent] + if p then + if trace then + report("%a has exceptions that default to %a",name,parent) + end + exceptions[name] = setmetatableindex({ },p) + else + if trace then + report("%a has independent exceptions",name) + end + exceptions[name] = { } + end +end + +function transliteration.set(name,vector) if enable then enable() end - local m = loadedmappings[vector] - local a = m and m.attribute or unsetvalue + local a = registervalue(a_transliteration, { + m = loadedmappings[vector], + e = exceptions[name], + }) if trace then - report("setting transliteration %s",vector) + report("setting transliteration %i, name %a, vector %a",a,name,vector) end texsetattribute(a_transliteration,a) end -function transliteration.register(vector) - if enable then - enable() - end - local m = loadedmappings[vector] - local a = m and m.attribute or unsetvalue - if trace then - report("registering transliteration %s",vector) +function transliteration.exception(name,old,new) + local m = loadedmappings[name] + if m then + m.exceptions[old] = new + else + local e = exceptions[name] + if not e then + e = { } + exceptions[name] = e + end + e[old] = new end - return a end -- When there is need I will improve the performance of the next handler. @@ -169,6 +200,7 @@ end function transliteration.handler(head) local aprev = nil local vector = nil + local except = nil local current = head local first = nil local last = nil @@ -180,34 +212,36 @@ function transliteration.handler(head) -- actually we can generalize the replacer elsewhere local function flush(nxt) - -- we can do some optimization here by having the split as replacement - local old = concat(list,"",1,size) - local new = vector(old) - if old ~= new then - if trace then - report("old: %s",old) - report("new: %s",new) - end - local c = first - local x = false - for s in utfvalues(new) do - if x then - head, c = insertafter(head,c,copynode(first)) - setchar(c,s) - else - setchar(c,s) - if c == last then - x = true + if vector then + -- we can do some optimization here by having the split as replacement + local old = concat(list,"",1,size) + local new = vector(old,except) + if old ~= new then + if trace then + report("old: %s",old) + report("new: %s",new) + end + local c = first + local x = false + for s in utfvalues(new) do + if x then + head, c = insertafter(head,c,copynode(first)) + setchar(c,s) else - c = getnext(c) + setchar(c,s) + if c == last then + x = true + else + c = getnext(c) + end end end - end - if not x then - while c do - head, c = removenode(head,c,true) - if c == nxt then - break + if not x then + while c do + head, c = removenode(head,c,true) + if c == nxt then + break + end end end end @@ -226,9 +260,19 @@ function transliteration.handler(head) size = 0 end aprev = a - vector = loadedmappings[a] - if vector then - vector = vector.vector + local data = getvalue(a_transliteration,a) + if data then + local m = data.m + if m then + vector = m.vector + except = data.e + else + vector = nil + except = nil + end + else + vector = nil + except = nil end end if not first then @@ -269,14 +313,20 @@ interfaces.implement { implement { name = "settransliteration", - arguments = "string", + arguments = "2 strings", actions = transliteration.set, } implement { name = "registertransliteration", - arguments = "string", - actions = { transliteration.register, context }, + arguments = "3 strings", + actions = transliteration.register, +} + +implement { + name = "transliterationexception", + arguments = "3 strings", + actions = transliteration.exception, } nodes.tasks.prependaction("processors", "normalizers", "languages.transliteration.handler", nil, "nut", "disabled" ) diff --git a/tex/context/base/mkxl/lang-tra.mkxl b/tex/context/base/mkxl/lang-tra.mkxl index 96dcc7d94..a44ee4ba9 100644 --- a/tex/context/base/mkxl/lang-tra.mkxl +++ b/tex/context/base/mkxl/lang-tra.mkxl @@ -23,46 +23,62 @@ \definesystemattribute[transliteration][public,global] -% define in lua: \usetransliteration[#1] +\newtoks\everytransliterations -% todo: define fast attribute at the tex end do we can have a proper define +\appendtoks + \disablediscretionaries + \let~=\lettertilde + % \let|=\letterbar +\to \everytransliterations -\def\lang_transliteration_set#1% - {\ifcsname\??transliteration#1\endcsname - \c_attr_transliteration\lastnamedcs - \edef\currenttransliteration{#1}% - \usetransliterationstyleandcolor\c!style\c!color - \uselanguageparameter\transliterationparameter - \else - \clf_settransliteration{#1}% - \fi} +\def\lang_transliteration_common + {\usetransliterationstyleandcolor\c!style\c!color + \uselanguageparameter\transliterationparameter + \clf_settransliteration{\currenttransliteration}{\transliterationparameter\c!vector}% + \the\everytransliterations} \permanent\tolerant\protected\def\settransliteration[#1]#;#2% - {\lang_transliteration_set{#1}} + {\edef\currenttransliteration{#1#2}% + \lang_transliteration_common} + +\permanent\protected\def\transliterationexception[#1]#2#3% + {\clf_transliterationexception{#1}{#2}{#3}} \permanent\tolerant\protected\def\starttransliteration[#1]#*[#2]% {\begingroup + \edef\currenttransliteration{#1}% \ifparameter#2\or - \edef\currenttransliteration{#1}% \setupcurrenttransliteration[#2]% \fi - \lang_transliteration_set{#1}} + \transliterationparameter\c!before\relax + \lang_transliteration_common} + +\permanent\protected\def\stoptransliteration + {\transliterationparameter\c!after\relax + \endgroup} \permanent\tolerant\protected\def\transliteration[#1]#;#2% - {\groupedcommand{\lang_transliteration_set{#1#2}}\donothing} + {\groupedcommand + {\edef\currenttransliteration{#1#2}% + \lang_transliteration_common + \transliterationparameter\c!left\relax} + {\transliterationparameter\c!right\relax}} \appendtoks - \expandafter\integerdef\csname\??transliteration\currenttransliteration\endcsname - \clf_registertransliteration{\transliterationparameter\c!vector}% - \relax + \clf_registertransliteration{\currenttransliterationparent}{\currenttransliteration}% + \ifcstok{\transliterationparameter\c!define}\v!yes + \frozen\protected\instance\edefcsname\e!start\currenttransliteration\endcsname{\starttransliteration[\currenttransliteration]}% + \frozen\protected\instance\edefcsname\e!stop \currenttransliteration\endcsname{\stoptransliteration}% + \frozen\protected\instance\edefcsname \currenttransliteration\endcsname{\transliteration[\currenttransliteration]}% + \fi \to \everydefinetransliteration -\permanent\protected\def\stoptransliteration - {\endgroup} - \permanent\protected\def\resettransliteration {\c_attr_transliteration\attributeunsetvalue} +\setuptransliteration + [\c!define=\v!yes] + \appendtoks \resettransliteration \to \everyinitializeverbatim diff --git a/tex/context/base/mkxl/libs-imp-zint.lmt b/tex/context/base/mkxl/libs-imp-zint.lmt index 4558ca58e..1b1d294c9 100644 --- a/tex/context/base/mkxl/libs-imp-zint.lmt +++ b/tex/context/base/mkxl/libs-imp-zint.lmt @@ -79,31 +79,56 @@ table.setmetatableindex(mapping,function(t,k) return v end) +-- local options = { +-- -- DATA_MODE = 0 -- Binary +-- -- UNICODE_MODE = 1 -- UTF-8 +-- -- GS1_MODE = 2 -- GS1 +-- -- GS1PARENS_MODE = 16 -- process parentheses as GS1 AI delimiters (instead of square brackets) +-- square = 100 -- DM_SQUARE : only consider square versions on automatic symbol size selection +-- -- DMRE = 101 -- DM_DMRE : consider DMRE versions on automatic symbol size selection +-- } + local report = logs.reporter("zint") local context = context local shown = false -- Same performance as just context(fmt,...): 113pps (On 2013 i7 laptop.) ------ f_rectangle = formatters["%sofill unitsquare xysized (%N,%N) shifted (%N,%N);"] -local f_hexagon = formatters["%sofill (%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--cycle;"] -local f_circle = formatters["%sofill unitcircle scaled %N shifted (%N,%N);"] +-- ----- f_rectangle = formatters["%sofill unitsquare xysized (%N,%N) shifted (%N,%N);"] +-- local f_hexagon = formatters["%sofill (%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--cycle;"] +-- local f_circle = formatters["%sofill unitcircle scaled %N shifted (%N,%N);"] + +----- f_rectangle = formatters["%nofill unitsquare xysized (%N,%N) shifted (%N,%N);"] +local f_hexagon = formatters["%nofill (%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--cycle;"] +local f_circle = formatters["%nofill unitcircle scaled %N shifted (%N,%N);"] + +local s_done = "dofill origin --cycle;" local f_string = formatters['draw textext("%s") scaled (%N/10) shifted (%N,%N);'] -- A bit faster: 130pps (When I see hexagons I'll do that too but MP takes way more time.) +-- local s_preamble = [[ +-- save ns; def ns (expr a, b) = nofill unitsquare xyscaled a shifted b ; enddef; +-- save ds; def ds (expr a, b) = dofill unitsquare xyscaled a shifted b ; enddef; +-- ]] + local s_preamble = [[ save ns; def ns (expr a, b) = nofill unitsquare xyscaled a shifted b ; enddef; - save ds; def ds (expr a, b) = dofill unitsquare xyscaled a shifted b ; enddef; ]] ----- f_rectangle = formatters["%ss((%N,%N),(%N,%N));"] -local f_rectangle = formatters["%ss((%i,%i),(%i,%i));"] +local f_rectangle = formatters["ns((%i,%i),(%i,%i));"] local function execute(specification) if okay() then - local code = specification.code - local text = specification.text + local code = specification.code + local text = specification.text + local option = specification.option + -- + if option then + option = gsub(option,"^%-+","") + end + specification.option = option -- if lower(code) == "isbn" then specification.text = text and gsub(text,"[^%d]","") or "" @@ -127,20 +152,24 @@ local function execute(specification) for i=1,n do local r = rectangles[i] -- context("%sofill unitsquare xysized (%N,%N) shifted (%N,%N);", - rectangles[i] = f_rectangle( - i == n and "d" or "n",r[3],r[4],r[1],r[2] - ) +-- rectangles[i] = f_rectangle( +-- i == n and "d" or "n",r[3],r[4],r[1],r[2] +-- ) +rectangles[i] = f_rectangle(r[3],r[4],r[1],r[2]) end +rectangles[n+1] = s_done context("% t",rectangles) end if hexagons then local n = #hexagons for i=1,n do -- context("%sofill (%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--cycle;", - hexagons[i] = f_hexagon( - i == n and "d" or "n",unpack(hexagons[i]) - ) +-- hexagons[i] = f_hexagon( +-- i == n and "d" or "n",unpack(hexagons[i]) +-- ) +hexagons[i] = f_hexagon(unpack(hexagons[i])) end +hexagons[n+1] = s_done context("% t",hexagons) end if circles then @@ -148,9 +177,11 @@ local function execute(specification) for i=1,n do local c = circles[i] -- context("%sofill unitcircle scaled %N shifted (%N,%N);", - circles[i] = f_circle( - i == n and "d" or "n",c[3],c[1],c[2] - ) +-- circles[i] = f_circle( +-- i == n and "d" or "n",c[3],c[1],c[2] +-- ) +circles[i] = f_circle(c[3],c[1],c[2]) +circles[n+1] = s_done end context("% t",circles) end @@ -197,6 +228,7 @@ interfaces.implement { { { "code" }, { "text" }, + { "option" }, } } } diff --git a/tex/context/base/mkxl/libs-imp-zint.mkxl b/tex/context/base/mkxl/libs-imp-zint.mkxl index b2c364379..9905e0470 100644 --- a/tex/context/base/mkxl/libs-imp-zint.mkxl +++ b/tex/context/base/mkxl/libs-imp-zint.mkxl @@ -22,7 +22,7 @@ %D %D % e:\tex-context\tex\texmf-win64\bin\lib\luametatex\zint\libzint.dll -\enabletrackers[*res*] +% \enabletrackers[*res*] \registerctxluafile{libs-imp-zint}{autosuffix} @@ -34,12 +34,13 @@ {\bgroup \usedzintfont \getdummyparameters - [\c!alternative=,\c!text=,#1]% + [\c!alternative=,\c!text=,\c!option=,#1]% \scale [#1]% {\clf_zint - code {\dummyparameter\c!alternative} - text {\dummyparameter\c!text} + code {\dummyparameter\c!alternative} + text {\dummyparameter\c!text} + option {\dummyparameter\c!option} \relax}% \egroup} @@ -51,23 +52,76 @@ \dontcomplain -\dorecurse{1}{ +% \dorecurse{1}{ +% \startTEXpage +% \barcode[alternative=PDF417,text={Hans Hagen}]% +% \blank +% \barcode[alternative=PDF417,text={Ton Otten}]% +% \blank +% \barcode[alternative=ISBN,text=9789490688011]% +% \blank +% \barcode[alternative=isbn,text=9789490688011,width=3cm]% +% \blank +% \dontleavehmode +% \barcode[alternative=qr code,text={This is ConTeXt MKIV : #1}] +% \barcode[alternative=qr code,text={This is ConTeXt LMTX}] +% \barcode[alternative=qr code,text={\cldloadfile{tufte}},width=3cm] +% \blank +% \barcode[alternative=datamatrix,text=whatever,width=3cm,option=square] +% \scale[width=3cm,height=3cm]{\barcode[alternative=datamatrix,text=whatever,width=3cm,option=square]} +% \barcode[alternative=datamatrix,text={helloworld}] +% \barcode[alternative=datamatrix,text={hello world}] +% \stopTEXpage +% } + + \startTEXpage + \startluacode + for i=1,100 do + context.dontleavehmode() + context.barcode { + alternative = "datamatrix", + text = string.rep("!",i), + } + context.space() + context.allowbreak() + end + \stopluacode + \stopTEXpage + \startTEXpage - \barcode[alternative=PDF417,text={Hans Hagen}]% - \blank - \barcode[alternative=PDF417,text={Ton Otten}]% - \blank - \barcode[alternative=ISBN,text=9789490688011]% - \blank - \barcode[alternative=isbn,text=9789490688011,width=3cm]% - \blank - \dontleavehmode - \barcode[alternative=qr code,text={This is ConTeXt MKIV : #1}] - \barcode[alternative=qr code,text={This is ConTeXt LMTX}] - \barcode[alternative=qr code,text={\cldloadfile{tufte}},width=3cm] + \startluacode + for i=1,100 do + context.dontleavehmode() + context.barcode { + alternative = "datamatrix", + text = string.rep("!",i), + option = "square", + } + context.space() + context.allowbreak() + end + \stopluacode \stopTEXpage -} + \startluacode + for i=1,25 do + context.startTEXpage() + context.dontleavehmode() + context(i) + context.space() + context.barcode { + alternative = "datamatrix", + text = string.rep("!",i), + } + context.space() + context.barcode { + alternative = "datamatrix", + text = string.rep("!",i), + option = "square", + } + context.stopTEXpage() + end + \stopluacode \stoptext diff --git a/tex/context/base/mkxl/lpdf-emb.lmt b/tex/context/base/mkxl/lpdf-emb.lmt index 9811c0843..d6252ae02 100644 --- a/tex/context/base/mkxl/lpdf-emb.lmt +++ b/tex/context/base/mkxl/lpdf-emb.lmt @@ -1826,7 +1826,7 @@ do if kind == "font" then return setmetatableindex(function(t,k) local h = data[k] - local v = direct(h[1]/255,h[2]/255,h[3]/255) + local v = h and direct(h[1]/255,h[2]/255,h[3]/255) or false t[k] = v return v end) diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 9bb3319d4..6b623b372 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -1529,7 +1529,7 @@ local flushimage do local d = -depth + half local w = width - line local t = total - line - if baseline then + if baseline and w > 0 then rule = f_y(line,half,d,w,t,half,w) else rule = f_x(line,half,d,w,t) @@ -3406,8 +3406,13 @@ do converter(driver,texgetbox(boxnumber),"page") end - localconverter = function(...) - converter(useddriver,...) +-- localconverter = function(...) +-- print(...) -- ok when we add this +-- converter(useddriver,...) -- otherwise nil .. lua bug +-- end + + localconverter = function(a,b,c,d) + converter(useddriver,a,b,c,d) end drivers.install { diff --git a/tex/context/base/mkxl/lpdf-rul.lmt b/tex/context/base/mkxl/lpdf-rul.lmt index 96b4597bb..1dfcc11a3 100644 --- a/tex/context/base/mkxl/lpdf-rul.lmt +++ b/tex/context/base/mkxl/lpdf-rul.lmt @@ -376,7 +376,29 @@ h %s]] pdfprint("direct",f_baselined(l,o,o,w-l,h+d-l,0,d,w,d)) end else - pdfprint("direct",f_rectangle(l,o,o,w-l,h+d-l)) + pdfprint("direct",f_rectangle(l,o,o,w-l,h+d-l,"s")) + end + end + + local function rule_box(p,h,v,i,n) + local w, h, d = getwhd(n) + local line = p.line or 65536 + local l = line *bpfactor + local w = w * bpfactor + local h = h * bpfactor + local d = d * bpfactor + local o = l / 2 + if p.baseline ~= false and ((d >= 0 and h >= 0) or (d <= 0 and h <= 0)) then + local dashed = tonumber(p.dashed) + if dashed and dashed > 5*line then + dashed = dashed * bpfactor + local delta = (w - 2*dashed*floor(w/(2*dashed)))/2 + pdfprint("direct",f_dashlined(l,o,o,w-l,h+d-l,dashed,dashed,delta,d,w-delta,d)) + else + pdfprint("direct",f_baselined(l,o,o,w-l,h+d-l,0,d,w,d)) + end + else + pdfprint("direct",f_rectangle(l,o,o,w-l,h+d-l,"s")) end end diff --git a/tex/context/base/mkxl/lpdf-xmp.lmt b/tex/context/base/mkxl/lpdf-xmp.lmt index c4f475914..e147c796f 100644 --- a/tex/context/base/mkxl/lpdf-xmp.lmt +++ b/tex/context/base/mkxl/lpdf-xmp.lmt @@ -64,10 +64,11 @@ local mapping = table.setmetatableindex ( { ["Producer"] = { "metadata","rdf:Description/pdf:Producer" }, -- ["Trapped"] = { "pdf", "rdf:Description/pdf:Trapped" }, -- '/False' in /Info, but 'False' in XMP -- Dublin Core schema - ["Author"] = { "metadata","rdf:Description/dc:creator/rdf:Seq/rdf:li" }, ["Format"] = { "metadata","rdf:Description/dc:format" }, -- optional, but nice to have - ["Subject"] = { "metadata","rdf:Description/dc:description/rdf:Alt/rdf:li" }, - ["Title"] = { "metadata","rdf:Description/dc:title/rdf:Alt/rdf:li" }, + -- These were dc:.../rdf:Seq/rdf:li but there was a (invalidating) bug in the iso + ["Author"] = { "metadata","rdf:Description/dc:creator" }, + ["Subject"] = { "metadata","rdf:Description/dc:description" }, + ["Title"] = { "metadata","rdf:Description/dc:title" }, -- XMP Basic schema ["CreateDate"] = { "date", "rdf:Description/xmp:CreateDate" }, ["CreationDate"] = { "date", "rdf:Description/xmp:CreationDate" }, -- dummy @@ -254,11 +255,11 @@ local pdfaddxmpinfo = lpdf.addxmpinfo function lpdf.addtoinfo(tag,pdfvalue,strvalue) local pattern = mapping[tag][2] - if pattern then + if pattern or strvalue == true then pdfaddtoinfo(tag,pdfvalue) end if type(pattern) == "string" then - local value = strvalue or gsub(tostring(pdfvalue),"^%((.*)%)$","%1") -- hack + local value = (type(strvalue) == "string" and strvalue) or gsub(tostring(pdfvalue),"^%((.*)%)$","%1") -- hack if trace_info then report_info("set %a to %a",tag,value) end diff --git a/tex/context/base/mkxl/math-acc.mklx b/tex/context/base/mkxl/math-acc.mklx index aab7e4874..929a37ae6 100644 --- a/tex/context/base/mkxl/math-acc.mklx +++ b/tex/context/base/mkxl/math-acc.mklx @@ -46,108 +46,129 @@ \installcorenamespace{mathaccents} -\installcommandhandler \??mathaccents {mathaccents} \??mathaccents +\installcommandhandler \??mathaccents {mathaccent} \??mathaccents + +\aliased\let\setupmathaccents\setupmathaccent \setupmathaccents [\c!top=, \c!bottom=, \c!mathstyle=, \c!color=, + \c!stretch=\v!no, \c!define=\v!yes] % not used -\definemathaccents +\definemathaccent [\v!both] -\definemathaccents +\definemathaccent [\v!top] [\v!both] -\definemathaccents +\definemathaccent [\v!bottom] [\v!both] \permanent\tolerant\protected\def\definemathtopaccent[#1]#*[#2]#*[#3]% class name top {\ifparameter#3\or - \frozen\protected\instance\edefcsname#2\endcsname{\math_accents_make_double {#1}\plusone{\number#3}\zerocount}% + \frozen\protected\instance\edefcsname#2\endcsname{\math_accent_make_double {#1}\plusone{\number#3}\zerocount}% \else - \frozen\protected\instance\edefcsname#1\endcsname{\math_accents_make_double\noexpand\currentmathaccents\plusone{\number#2}\zerocount}% + \frozen\protected\instance\edefcsname#1\endcsname{\math_accent_make_double\noexpand\currentmathaccent\plusone{\number#2}\zerocount}% \fi} \permanent\tolerant\protected\def\definemathbottomaccent[#1]#*[#2]#*[#3]% class name bottom {\ifparameter#3\or - \frozen\protected\instance\edefcsname#2\endcsname{\math_accents_make_double {#1}\plustwo\zerocount{\number#3}}% + \frozen\protected\instance\edefcsname#2\endcsname{\math_accent_make_double {#1}\plustwo\zerocount{\number#3}}% \else - \frozen\protected\instance\edefcsname#1\endcsname{\math_accents_make_double\noexpand\currentmathaccents\plustwo\zerocount{\number#2}}% + \frozen\protected\instance\edefcsname#1\endcsname{\math_accent_make_double\noexpand\currentmathaccent\plustwo\zerocount{\number#2}}% \fi} \permanent\tolerant\protected\def\definemathdoubleaccent[#1]#*[#2]#*[#3]#*[#4]% class name top bottom {\ifparameter#4\or - \frozen\protected\instance\edefcsname#2\endcsname{\math_accents_make_double {#1}\plusthree{\number#3}{\number#4}}% + \frozen\protected\instance\edefcsname#2\endcsname{\math_accent_make_double {#1}\plusthree{\number#3}{\number#4}}% \else - \frozen\protected\instance\edefcsname#1\endcsname{\math_accents_make_double\noexpand\currentmathaccents\plusthree{\number#2}{\number#3}}% + \frozen\protected\instance\edefcsname#1\endcsname{\math_accent_make_double\noexpand\currentmathaccent\plusthree{\number#2}{\number#3}}% \fi} -\let\math_accents_color_pop\donothing - -\def\math_accents_color_push_yes - {\pushcolor[\p_math_accent_color]% - \let\math_accents_color_pop\popcolor} +\installlocalcurrenthandler \??mathaccents {mathaccent} -\def\math_accents_color_push_nop - {\let\math_accents_color_pop\donothing} - -\protected\def\math_accents_make_double#class#kind#top#bottom#content% - {\begingroup - \edef\currentmathaccents {#class}% - \edef\p_math_accent_color{\mathaccentsparameter\c!color}% - \startusemathstyleparameter\mathaccentsparameter\c!mathstyle - \ifempty\p_math_accent_color - \math_accents_color_push_nop - \else - \math_accents_color_push_yes - \fi +\tolerant\protected\def\math_accent_make_double#class#kind#top#bottom#*[#settings]#:#content% + {\beginmathgroup + \setlocalmathaccentcurrent{#class}% \edef\currentmathaccent{#class}% + \startusemathstyleparameter\mathaccentparameter\c!mathstyle + \setupcurrentmathaccent[#settings]% + \edef\m_fixed{\ifcstok{\mathaccentparameter\c!stretch}\v!yes\else\s!fixed\fi}% + \Umathaccent + \usedcolorparameterattributes{\mathaccentparameter\c!color}% \ifcase#kind\or - \Umathaccent \fam\zerocount#top + top \m_fixed + \fam\zerocount#top \or - \Umathaccent bottom \fam\zerocount#bottom + bottom \m_fixed + \fam\zerocount#bottom \or - \Umathaccent both \fam\zerocount#top - \fam\zerocount#bottom + both \m_fixed + \fam\zerocount#top + \fam\zerocount#bottom \fi - {\math_accents_color_pop#content}% + {\ifconditional\c_math_accent_auto_dotless\mathdotless\fi#content}% \stopusemathstyleparameter - \endgroup} + \endmathgroup} %D Relative new: -\newconditional\c_math_accents_auto_dotless \settrue\c_math_accents_auto_dotless % cf opentype math - -\aliased\let\normalgrave\grave \permanent\protected\def\dotlessgrave#1{\normalgrave{\mathdotless#1}} -\aliased\let\normalddot \ddot \permanent\protected\def\dotlessddot #1{\normalddot {\mathdotless#1}} -\aliased\let\normalbar \bar \permanent\protected\def\dotlessbar #1{\normalbar {\mathdotless#1}} -\aliased\let\normalacute\acute \permanent\protected\def\dotlessacute#1{\normalacute{\mathdotless#1}} -\aliased\let\normalhat \hat \permanent\protected\def\dotlesshat #1{\normalhat {\mathdotless#1}} -\aliased\let\normalcheck\check \permanent\protected\def\dotlesscheck#1{\normalcheck{\mathdotless#1}} -\aliased\let\normalbreve\breve \permanent\protected\def\dotlessbreve#1{\normalbreve{\mathdotless#1}} -\aliased\let\normaldot \dot \permanent\protected\def\dotlessdot #1{\normaldot {\mathdotless#1}} -\aliased\let\normalring \ring \permanent\protected\def\dotlessring #1{\normalring {\mathdotless#1}} -\aliased\let\normaltilde\tilde \permanent\protected\def\dotlesstilde#1{\normaltilde{\mathdotless#1}} -\aliased\let\normaldddot\dddot \permanent\protected\def\dotlessdddot#1{\normaldddot{\mathdotless#1}} - -\def\math_accents_auto_dotless#1#2{\ifconditional\c_math_accents_auto_dotless\expandafter#2\else\expandafter#1\fi} - -\permanent\protected\def\grave {\math_accents_auto_dotless\normalgrave \dotlessgrave } -\permanent\protected\def\ddot {\math_accents_auto_dotless\normalddot \dotlessddot } -\permanent\protected\def\bar {\math_accents_auto_dotless\normalbar \dotlessbar } -\permanent\protected\def\acute {\math_accents_auto_dotless\normalacute \dotlessacute } -\permanent\protected\def\hat {\math_accents_auto_dotless\normalhat \dotlesshat } -\permanent\protected\def\check {\math_accents_auto_dotless\normalcheck \dotlesscheck } -\permanent\protected\def\breve {\math_accents_auto_dotless\normalbreve \dotlessbreve } -\permanent\protected\def\dot {\math_accents_auto_dotless\normaldot \dotlessdot } -\permanent\protected\def\ring {\math_accents_auto_dotless\normalring \dotlessring } -\permanent\protected\def\tilde {\math_accents_auto_dotless\normaltilde \dotlesstilde } -\permanent\protected\def\dddot {\math_accents_auto_dotless\normaldddot \dotlessdddot } +\newconditional\c_math_accent_auto_dotless \settrue\c_math_accent_auto_dotless % cf opentype math + +\aliased\let\normalgrave\grave +\aliased\let\normalddot \ddot +\aliased\let\normalbar \bar +\aliased\let\normalacute\acute +\aliased\let\normalhat \hat +\aliased\let\normalcheck\check +\aliased\let\normalbreve\breve +\aliased\let\normaldot \dot +\aliased\let\normalring \ring +\aliased\let\normaltilde\tilde +\aliased\let\normaldddot\dddot + +\pushoverloadmode + +% these are not stretched ... we should adapt char-def.lua to use these: + +\definemathtopaccent[\v!top][grave]["60] +\definemathtopaccent[\v!top][ddot] ["A8] +\definemathtopaccent[\v!top][bar] ["AF] +\definemathtopaccent[\v!top][acute]["B4] +\definemathtopaccent[\v!top][hat] ["2C6] % "302 +\definemathtopaccent[\v!top][check]["2C7] +\definemathtopaccent[\v!top][breve]["2D8] +\definemathtopaccent[\v!top][dot] ["2D9] +\definemathtopaccent[\v!top][ring] ["2DA] +\definemathtopaccent[\v!top][tilde]["2DC] +\definemathtopaccent[\v!top][dddot]["20DB] + +\definemathaccent + [\v!top:\v!stretch] + [\v!top] + [\c!stretch=\v!yes] + +%D We have a problem. We can use stackers but then we need to adapt the dimensions +%D which is font dependent. So, for now we keep them as accents. + +\definemathtopaccent[\v!top:\v!stretch][widegrave]["0300] % ["060] +\definemathtopaccent[\v!top:\v!stretch][wideddot] ["0308] % ["0A8] +\definemathtopaccent[\v!top:\v!stretch][widebar] ["0304] % ["0AF] +\definemathtopaccent[\v!top:\v!stretch][wideacute]["0301] % ["0B4] +\definemathtopaccent[\v!top:\v!stretch][widehat] ["0302] % ["2C6] +\definemathtopaccent[\v!top:\v!stretch][widecheck]["030C] % ["2C7] +\definemathtopaccent[\v!top:\v!stretch][widebreve]["0306] % ["2D8] +\definemathtopaccent[\v!top:\v!stretch][widedot] ["0307] % ["2D9] +\definemathtopaccent[\v!top:\v!stretch][widering] ["030A] % ["2DA] +\definemathtopaccent[\v!top:\v!stretch][widetilde]["0303] % ["2DC] +\definemathtopaccent[\v!top:\v!stretch][widedddot]["20DB] \aliased\let\mathring\ring % for a while +\popoverloadmode + \protect \endinput diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt index 48d389bf9..7aeec184f 100644 --- a/tex/context/base/mkxl/math-act.lmt +++ b/tex/context/base/mkxl/math-act.lmt @@ -13,6 +13,7 @@ local type, next = type, next local fastcopy, insert, remove = table.fastcopy, table.insert, table.remove local formatters = string.formatters local byte = string.byte +local setmetatableindex, sortedhash = table.setmetatableindex, table.sortedhash local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) local trace_collecting = false trackers.register("math.collecting", function(v) trace_collecting = v end) @@ -60,9 +61,26 @@ function mathematics.initializeparameters(target,original) local mathparameters = original.mathparameters if mathparameters and next(mathparameters) then mathparameters = mathematics.dimensions(mathparameters) - if not mathparameters.SpaceBeforeScript then - mathparameters.SpaceBeforeScript = mathparameters.SpaceAfterScript - end + if not mathparameters.PrimeRaisePercent then mathparameters.PrimeRaisePercent = 25 end + if not mathparameters.PrimeShiftUp then mathparameters.PrimeShiftUp = mathparameters.SuperscriptShiftUp end + if not mathparameters.PrimeBaselineDropMax then mathparameters.PrimeBaselineDropMax = mathparameters.SuperscriptBaselineDropMax end + if not mathparameters.PrimeShiftUpCramped then mathparameters.PrimeShiftUpCramped = mathparameters.SuperscriptShiftUpCramped end + if not mathparameters.PrimeSpaceAfter then mathparameters.PrimeSpaceAfter = 0 end + if not mathparameters.PrimeWidthPercent then mathparameters.PrimeWidthPercent = 50 end + if not mathparameters.SpaceBeforeScript then mathparameters.SpaceBeforeScript = mathparameters.SpaceAfterScript end + if not mathparameters.NoLimitSupFactor then mathparameters.NoLimitSupFactor = 0 end + if not mathparameters.NoLimitSubFactor then mathparameters.NoLimitSubFactor = 0 end + if not mathparameters.AccentTopShiftUp then mathparameters.AccentTopShiftUp = 0 end + if not mathparameters.AccentBottomShiftDown then mathparameters.AccentBottomShiftDown = 0 end + if not mathparameters.FlattenedAccentTopShiftUp then mathparameters.AccentTopShiftUp = 0 end + if not mathparameters.FlattenedAccentBottomShiftDown then mathparameters.AccentBottomShiftDown = 0 end + if not mathparameters.AccentBaseDepth then mathparameters.AccentBaseDepth = 0 end + if not mathparameters.AccentFlattenedBaseDepth then mathparameters.AccentFlattenedBaseDepth = 0 end + -- + -- we don't want to reset that each time .. but then we also can't show what the value was + -- + -- mathparameters.RadicalDegreeBefore = 0 + -- target.mathparameters = mathparameters end end @@ -77,6 +95,8 @@ local how = { RadicalDegreeBottomRaisePercent = "unscaled", NoLimitSupFactor = "unscaled", NoLimitSubFactor = "unscaled", + PrimeRaisePercent = "unscaled", + PrimeWidthPercent = "unscaled", } function mathematics.scaleparameters(target,original) @@ -122,12 +142,15 @@ function mathematics.checkprivateparameters(target,original) if parameters then local size = parameters.size if size then - if not mathparameters.FractionDelimiterSize then - mathparameters.FractionDelimiterSize = 1.01 * size - end - if not mathparameters.FractionDelimiterDisplayStyleSize then - mathparameters.FractionDelimiterDisplayStyleSize = 2.40 * size - end +-- if not mathparameters.FractionDelimiterSize then +-- mathparameters.FractionDelimiterSize = 1.01 * size +-- end +-- if not mathparameters.FractionDelimiterDisplayStyleSize then +-- mathparameters.FractionDelimiterDisplayStyleSize = 2.40 * size +-- end +-- if not mathparameters.PrimeSuperscriptSpace then +-- mathparameters.PrimeSuperscriptSpace = size / 20 +-- end elseif properties then report_math("invalid parameters in font %a",properties.fullname or "?") else @@ -149,34 +172,55 @@ function mathematics.overloadparameters(target,original) for i=1,#goodies do local goodie = goodies[i] local mathematics = goodie.mathematics - local parameters = mathematics and mathematics.parameters - if parameters then - if trace_defining then - report_math("overloading math parameters in %a @ %p",target.properties.fullname,target.parameters.size) - end - for name, value in next, parameters do - local tvalue = type(value) - if tvalue == "string" then - report_math("comment for math parameter %a: %s",name,value) - else + if mathematics then + local parameters = mathematics.parameters + local bigslots = mathematics.bigslots or mathematics.bigs + if parameters then + if trace_defining then + report_math("overloading math parameters in %a @ %p",target.properties.fullname,target.parameters.size) + end + for name, value in next, parameters do + local tvalue = type(value) local oldvalue = mathparameters[name] local newvalue = oldvalue - if oldvalue then - if tvalue == "number" then - newvalue = value - elseif tvalue == "function" then - newvalue = value(oldvalue,target,original) - elseif not tvalue then - newvalue = nil - end - if trace_defining and oldvalue ~= newvalue then - report_math("overloading math parameter %a: %S => %S",name,oldvalue,newvalue) - end - else - report_math("invalid math parameter %a",name) + if tvalue == "number" then + newvalue = value + elseif tvalue == "string" then + -- delay till all set + elseif tvalue == "function" then + newvalue = value(oldvalue,target,original) + elseif not tvalue then + newvalue = nil + end + if trace_defining and oldvalue ~= newvalue then + report_math("overloading math parameter %a: %S => %S",name,oldvalue or 0,newvalue) end mathparameters[name] = newvalue end + for name, value in next, parameters do + local tvalue = type(value) + if tvalue == "string" then + local newvalue = mathparameters[value] + -- if not newvalue then + -- local code = loadstring("return " .. value,"","t",mathparameters) + -- if type(code) == "function" then + -- local okay, v = pcall(code) + -- if okay then + -- newvalue = v + -- end + -- end + -- end + if newvalue then + -- split in number and string + mathparameters[name] = newvalue + elseif trace_defining then + report_math("ignoring math parameter %a: %S",name,value) + end + end + end + end + if bigslots then + target.bigslots = bigslots end end end @@ -208,34 +252,151 @@ end do local stepper = utilities.parsers.stepper + local count = 0 + + local splitter = lpeg.tsplitat(".") - local function adapt(target,original,targetcharacters,originalcharacters,k,v,compact,n) + local function adapt(list,target,original,targetcharacters,originalcharacters,k,v,compact,n) local character = targetcharacters[k] if character then - local width = character.width - local italic = character.italic - local offsetfactor = v[1] or 1 - local widthfactor = v[2] or 1 - local italicfactor = v[3] or 1 - if width then - character.advance = width -- so advance is oldwidth - character.xoffset = offsetfactor * width - character.width = widthfactor * width - end - if italic then - character.italic = italicfactor * italic - elseif width and italicfactor ~= 1 then - character.italic = italicfactor * width - end - if trace_tweaking then - report_tweak("adapting dimensions of %U ",target,original,k) - end - local smaller = originalcharacters[k].smaller - if compact and smaller and smaller ~= k then - adapt(target,original,targetcharacters,originalcharacters,smaller,v,compact,n+1) + if not character.tweaked then + local t = type(v) + if t == "number" then + v = list[v] + t = type(v) + end + if t == "table" then + local width = character.width + local height = character.height + local depth = character.depth + local italic = character.italic + local topaccent = character.topaccent + if #v > 0 then + local offsetfactor = v[1] + local widthfactor = v[2] + local italicfactor = v[3] + local anchorfactor = v[4] + if width then + character.advance = width -- so advance is oldwidth + character.xoffset = offsetfactor * width + character.width = widthfactor * width + end + if italic then + character.italic = italicfactor * italic + elseif width and italicfactor ~= 1 then + character.italic = italicfactor * width + end + if topaccent and topaccent > 0 then + if anchorfactor then + character.topaccent = anchorfactor * topaccent + elseif width then + character.topaccent = topaccent + (character.width - character.advance) / 2 + end + end + else + local widthfactor = v.width + local heightfactor = v.height + local depthfactor = v.depth + local italicfactor = v.italic + local anchorfactor = v.anchor + local advancefactor = v.advance + local xoffsetfactor = v.xoffset + local yoffsetfactor = v.yoffset + local scalefactor = v.scale + local total = (height or 0) + (depth or 0) + if scalefactor ~= 1 then + character.scale = scalefactor + end + if width and width ~= 0 then + if advancefactor then + character.advance = advancefactor * width + end + if widthfactor then + character.width = widthfactor * width + end + if xoffsetfactor then + character.xoffset = xoffsetfactor * width + end + end + if height and height ~= 0 then + if heightfactor then + character.height = heightfactor * height + end + end + if depth and depthfactor then + character.depth = depthfactor * depth + end + if yoffsetfactor then + character.yoffset = yoffsetfactor * total + end + if italic and italic ~= 0 and italicfactor then + character.italic = italicfactor * italic + end + if anchorfactor then + character.topaccent = anchorfactor * (topaccent or width) + end + end + if trace_tweaking then + report_tweak("adapting dimensions of %U ",target,original,k) + end + local smaller = originalcharacters[k].smaller + if compact and smaller and smaller ~= k then + adapt(list,target,original,targetcharacters,originalcharacters,smaller,v,compact,n+1) + end + count = count + 1 + else + report_mathtweak("invalid dimension entry %U",k) + end + character.tweaked = true + if v.all then + local nxt = character.next + if nxt then + adapt(list,target,original,targetcharacters,originalcharacters,nxt,v,compact,n) + else + local parts = character.hparts + if parts then + for i=1,#parts do + adapt(list,target,original,targetcharacters,originalcharacters,parts[i],v,compact,n) + end + end + end + end end else - report_math("no character %U",k) + report_tweak("no character %U",target,original,k) + end + end + + local function detail(characters,k) + if type(k) == "string" then + local t = lpeg.match(splitter,k) + local n = #t + if n > 0 then + local m = tonumber(t[1]) or tonumber(t[1],16) + if m then + local c = characters[m] + if c and n > 1 then + m = t[2] + if m == "parts" then + local nxt = c.next + while nxt do + c = characters[nxt] + nxt = c.next + end + c = c.hparts or c.vparts + if c and n > 2 then + m = tonumber(t[3]) + if m then + c = c[m] + if c then + return c.glyph + end + end + end + end + end + end + end end end @@ -245,14 +406,29 @@ do local targetcharacters = target.characters local originalcharacters = original.characters local compact = target.parameters.textscale and true or false - for k, v in next, list do + count = 0 + for k, v in sortedhash(list) do local t = type(k) if t == "number" then - adapt(target,original,targetcharacters,originalcharacters,k,v,compact,1) + adapt(list,target,original,targetcharacters,originalcharacters,k,v,compact,1) elseif t == "string" then - stepper(k,function(n) adapt(target,original,targetcharacters,originalcharacters,n,v,compact,1) end) + local d = detail(targetcharacters,k) + if d then + adapt(list,target,original,targetcharacters,originalcharacters,d,v,compact,1) + else + stepper(k,function(n) + adapt(list,target,original,targetcharacters,originalcharacters,n,v,compact,1) + end) + end + -- elseif t == "table" then + -- for i=1,#t do + -- adapt(list,target,original,targetcharacters,originalcharacters,t[i],v,compact,1) + -- end end end + if trace_tweaking and count > 0 then + report_mathtweak("%i dimensions adapted",count) + end end end @@ -411,6 +587,274 @@ do end +do + + function mathtweaks.fixanchors(target,original,parameters) + local factor = tonumber(parameters.factor) + if factor ~= 0 then + for k, v in next, target.characters do + local a = v.topaccent + if a and a > 0 then + v.topaccent = a * factor + end + end + end + end + +end + +do + + -- local list = { + -- [0x203E] = { factor = .4 }, -- overbar + -- [0x203E] = { factor = .7 }, -- underbar + -- [0x23DE] = { factor = .4 }, -- overbrace + -- [0x23DF] = { factor = .7 }, -- underbrace + -- [0x23DC] = { factor = .4 }, -- overparent + -- [0x23DD] = { factor = .7 }, -- underparent + -- [0x23B4] = { factor = .4 }, -- overbracket + -- [0x23B5] = { factor = .7 }, -- underbracket + -- } + + -- We can patch the dimensions in-place or we can use additional characters in + -- the private namespace. + + -- local addprivate = fonts.helpers.addprivate + -- local newnextglyph = addprivate(target,formatters["M-N-%H"](nextglyph),newnextdata) + + local over = { factor = "over" } + local under = { factor = "under" } + + local candidates = { + over = { + [0x203E] = over, -- overbar + [0x23DE] = over, -- overbrace + [0x23DC] = over, -- overparent + [0x23B4] = over, -- overbracket + }, + under = { + [0x23DF] = under, -- underbrace + [0x23DD] = under, -- underparent + [0x23B5] = under, -- underbracket + }, + accent = { + [0x0300] = over, -- widegrave + [0x0308] = over, -- wideddot + [0x0304] = over, -- widebar + [0x0301] = over, -- wideacute + [0x0302] = over, -- widehat + [0x030C] = over, -- widecheck + [0x0306] = over, -- widebreve + [0x0307] = over, -- widedot + [0x030A] = over, -- widering + [0x0303] = over, -- widetilde + [0x20DB] = over, -- widedddot + }, + } + + local function adapt(c,factor,baseheight,basedepth) + if not c.tweaked then + local height = c.height or 0 + local depth = c.depth or 0 + local yoffset = 0 + if factor == "over" then + local h = height - baseheight + yoffset = h - height + height = h + depth = depth - baseheight + elseif factor == "under" then + local d = depth - basedepth + yoffset = depth - d + depth = d + height = height - baseheight + else + if height > 0 then + local h = tonumber(factor) * height + yoffset = h - height + height = h + elseif depth > 0 then + local d = tonumber(factor) * depth + yoffset = depth - d + depth = d + end + end + c.yoffset = yoffset ~= 0 and yoffset or nil + c.height = height > 0 and height or nil + c.depth = depth > 0 and depth or nil + c.tweaked = true + end + end + + local function process(characters,list,baseheight,basedepth) + if list then + for k, v in sortedhash(list) do -- sort for tracing + local c = characters[k] + if c and not c.yoffset then + local factor = v.factor + if factor then + adapt(c,factor,baseheight,basedepth) + local nc = c.next + local nv = 0 + local ns = 0 + while nc do + local c = characters[nc] + if c then + adapt(c,factor,baseheight,basedepth) + nv = nv + 1 + nc = c.next + if not nc then + local hv = c.hparts + if hv then + for i=1,#hv do + local c = characters[hv[i].glyph] + if c then + adapt(c,factor,baseheight,basedepth) + ns = ns + 1 + end + end + end + break + end + else + break + end + end + if trace_tweaking then + report_tweak("adapting extensible (%i sizes, %i parts) %U",k,nv,ns) + end + end + end + end + end + end + + function mathtweaks.accentdimensions(target,original,parameters) + local list = parameters.list or { "over", "under" } + if list then + local characters = target.characters + local baseheight = target.mathparameters.AccentBaseHeight or 0 + local basedepth = target.mathparameters.AccentBaseDepth or 0 + for k, v in sortedhash(list) do -- sort for tracing + local t = type(v) + if t == "string" then + v = candidates[v] + t = type(v) + end + if t == "table" then + process(characters,v,baseheight,basedepth) + end + end + end + end + +end + +do + + -- function mathtweaks.addrules(target,original,parameters) + -- local characters = target.characters + -- local height = target.mathparameters.OverbarRuleThickness + -- local depth = target.mathparameters.UnderbarRuleThickness + -- local width = target.parameters.emwidth/2 + -- local step = 0.8 * width + -- characters[0x203E] = { -- over + -- width = width, + -- height = height, + -- depth = 0, + -- unicode = 0x203E, + -- commands = { { "rule", height, width } }, + -- hparts = { + -- { advance = width, ["end"] = step, glyph = 0x203E, start = 0 }, + -- { advance = width, ["end"] = 0, glyph = 0x203E, start = step, extender = 1 }, + -- } + -- } + -- characters[0x0332] = { -- under + -- width = width, + -- height = 0, + -- depth = depth, + -- yoffset = -depth, + -- unicode = 0x0332, + -- commands = { { "rule", height, width } }, + -- hparts = { + -- { advance = width, ["end"] = step, glyph = 0x0332, start = 0 }, + -- { advance = width, ["end"] = 0, glyph = 0x0332, start = step, extender = 1 }, + -- } + -- } + -- end + + function mathtweaks.addrules(target,original,parameters) + local characters = target.characters + local thickness = target.mathparameters.OverbarRuleThickness + local width = target.parameters.emwidth / 2 + local step = 0.8 * width + characters[0x203E] = { -- over + width = width, + height = thickness / 2, + depth = thickness / 2, + yoffset = - thickness / 2, + unicode = 0x203E, + commands = { { "rule", thickness, width } }, + hparts = { + { advance = width, ["end"] = step, glyph = 0x203E, start = 0 }, + { advance = width, ["end"] = 0, glyph = 0x203E, start = step, extender = 1 }, + } + } + -- + characters[0x0332] = characters[0x203E] + -- + -- lucida lacks them ... + -- + local addprivate = fonts.helpers.addprivate + -- + local half = thickness / 2 + local double = thickness * 2 + -- + if not characters[0x23B4] then + local tpiece = addprivate(target,"bracket-piece-top",{ + width = thickness, + height = half, + depth = double, + yoffset = - double, + commands = { { "rule", thickness * 2.5, thickness } }, + }) + characters[0x23B4] = { -- over + width = width, + height = half, + depth = double, + unicode = 0x23B4, + commands = { { "rule", thickness, width } }, + hparts = { + { advance = thickness, glyph = tpiece, ["end"] = 0, start = half }, + { advance = width, glyph = 0x203E, ["end"] = step, start = step, extender = 1 }, + { advance = thickness, glyph = tpiece, ["end"] = half, start = 0 }, + } + } + end + if not characters[0x23B5] then + local bpiece = addprivate(target,"bracket-piece-bottom",{ + width = thickness, + height = double, + depth = half, + yoffset = - half, + commands = { { "rule", thickness * 2.5, thickness } }, + }) + characters[0x23B5] = { -- over + width = width, + height = double, + depth = half, + unicode = 0x23B5, + commands = { { "rule", thickness, width } }, + hparts = { + { advance = thickness, glyph = bpiece, ["end"] = 0, start = half }, + { advance = width, glyph = 0x203E, ["end"] = step, start = step, extender = 1 }, + { advance = thickness, glyph = bpiece, ["end"] = half, start = 0 }, + } + } + end + end + +end + function mathtweaks.action(target,original,parameters) local action = parameters.action if type(action) == "function" then @@ -626,32 +1070,42 @@ do end +local apply_tweaks = true + +directives.register("math.applytweaks", function(v) + apply_tweaks = v; +end) + local function applytweaks(when,target,original) - local goodies = original.goodies - if goodies then - for i=1,#goodies do - local goodie = goodies[i] - local mathematics = goodie.mathematics - local tweaks = mathematics and mathematics.tweaks - if type(tweaks) == "table" then - tweaks = tweaks[when] + if apply_tweaks then + local goodies = original.goodies + if goodies then + for i=1,#goodies do + local goodie = goodies[i] + local mathematics = goodie.mathematics + local tweaks = mathematics and mathematics.tweaks if type(tweaks) == "table" then - if trace_defining then - report_math("tweaking math of %a @ %p (%s)",target.properties.fullname,target.parameters.size,when) - end - for i=1,#tweaks do - local tweak = tweaks[i] - local tvalue = type(tweak) - if type(tweak) == "table" then - local action = mathtweaks[tweak.tweak or ""] - if action then - action(target,original,tweak) + tweaks = tweaks[when] + if type(tweaks) == "table" then + if trace_defining then + report_math("tweaking math of %a @ %p (%s)",target.properties.fullname,target.parameters.size,when) + end + for i=1,#tweaks do + local tweak = tweaks[i] + local tvalue = type(tweak) + if type(tweak) == "table" then + local action = mathtweaks[tweak.tweak or ""] + if action then + action(target,original,tweak) + end end end end end end end + else + report_math("not tweaking math of %a @ %p (%s)",target.properties.fullname,target.parameters.size,when) end end @@ -669,10 +1123,10 @@ function mathematics.tweakaftercopyingfont(target,original) end end +sequencers.appendaction("mathparameters","system","mathematics.overloadparameters") sequencers.appendaction("mathparameters","system","mathematics.scaleparameters") sequencers.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") -- should go in lfg instead sequencers.appendaction("mathparameters","system","mathematics.checkprivateparameters") -- after scaling ! -sequencers.appendaction("mathparameters","system","mathematics.overloadparameters") sequencers.appendaction("beforecopyingcharacters","system","mathematics.tweakbeforecopyingfont") sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweakaftercopyingfont") @@ -683,16 +1137,11 @@ sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweakaft -- helpers -local setmetatableindex = table.setmetatableindex - -local getfontoffamily = tex.getfontoffamily +local getfontoffamily = tex.getfontoffamily -local fontcharacters = fonts.hashes.characters -local extensibles = utilities.storage.allocate() -fonts.hashes.extensibles = extensibles - -local chardata = characters.data -local extensibles = mathematics.extensibles +local fontcharacters = fonts.hashes.characters +local chardata = characters.data +local extensibles = mathematics.extensibles -- we use numbers at the tex end (otherwise we could stick to chars) @@ -722,15 +1171,15 @@ local function extensiblecode(font,unicode) if not char then return unknown end - if character.hvariants then - if character.vvariants then + if character.hparts then + if character.vparts then return { e_mixed, code, character } else local m = char.mathextensible local e = m and extensibles[m] return e and { e, code, character } or unknown end - elseif character.vvariants then + elseif character.vparts then local m = char.mathextensible local e = m and extensibles[m] return e and { e, code, character } or unknown @@ -772,19 +1221,19 @@ local function horizontalcode(family,unicode) local loffset = 0 local roffset = 0 if kind == e_left then - local charlist = data[3].hvariants + local charlist = data[3].hparts if charlist then local left = charlist[1] loffset = abs((left["start"] or 0) - (left["end"] or 0)) end elseif kind == e_right then - local charlist = data[3].hvariants + local charlist = data[3].hparts if charlist then local right = charlist[#charlist] roffset = abs((right["start"] or 0) - (right["end"] or 0)) end elseif kind == e_horizontal then - local charlist = data[3].hvariants + local charlist = data[3].hparts if charlist then local left = charlist[1] local right = charlist[#charlist] @@ -815,7 +1264,6 @@ interfaces.implement { -- can be public with two times "integerargument" end } - local stack = { } function mathematics.registerfallbackid(n,id,name) diff --git a/tex/context/base/mkxl/math-ali.mkxl b/tex/context/base/mkxl/math-ali.mkxl index 30f5c0524..6149d9be2 100644 --- a/tex/context/base/mkxl/math-ali.mkxl +++ b/tex/context/base/mkxl/math-ali.mkxl @@ -2196,6 +2196,25 @@ {\afterdisplayspace \endgroup} +%D Kind of new (February 2022): + +\installcorenamespace {maththreshold} + +\setupmathematics[\c!threshold=\zeropoint] + +\permanent\protected\def\installmaththreshold#1#2% + {\expandafter\gluespecdef\csname\??maththreshold#1\endcsname#2\relax} + +\installmaththreshold\v!none {\zeropoint} +\installmaththreshold\v!small {3\emwidth plus 0.50\emwidth minus 0.25\emwidth} +\installmaththreshold\v!medium{4\emwidth plus 0.75\emwidth minus 0.50\emwidth} +\installmaththreshold\v!big {5\emwidth plus 1.00\emwidth minus 0.75\emwidth} + +\appendtoks + \edef\p_threshold{\mathematicsparameter\c!threshold}% + \maththreshold\ifcsname\??maththreshold\p_threshold\endcsname\lastnamedcs\else\p_threshold\fi\relax +\to \everymath % \everyemathematics + \protect \endinput % \placeformula \startformula[-] \startmatrix diff --git a/tex/context/base/mkxl/math-def.mkxl b/tex/context/base/mkxl/math-def.mkxl index c7cf65270..53165a30c 100644 --- a/tex/context/base/mkxl/math-def.mkxl +++ b/tex/context/base/mkxl/math-def.mkxl @@ -26,8 +26,7 @@ \activatemathcharacters -%D The \mfunction macro is an alternative for \hbox with a controlable font -%D switch. +%D The \mfunction macro is an alternative for \hbox with a controlable font switch. \definemathcommand [arccos] [nolop] {\mfunctionlabeltext{arccos}} \definemathcommand [arcsin] [nolop] {\mfunctionlabeltext{arcsin}} @@ -104,15 +103,14 @@ %D equalscoloncolon, coloncolonapprox, approxcoloncolon, %D colonsim, simcoloncolon} %D -%D The following colon related definitions are provided by Aditya -%D Mahajan who derived them from \type {mathtools.sty} and \type -%D {colonequals.sty}. This will be redone as part of the overhaul -%D and font updates. +%D The following colon related definitions are provided by Aditya Mahajan who +%D derived them from \type {mathtools.sty} and \type {colonequals.sty}. This will be +%D redone as part of the overhaul and font updates. %D -%D In $a := b$ the colon is not vertically centered with the equal -%D to. Also the distance between colon and equal to is a bit large. -%D So, we define a vertically centered colon \tex {centercolon} and -%D a few macros for colon and double colon relation symbols. +%D In $a := b$ the colon is not vertically centered with the equal to. Also the +%D distance between colon and equal to is a bit large. So, we define a vertically +%D centered colon \tex {centercolon} and a few macros for colon and double colon +%D relation symbols. %D %D \startlines %D \formula {A \centercolon B} @@ -140,8 +138,8 @@ \pushoverloadmode -\definemathcommand [colonsep] {\mkern-1.2mu} -\definemathcommand [doublecolonsep] {\mkern-0.9mu} +\definemathcommand [colonsep] {\mkern-1.2mu} +\definemathcommand [doublecolonsep] {\mkern-0.9mu} \definemathcommand [centercolon] [rel] {\mathstylevcenteredhbox\colon} \definemathcommand [colonminus] [rel] {\centercolon\colonsep\mathrel{-}} diff --git a/tex/context/base/mkxl/math-del.mkxl b/tex/context/base/mkxl/math-del.mkxl index 8f2596359..47febc180 100644 --- a/tex/context/base/mkxl/math-del.mkxl +++ b/tex/context/base/mkxl/math-del.mkxl @@ -66,7 +66,7 @@ % A new experiment: % Hm, we already have \definemathextensible so we need to preserve that one. We now -% use \definemathdelimiter. +% use \definemathdelimiter. This mechanism will probably disappear so don't use it! \installcorenamespace {mathdelimiter} @@ -139,7 +139,7 @@ % \ruledhbox{$\int f\frac{1}{2}$} % \stoplines -\permanent\protected\def\autointegral#1#2#3% +\permanent\protected\def\autointegral#1#2#3% this one is obsolete now {\ifmmode \setbox\nextbox\mathstylehbox{#3}% \scratchdimen\ifdim\nextboxht>\nextboxdp\nextboxht\else\nextboxdp\fi diff --git a/tex/context/base/mkxl/math-dim.lmt b/tex/context/base/mkxl/math-dim.lmt index 3b88b0b0b..0dd348184 100644 --- a/tex/context/base/mkxl/math-dim.lmt +++ b/tex/context/base/mkxl/math-dim.lmt @@ -104,14 +104,14 @@ local defaults = { } local styles = { + 'display_style', 'cramped_display_style', - 'cramped_script_script_style', - 'cramped_script_style', + 'text_style', 'cramped_text_style', - 'display_style', - 'script_script_style', 'script_style', - 'text_style', + 'cramped_script_style', + 'script_script_style', + 'cramped_script_script_style', } for k, v in next, defaults do diff --git a/tex/context/base/mkxl/math-fbk.lmt b/tex/context/base/mkxl/math-fbk.lmt index 80b99d83b..c219bb34f 100644 --- a/tex/context/base/mkxl/math-fbk.lmt +++ b/tex/context/base/mkxl/math-fbk.lmt @@ -246,160 +246,164 @@ virtualcharacters[0xFE352] = function(data) end end -local function accent_to_extensible(target,newchr,original,oldchr,height,depth,swap,offset,unicode) - local characters = target.characters - local olddata = characters[oldchr] - -- brrr ... pagella has only next - if olddata and not olddata.commands then -- not: and olddata.width > 0 - local addprivate = fonts.helpers.addprivate - if swap then - swap = characters[swap] - height = swap.depth or 0 - depth = 0 - else - height = height or 0 - depth = depth or 0 - end - local oldheight = olddata.height or 0 - local correction = swap and - downcommand[oldheight - height] - or downcommand[oldheight + (offset or 0)] - local newdata = { - commands = { correction, charcommand[oldchr] }, - width = olddata.width, - height = height, - depth = depth, - unicode = unicode, - } - local glyphdata = newdata - local nextglyph = olddata.next - while nextglyph do - local oldnextdata = characters[nextglyph] - if oldnextdata then - local newnextdata = { - commands = { correction, charcommand[nextglyph] }, - width = oldnextdata.width, - height = height, - depth = depth, - } - local newnextglyph = addprivate(target,formatters["M-N-%H"](nextglyph),newnextdata) - newdata.next = newnextglyph - local nextnextglyph = oldnextdata.next - if nextnextglyph == nextglyph then - break - else - olddata = oldnextdata - newdata = newnextdata - nextglyph = nextnextglyph - end - else - report_fallbacks("error in fallback: no valid next, slot %X",nextglyph) - break - end - end - local hv = olddata.hvariants - if hv then - hv = fastcopy(hv) - newdata.hvariants = hv - for i=1,#hv do - local hvi = hv[i] - local oldglyph = hvi.glyph - local olddata = characters[oldglyph] - if olddata then - local newdata = { - commands = { correction, charcommand[oldglyph] }, - width = olddata.width, - height = height, - depth = depth, - } - hvi.glyph = addprivate(target,formatters["M-H-%H"](oldglyph),newdata) - else - report_fallbacks("error in fallback: no valid hvariants, slot %X, index %i",oldglyph,i) - end - end - end - return glyphdata, true - else - return olddata, false - end -end - -virtualcharacters[0x203E] = function(data) - local target = data.target - local height = 0 - local depth = 0 - -- local mathparameters = target.mathparameters - -- if mathparameters then - -- height = mathparameters.OverbarVerticalGap - -- depth = mathparameters.UnderbarVerticalGap - -- else - height = target.parameters.xheight/4 - depth = height - -- end - return accent_to_extensible(target,0x203E,data.original,0x0305,height,depth,nil,nil,0x203E) -end - --- virtualcharacters[0xFE33E] = virtualcharacters[0x203E] -- convenient --- virtualcharacters[0xFE33F] = virtualcharacters[0x203E] -- convenient - -virtualcharacters[0xFE33E] = function(data) - local target = data.target - local height = 0 - local depth = target.parameters.xheight/4 - return accent_to_extensible(target,0xFE33E,data.original,0x0305,height,depth,nil,nil,0x203E) -end - -virtualcharacters[0xFE33F] = function(data) - local target = data.target - local height = target.parameters.xheight/8 - local depth = height - return accent_to_extensible(target,0xFE33F,data.original,0x0305,height,depth,nil,nil,0x203E) -end - -local function smashed(data,unicode,swap,private) - local target = data.target - local original = data.original - local chardata = target.characters[unicode] - if chardata and chardata.height > target.parameters.xheight then - return accent_to_extensible(target,private,original,unicode,0,0,swap,nil,unicode) - else - return original.characters[unicode] - end -end - -addextra(0xFE3DE) -- EXTENSIBLE OF 0x03DE -addextra(0xFE3DC) -- EXTENSIBLE OF 0x03DC -addextra(0xFE3B4) -- EXTENSIBLE OF 0x03B4 - -virtualcharacters[0xFE3DE] = function(data) return smashed(data,0x23DE,0x23DF,0xFE3DE) end -virtualcharacters[0xFE3DC] = function(data) return smashed(data,0x23DC,0x23DD,0xFE3DC) end -virtualcharacters[0xFE3B4] = function(data) return smashed(data,0x23B4,0x23B5,0xFE3B4) end - -addextra(0xFE3DF) -- EXTENSIBLE OF 0x03DF -addextra(0xFE3DD) -- EXTENSIBLE OF 0x03DD -addextra(0xFE3B5) -- EXTENSIBLE OF 0x03B5 - -virtualcharacters[0xFE3DF] = function(data) local c = data.target.characters[0x23DF] if c then c.unicode = 0x23DF return c end end -virtualcharacters[0xFE3DD] = function(data) local c = data.target.characters[0x23DD] if c then c.unicode = 0x23DD return c end end -virtualcharacters[0xFE3B5] = function(data) local c = data.target.characters[0x23B5] if c then c.unicode = 0x23B5 return c end end - --- todo: add some more .. numbers might change - -addextra(0xFE302) -- EXTENSIBLE OF 0x0302 -addextra(0xFE303) -- EXTENSIBLE OF 0x0303 - -local function smashed(data,unicode,private) - local target = data.target - local height = target.parameters.xheight / 2 - local c, done = accent_to_extensible(target,private,data.original,unicode,height,0,nil,-height,unicode) - if done then - c.topaccent = nil -- or maybe also all the others - end - return c -end +--------------------------------------------------------------------------------- +-- these are moved to math-act.lmt (keep this code) +--------------------------------------------------------------------------------- -virtualcharacters[0xFE302] = function(data) return smashed(data,0x0302,0xFE302) end -virtualcharacters[0xFE303] = function(data) return smashed(data,0x0303,0xFE303) end +-- local function accent_to_extensible(target,newchr,original,oldchr,height,depth,swap,offset,unicode) +-- local characters = target.characters +-- local olddata = characters[oldchr] +-- -- brrr ... pagella has only next +-- if olddata and not olddata.commands then -- not: and olddata.width > 0 +-- local addprivate = fonts.helpers.addprivate +-- if swap then +-- swap = characters[swap] +-- height = swap.depth or 0 +-- depth = 0 +-- else +-- height = height or 0 +-- depth = depth or 0 +-- end +-- local oldheight = olddata.height or 0 +-- local correction = swap and +-- downcommand[oldheight - height] +-- or downcommand[oldheight + (offset or 0)] +-- local newdata = { +-- commands = { correction, charcommand[oldchr] }, +-- width = olddata.width, +-- height = height, +-- depth = depth, +-- unicode = unicode, +-- } +-- local glyphdata = newdata +-- local nextglyph = olddata.next +-- while nextglyph do +-- local oldnextdata = characters[nextglyph] +-- if oldnextdata then +-- local newnextdata = { +-- commands = { correction, charcommand[nextglyph] }, +-- width = oldnextdata.width, +-- height = height, +-- depth = depth, +-- } +-- local newnextglyph = addprivate(target,formatters["M-N-%H"](nextglyph),newnextdata) +-- newdata.next = newnextglyph +-- local nextnextglyph = oldnextdata.next +-- if nextnextglyph == nextglyph then +-- break +-- else +-- olddata = oldnextdata +-- newdata = newnextdata +-- nextglyph = nextnextglyph +-- end +-- else +-- report_fallbacks("error in fallback: no valid next, slot %X",nextglyph) +-- break +-- end +-- end +-- local hv = olddata.hparts +-- if hv then +-- hv = fastcopy(hv) +-- newdata.hparts = hv +-- for i=1,#hv do +-- local hvi = hv[i] +-- local oldglyph = hvi.glyph +-- local olddata = characters[oldglyph] +-- if olddata then +-- local newdata = { +-- commands = { correction, charcommand[oldglyph] }, +-- width = olddata.width, +-- height = height, +-- depth = depth, +-- } +-- hvi.glyph = addprivate(target,formatters["M-H-%H"](oldglyph),newdata) +-- else +-- report_fallbacks("error in fallback: no valid hparts, slot %X, index %i",oldglyph,i) +-- end +-- end +-- end +-- return glyphdata, true +-- else +-- return olddata, false +-- end +-- end +-- +-- virtualcharacters[0x203E] = function(data) -- overbar +-- local target = data.target +-- local height = 0 +-- local depth = 0 +-- -- local mathparameters = target.mathparameters +-- -- if mathparameters then +-- -- height = mathparameters.OverbarVerticalGap +-- -- depth = mathparameters.UnderbarVerticalGap +-- -- else +-- height = target.parameters.xheight/4 +-- depth = height +-- -- end +-- return accent_to_extensible(target,0x203E,data.original,0x0305,height,depth,nil,nil,0x203E) +-- end +-- +-- -- virtualcharacters[0xFE33E] = virtualcharacters[0x203E] -- convenient +-- -- virtualcharacters[0xFE33F] = virtualcharacters[0x203E] -- convenient +-- +-- virtualcharacters[0xFE33E] = function(data) +-- local target = data.target +-- local height = 0 +-- local depth = target.parameters.xheight/4 +-- return accent_to_extensible(target,0xFE33E,data.original,0x0305,height,depth,nil,nil,0x203E) +-- end +-- +-- virtualcharacters[0xFE33F] = function(data) +-- local target = data.target +-- local height = target.parameters.xheight/8 +-- local depth = height +-- return accent_to_extensible(target,0xFE33F,data.original,0x0305,height,depth,nil,nil,0x203E) +-- end +-- +-- local function smashed(data,unicode,swap,private) +-- local target = data.target +-- local original = data.original +-- local chardata = target.characters[unicode] +-- if chardata and chardata.height > target.parameters.xheight then +-- return accent_to_extensible(target,private,original,unicode,0,0,swap,nil,unicode) +-- else +-- return original.characters[unicode] +-- end +-- end +-- +-- addextra(0xFE3DE) -- EXTENSIBLE OF 0x03DE : overbrace +-- addextra(0xFE3DC) -- EXTENSIBLE OF 0x03DC : overparent +-- addextra(0xFE3B4) -- EXTENSIBLE OF 0x03B4 : overbracket +-- +-- virtualcharacters[0xFE3DE] = function(data) return smashed(data,0x23DE,0x23DF,0xFE3DE) end +-- virtualcharacters[0xFE3DC] = function(data) return smashed(data,0x23DC,0x23DD,0xFE3DC) end +-- virtualcharacters[0xFE3B4] = function(data) return smashed(data,0x23B4,0x23B5,0xFE3B4) end +-- +-- addextra(0xFE3DF) -- EXTENSIBLE OF 0x03DF +-- addextra(0xFE3DD) -- EXTENSIBLE OF 0x03DD +-- addextra(0xFE3B5) -- EXTENSIBLE OF 0x03B5 +-- +-- virtualcharacters[0xFE3DF] = function(data) local c = data.target.characters[0x23DF] if c then c.unicode = 0x23DF return c end end +-- virtualcharacters[0xFE3DD] = function(data) local c = data.target.characters[0x23DD] if c then c.unicode = 0x23DD return c end end +-- virtualcharacters[0xFE3B5] = function(data) local c = data.target.characters[0x23B5] if c then c.unicode = 0x23B5 return c end end +-- +-- -- todo: add some more .. numbers might change +-- +-- addextra(0xFE302) -- EXTENSIBLE OF 0x0302 +-- addextra(0xFE303) -- EXTENSIBLE OF 0x0303 +-- +-- local function smashed(data,unicode,private) +-- local target = data.target +-- local height = target.parameters.xheight / 2 +-- local c, done = accent_to_extensible(target,private,data.original,unicode,height,0,nil,-height,unicode) +-- if done then +-- c.topaccent = nil -- or maybe also all the others +-- end +-- return c +-- end +-- +-- virtualcharacters[0xFE302] = function(data) return smashed(data,0x0302,0xFE302) end +-- virtualcharacters[0xFE303] = function(data) return smashed(data,0x0303,0xFE303) end --------------------------------------------------------------------------------- -- these are moved to math-act.lmt @@ -717,7 +721,7 @@ virtualcharacters[0x305] = function(data) height = height, depth = depth, commands = { { "rule", height, width } }, - hvariants = { + hparts = { { advance = width, ["end"] = used, diff --git a/tex/context/base/mkxl/math-fen.mkxl b/tex/context/base/mkxl/math-fen.mkxl index b8347eb66..08891286e 100644 --- a/tex/context/base/mkxl/math-fen.mkxl +++ b/tex/context/base/mkxl/math-fen.mkxl @@ -58,13 +58,19 @@ \c!color=, \c!command=, \c!mathclass=, + \c!leftsource=\zerocount, + \c!middlesource=\zerocount, + \c!rightsource=\mathfenceparameter\c!source, + \c!source=\zerocount, + \c!height=\zeropoint, + \c!depth=\zeropoint, \c!factor=\v!auto] \appendtoks \edef\p_command{\mathfenceparameter\c!command}% \ifx\p_command\v!yes % \instance - \protected\edefcsname\currentmathfence\endcsname{\math_fenced_fenced[\currentmathfence]}% + \protected\edefcsname\currentmathfence\endcsname{\math_fenced_fenced{\currentmathfence}}% \fi \to \everydefinemathfence @@ -87,9 +93,13 @@ %D $ a + \fenced[bar] {\frac {b} {c}} + d $ %D \stoptyping +% todo : class -> number + \newconditional\c_math_fenced_mirror \settrue \c_math_fenced_mirror \newconditional\c_math_fenced_sized \setfalse\c_math_fenced_sized +\newcount\c_math_fence_nesting + \installcorenamespace {mathfencesize} \defcsname\??mathfencesize big\endcsname{1} @@ -97,125 +107,143 @@ \defcsname\??mathfencesize bigg\endcsname{3} \defcsname\??mathfencesize Bigg\endcsname{4} +\let\math_fenced_trace\donothing + \def\math_fenced_force_size#1#2% {\c_attr_mathsize\numexpr #1*\plushundred +\ifcsname\??mathfencesize#2\endcsname\lastnamedcs\else#2\fi \relax} -\protected\def\math_fenced_inject#1#2#3#4% - {\ifx#1\empty - #2.% +\def\math_fenced_common_factor_none + {\math_fenced_force_size\bigmathdelimitervariant\c_math_fence_nesting\relax + \Uvextensible + \s!axis + \s!exact} + +\def\math_fenced_common_factor_fixed + {\Uvextensible + \s!axis + \s!exact} + +\def\math_fenced_common_factor_unknown + {\scratchdimen\dimexpr\p_factor\bodyfontsize/2\relax + \Uvextensible + \s!height\scratchdimen + \s!depth\scratchdimen + \s!axis + \s!exact} + +\def\math_fenced_common_factor_force + {\Uvextensible + \s!height\mathfenceparameter\c!height + \s!depth\mathfenceparameter\c!depth + \s!axis + \s!exact} + +\permanent\def\math_fenced_common#1#2#3#4% \Uwhatever class symbol source + {\ifconditional\c_math_fenced_sized + \orelse\ifconditional\c_math_fenced_level_mode + \ifnum#2=\mathopencode + % \hpack{\infofont<L:\number\c_math_fenced_level:\number\c_attr_mathsize>}% + \integerdef\c_math_fenced_stack\c_attr_mathsize + \push_macro_c_math_fenced_stack + \orelse\ifnum#2=\mathclosecode + \pop_macro_c_math_fenced_stack + \c_attr_mathsize\c_math_fenced_stack + % \hpack{\infofont<R:\number\c_math_fenced_level:\number\c_attr_mathsize>}% + \fi + \fi + \edef\p_fence{#3}% + \ifempty\p_fence + #1.\relax \else + \edef\p_factor {\mathfenceparameter\c!factor}% + \edef\p_size {\mathfenceparameter\c!size}% \edef\p_mathclass{\mathfenceparameter\c!mathclass}% - \ifconditional\c_math_fenced_sized - \let\p_factor\v!fixed - \else - \edef\p_factor{\mathfenceparameter\c!factor}% - \fi - \ifempty\p_factor - \ifempty\p_mathclass - #2% + \ifnum\c_math_fenced_level>\zerocount + \math_fenced_common_factor_fixed + \orelse\ifconditional\c_math_fenced_sized + \math_fenced_common_factor_fixed + \orelse\ifempty\p_factor + \ifconditional\c_math_fenced_level_mode + \Uvextensible \else - #3% - \s!class\p_mathclass + #1% \Uleft \Umiddle \Uleft \fi \orelse\ifx\p_factor\v!auto - \ifempty\p_mathclass - #2% + \ifconditional\c_math_fenced_level_mode + \Uvextensible \else - #3% - \s!class\p_mathclass + #1% \Uleft \Umiddle \Uleft \fi \orelse\ifx\p_factor\v!none - #3% - \s!height\zeropoint % redundant with "exact" - \s!depth\zeropoint % redundant with "exact" - \ifempty\p_mathclass\else - \s!class\p_mathclass - \fi - \s!axis - \s!exact % new - % #2% + \math_fenced_common_factor_none + \orelse\ifx\p_factor\v!fixed + \math_fenced_common_factor_fixed + \orelse\ifx\p_factor\v!force + \math_fenced_common_factor_force \else - %\scratchdimen\ifx\p_factor\v!fixed\scaledpoint\else\dimexpr\p_factor\bodyfontsize/2\relax\fi - \scratchdimen\ifx\p_factor\v!fixed\zeropoint\else\dimexpr\p_factor\bodyfontsize/2\relax\fi - #3% - \s!height\scratchdimen - \s!depth\scratchdimen - \ifempty\p_mathclass\else - \s!class\p_mathclass - \fi - \s!axis - \s!exact + \math_fenced_common_factor_unknown + \fi + \usedcolorparameterattributes{\mathfenceparameter\c!color}% + \s!class\ifempty\p_mathclass#2\else\p_mathclass\fi + \s!source\numexpr\namedboxanchor{\mathfenceparameter#4}\relax + \math_fenced_trace + \Udelimiter#2\fam\p_fence\relax + \fi + % we could use \s!attr \c_math_fenced_stack here + \ifconditional\c_math_fenced_sized + \orelse\ifcase\c_math_fenced_level + \c_attr_mathsize\attributeunsetvalue + \fi} + +\def\math_fenced_left + {\advance\c_math_fence_nesting\plusone + \math_fenced_common\Uleft\mathopencode\math_fenced_p_left\c!leftsource} + +\def\math_fenced_middle + {\math_fenced_common\Umiddle\mathmiddlecode\math_fenced_p_middle\c!middlesource} + +\def\math_fenced_right + {\math_fenced_common\Uright\mathclosecode\math_fenced_p_right\c!rightsource + \advance\c_math_fence_nesting\minusone} + +\def\math_fenced_p_left + {\ifconditional\c_math_fenced_mirror + \ifconditional\c_math_right_to_left + \mathfenceparameter\c!right + \else + \mathfenceparameter\c!left \fi - \Udelimiter#4\fam#1\relax + \else + \mathfenceparameter\c!left \fi} -\permanent\def\math_fenced_left - {\edef\p_left - {\ifconditional\c_math_fenced_mirror - \ifconditional\c_math_right_to_left - \mathfenceparameter\c!right - \else - \mathfenceparameter\c!left - \fi - \else - \mathfenceparameter\c!left - \fi}% - \math_fenced_color_push - \math_fenced_inject\p_left\normalleft\Uleft\plusfour - \math_fenced_color_pop} - -\permanent\def\math_fenced_middle - {\edef\p_middle{\mathfenceparameter\c!middle}% - \mskip\thinmuskip - \math_fenced_color_push - \math_fenced_inject\p_middle\normalmiddle\Umiddle\plusfour - \math_fenced_color_pop - \mskip\thinmuskip} - -\permanent\def\math_fenced_right - {\edef\p_right - {\ifconditional\c_math_fenced_mirror - \ifconditional\c_math_right_to_left - \mathfenceparameter\c!left - \else - \mathfenceparameter\c!right - \fi - \else - \mathfenceparameter\c!right - \fi}% - \math_fenced_color_push - \math_fenced_inject\p_right\normalright\Uright\plusfive - \math_fenced_color_pop} - -\def\math_fenced_color_do_push{\pushcolor[\p_math_fenced_color]} -\let\math_fenced_color_do_pop \popcolor - -\let\math_fenced_color_push\donothing -\let\math_fenced_color_pop \donothing +\def\math_fenced_p_middle + {\mathfenceparameter\c!middle}% + +\def\math_fenced_p_right + {\ifconditional\c_math_fenced_mirror + \ifconditional\c_math_right_to_left + \mathfenceparameter\c!left + \else + \mathfenceparameter\c!right + \fi + \else + \mathfenceparameter\c!right + \fi} \aliased\let\fence \relax \aliased\let\fenced\relax -\newcount\c_math_fenced_nesting - \protected\def\math_fenced_fenced_common {\startusemathstyleparameter\mathfenceparameter\c!mathstyle - \enforced\let\fence\math_fenced_middle - \edef\p_math_fenced_color{\mathfenceparameter\c!color}% - \ifempty\p_math_fenced_color - \let\math_fenced_color_push\donothing - \let\math_fenced_color_pop \donothing - \else - \let\math_fenced_color_push\math_fenced_color_do_push - \let\math_fenced_color_pop \math_fenced_color_do_pop - \fi} + \enforced\let\fence\math_fenced_middle} \protected\def\math_fenced_fenced_start#1% - {\advance\c_math_fenced_nesting\plusone - \begingroup + {\begingroup + %{\beginmathgroup \edef\currentmathfence{#1}% \math_fenced_fenced_common \math_fenced_left} @@ -224,15 +252,19 @@ {\edef\currentmathfence{#1}% \math_fenced_right \stopusemathstyleparameter - \endgroup - \advance\c_math_fenced_nesting\minusone} + \endgroup} + %\endmathgroup} -\tolerant\protected\def\math_fenced_fenced[#1]#*[#2]% - {\advance\c_math_fenced_nesting\plusone - \begingroup - \edef\currentmathfence{#1}% +\installlocalcurrenthandler \??mathfences {mathfence} + +\tolerant\protected\def\math_fenced_fenced#1#*[#2]% + {\begingroup + %{\beginmathgroup + \setlocalmathfencecurrent{#1}% \edef\currentmathfence{#1}% % under test: + \setfalse\c_math_fenced_level_mode \c_attr_mathsize\attributeunsetvalue + % \letmathfenceparameter\c!size\empty \letmathfenceparameter\c!factor\v!auto % so far @@ -250,8 +282,8 @@ \protected\def\math_fenced_fenced_indeed_finish {\stopusemathstyleparameter - \endgroup - \advance\c_math_fenced_nesting\minusone} + \endgroup} + %\endmathgroup} \protected\def\math_fenced_fenced_indeed_fixed#1% {\math_fenced_force_size\bigmathdelimitervariant\p_size @@ -272,10 +304,81 @@ \math_fenced_right \math_fenced_fenced_indeed_finish} +\protected\def\math_fenced_direct[#1]% + {\math_fenced_fenced{#1}} + \appendtoks - \enforced\let\fenced\math_fenced_fenced + \enforced\let\fenced\math_fenced_direct \to \everymathematics +%D This is new: +%D +%D \starttyping +%D $ \F0 \left( x + \F1 \left( x \right) + x \right) $ +%D $ +%D \F0 \left( x + \F1 \left( x + \F2 \left( x + \F3 \left( x + \F4 \left( x + +%D 2 +%D + x \right) + x \right) + x \right) + x \right) + x \right) +%D $ +%D $ \F1 \left( x + \F1 \left( x \right) + x \right) $ +%D $ \F3 \left( x + \F1 \left( x \right) + x \right) $ +%D $ \F1 \left( x + \F4 \left( x \right) + x \right) $ +%D $ \F4 \left( x + \F- \left( x \right) + x \right) $ +%D $ \F4 +%D \left( 1 + +%D \F- \left( 2 + +%D \F* \left( 3 + +%D 4 +%D \right) +%D + 5 + +%D \F- \left( 6 + +%D 7 +%D \right) +%D \right) +%D + 8 +%D \right) +%D $ +%D \stoptyping +%D +%D \starttyping +%D \startTEXpage[offset=1dk,width=20dk] +%D \ruledhbox{$ \F3 \left( 1 + \F2 \left( a + b \right) + \left( a + b \right) \right) $}\par +%D \ruledhbox{$ \F3 \left( 1 + \F0 \left( a + b \right) \right) $}\par +%D \ruledhbox{$ \F3 \left( 1 + \F= \left( a + b \right) \right) $}\par +%D \ruledhbox{$ \F4 \left( 1 + \fenced[parenthesis]{a + b} \right) $}\par +%D \ruledhbox{$ \F3 \left( 1 + \F- \left( a + b \right) \right) $}\par +%D \ruledhbox{$ \left( \frac{1}{1+x} \right) $}\par +%D \ruledhbox{$ \left( \frac{1}{1+x} \right) $}\par +%D \stopTEXpage +%D \stoptyping + +\newcount \c_math_fenced_level +\newconditional\c_math_fenced_level_mode + +\integerdef\c_math_fenced_stack \zerocount + +\installmacrostack \c_math_fenced_stack + +\installcorenamespace{fencelevels} +\installcorenamespace{fencestack} + +\defcsname\??fencelevels+\endcsname{\advance\c_math_fenced_level\plusone } +\defcsname\??fencelevels-\endcsname{\advance\c_math_fenced_level\minusone } +\defcsname\??fencelevels=\endcsname {\c_math_fenced_level\zerocount} + +\letcsname\??fencelevels*\endcsname\donothing + +\permanent\protected\def\F#1% + {\settrue\c_math_fenced_level_mode + \ifchknum#1\or + \c_math_fenced_level#1\relax + \orelse\ifcsname\??fencelevels#1\endcsname + \lastnamedcs + \else + \c_math_fenced_level\zerocount + \fi + \math_fenced_force_size\bigmathdelimitervariant\c_math_fenced_level\relax} + % integral experiment (but no scripts) % % \protected\def\math_fenced_fenced_simple#1% @@ -420,7 +523,7 @@ \popoverloadmode -\let\leftorright\relax +% \let\leftorright\relax \newconditional\c_math_fenced_done \newconditional\c_math_fenced_unknown \settrue\c_math_fenced_unknown @@ -620,12 +723,6 @@ %D As we have overloaded \type {\left} and \type {\right} we also need a more %D clever version of the following: -% methods: -% -% 1: none -% 2: lua -% 3: tex - % variants: % % 1: step 1 @@ -633,85 +730,35 @@ % 3: htdp * 1.33^n % 4: size * 1.33^n -\setnewconstant\bigmathdelimitermethod \plustwo % \plusone \setnewconstant\bigmathdelimitervariant\plusthree \appendtoks - \bigmathdelimitermethod \mathfenceparameter\c!method\relax - \bigmathdelimitervariant\mathfenceparameter\c!alternative\relax + \bigmathdelimitervariant\mathfenceparameter\c!alternative\relax % controls lua \to \everysetupmathfence -\setupmathfence[\c!method=1,\c!alternative=1] +\setupmathfence[\c!alternative=1] % or 5 -% \protected\def\plainbigdelimiters % traditional method -% {\bigmathdelimitermethod\plustwo} -% -% \plainbigdelimiters % is default for the moment but not so nice - -\installcorenamespace{mathbig} +\permanent\protected\def\choosemathbig + {\mathortext\math_choosemathbig_math\math_choosemathbig_text} -\defcsname\??mathbig1\endcsname{0.85} -\defcsname\??mathbig2\endcsname{1.15} -\defcsname\??mathbig3\endcsname{1.45} -\defcsname\??mathbig4\endcsname{1.75} +\protected\def\math_choosemathbig_math#1#2% so we accept \big{||} as well + {\math_fenced_force_size\bigmathdelimitervariant{#1}\relax + \Uvextensible#2\relax + \c_attr_mathsize\attributeunsetvalue} -\permanent\protected\def\choosemathbig#1#2% so we accept \big{||} as well - {{\naturalhbox\bgroup +\protected\def\math_choosemathbig_text#1#2% so we accept \big{||} as well + {\naturalhbox\bgroup \startimath - \ifcase\bigmathdelimitermethod - \math_fenced_step#2\relax - \or - \math_fenced_force_size\bigmathdelimitervariant{#1}\relax - \math_fenced_step#2\relax - \else - \math_fenced_step#2{\vpack to\csname\??mathbig#1\endcsname\bodyfontsize{}}% - \fi - \nulldelimiterspace\zeropoint\relax + \math_choosemathbig_math{#1}{#2}% + \nulldelimiterspace\zeropoint \mathsurround\zeropoint \stopimath - \egroup}} - -% needs testing: -% -% \protected\def\choosemathbig#1#2% so we accept \big{||} as well -% {{\naturalhbox\bgroup -% \startimath -% \ifcase\bigmathdelimitermethod -% \Uvextensible#2\relax -% \or -% \math_fenced_force_size\bigmathdelimitervariant{#1}\relax -% \Uvextensible#2\relax -% \else -% \scratchdimen.5\dimexpr\csname\??mathbig\number#1\endcsname\bodyfontsize+1.1\exheight\relax -% \Uvextensible\s!axis \s!depth \scratchdimen \s!height \scratchdimen #2\relax -% \fi -% \nulldelimiterspace\zeropoint\relax -% \mathsurround\zeropoint -% \stopimath -% \egroup}} - -\def\math_fenced_step#1#2% - {\setfalse\c_math_fenced_unknown - \setfalse\c_math_fenced_done - \left#1\relax - \ifconditional\c_math_fenced_done - #2% - \right.\relax - \else - \left.\relax - #2% - \setfalse\c_math_fenced_done - \right#1\relax - \ifconditional\c_math_fenced_done - \else - \right.\relax - \fi - \fi} + \egroup} -\permanent\protected\def\mathdelimiterstep#1#2% not used +\permanent\protected\def\mathdelimiterstep#1#2% not used, only in example {\begingroup \math_fenced_force_size\plusone{#1}% - \math_fenced_step#2\relax + \Uvextensible#2\relax \endgroup} \definemathcommand [big] {\choosemathbig1} @@ -779,6 +826,7 @@ \permanent\protected\def\enableautofences {\clf_enableautofences + \setfalse\c_math_fences_auto \glet\clf_enableautofences\relax % onlyonce anyway \enforced\permanent\protected\gdef\enableautofences{\settrue\c_math_fences_auto}% \enableautofences} @@ -865,4 +913,79 @@ \immutable\Umathchardef\bracelu\zerocount \zerocount "FF07C \immutable\Umathchardef\braceru\zerocount \zerocount "FF07D +%D Some tracing: + +\definefont[mathindexfont][Mono sa .2] + +\def\math_fenced_trace_indeed + {% + \beginlocalcontrol + \registerboxanchor + \registeranchorbox + \registeredboxanchor + \plusone + \hbox + \s!anchors \boxanchorpresetcode{depth} \boxanchorpresetcode{height} + \s!yoffset -.1\exheight + \s!target \registeredboxanchor + \s!to \zeropoint + {\darkblue\hss\mathindexfont\ruledhbox{\number\c_math_fence_nesting}\hss}% + \endlocalcontrol + \s!source \registeredboxanchor + } + +% \def\math_fenced_trace_indeed +% {% +% \beginlocalcontrol +% \registerboxanchor +% \registeranchorbox +% \registeredboxanchor +% \plusone +% \ruledhbox +% \s!anchors \boxanchorpresetcode{depth} \boxanchorpresetcode{height} +% \s!yoffset -.1\exheight +% \s!target \registeredboxanchor +% \s!to \zeropoint +% {\darkblue\hss\mathindexfont\ruledhbox{\number\c_math_fence_nesting B}\hss}% +% \registeranchorbox +% \registeredboxanchor +% \plusone +% \ruledhbox +% \s!anchors \boxanchorpresetcode{height} \boxanchorpresetcode{depth} +% \s!yoffset .1\exheight +% \s!target \registeredboxanchor +% \s!to \zeropoint +% {\darkgreen\hss\mathindexfont\ruledhbox{\number\c_math_fence_nesting T}\hss}% +% \registeranchorbox +% \registeredboxanchor +% \plusone +% \ruledhbox +% \s!anchors \boxanchorpresetcode{left} \boxanchorpresetcode{right} +% \s!xoffset -.1\emwidth +% \s!target \registeredboxanchor +% \s!to \zeropoint +% {\darkred\hss\mathindexfont\ruledhbox{\number\c_math_fence_nesting L}}% +% \registeranchorbox +% \registeredboxanchor +% \plusone +% \ruledhbox +% \s!anchors \boxanchorpresetcode{right} \boxanchorpresetcode{left} +% \s!xoffset .1\emwidth +% \s!target \registeredboxanchor +% \s!to \zeropoint +% {\darkyellow\mathindexfont\ruledhbox{\number\c_math_fence_nesting R}\hss}% +% \endlocalcontrol +% \s!source \registeredboxanchor +% } + +\installtextracker + {math.fencenesting} + {\let\math_fenced_trace\math_fenced_trace_indeed} + {\let\math_fenced_trace\donothing} + +\appendtoks + \integerdef\c_math_fence_level\minusone + \c_math_fence_nesting\zerocount +\to \everymathematics + \protect diff --git a/tex/context/base/mkxl/math-frc.lmt b/tex/context/base/mkxl/math-frc.lmt index c82b8387d..c2ae2fbd5 100644 --- a/tex/context/base/mkxl/math-frc.lmt +++ b/tex/context/base/mkxl/math-frc.lmt @@ -6,73 +6,62 @@ if not modules then modules = { } end modules ['math-frc'] = { license = "see context related readme files" } -local utfchar = utf.char - -local context = context -local variables = interfaces.variables - -local v_no = variables.no -local v_yes = variables.yes -local v_hidden = variables.hidden - -local resolved = { - [0x007B] = "\\{", - [0x007D] = "\\}", -} - -table.setmetatableindex(resolved, function(t,k) - local v = utfchar(k) - t[k] = v - return v -end) - -local ctx_Uatop = context.Uatop -local ctx_Uover = context.Uover - --- local function umathfraction(how,style,left,right,width) --- style = tonumber(style) -- or nil +-- obsolete +-- +-- \def\math_frac_command_u +-- {\clf_umathfraction % we can get this bakc to the tex end +-- {\mathfractionparameter\c!rule}% +-- \ifempty\p_math_fraction_fences +-- \mathfractionparameter\c!left \space +-- \mathfractionparameter\c!right\space +-- \else +-- \math_frac_no_delim\space +-- \math_frac_no_delim\space +-- \fi +-- \dimexpr\mathfractionparameter\c!rulethickness\relax +-- {\number\namedboxanchor{\mathfractionparameter\c!source}}% +-- \relax} +-- +-- local utfchar = utf.char +-- +-- local context = context +-- local variables = interfaces.variables +-- +-- local v_no = variables.no +-- local v_yes = variables.yes +-- local v_hidden = variables.hidden +-- +-- local resolved = { +-- [0x007B] = "\\{", +-- [0x007D] = "\\}", +-- } +-- +-- table.setmetatableindex(resolved, function(t,k) +-- local v = utfchar(k) +-- t[k] = v +-- return v +-- end) +-- +-- local function umathfraction(how,left,right,width,source) +-- source = tonumber(source) or 0 -- if how == v_no then -- if left == 0x002E and right == 0x002E then --- if style then --- context("\\Uatop style %i",style) --- else --- ctx_Uatop() --- end +-- context("\\Uatop source %i ",source) -- else --- if style then --- context("\\Uatopwithdelims style %i %s%s",style,resolved[left],resolved[right]) --- else --- context("\\Uatopwithdelims%s%s",resolved[left],resolved[right]) --- end +-- context("\\Uatopwithdelims %s%s source %i ",resolved[left],resolved[right],source) -- end -- elseif how == v_yes or how == v_hidden then --- local norule = how == v_hidden and " norule " or "" --- if style then --- if left == 0x002E and right == 0x002E then --- context("\\Uabove style %i %s%ssp",style,norule,width) --- else --- context("\\Uabovewithdelims style %i %s%s%s%ssp",style,norule,resolved[left],resolved[right],width) --- end +-- local norule = how == v_hidden and "norule" or "" +-- if left == 0x002E and right == 0x002E then +-- context("\\Uabove source %i %s %ssp",source,norule,width) -- else --- if left == 0x002E and right == 0x002E then --- context("\\Uabove%s%ssp",norule,width) --- else --- context("\\Uabovewithdelims%s%s%s%ssp",norule,resolved[left],resolved[right],width) --- end +-- context("\\Uabovewithdelims %s%s source %i %s %ssp",resolved[left],resolved[right],source,norule,width) -- end -- else -- v_auto -- if left == 0x002E and right == 0x002E then --- if style then --- context("\\Uover style %i",style) --- else --- ctx_Uover() --- end +-- context("\\Uover source %i ",source) -- else --- if style then --- context("\\Uoverwithdelims style %i %s%s",style,resolved[left],resolved[right]) --- else --- context("\\Uoverwithdelims%s%s",resolved[left],resolved[right]) --- end +-- context("\\Uoverwithdelims %s%s source %i ",resolved[left],resolved[right],source) -- end -- end -- end @@ -80,35 +69,6 @@ local ctx_Uover = context.Uover -- interfaces.implement { -- name = "umathfraction", -- actions = umathfraction, --- arguments = { "string", "string", "number", "number", "dimen" } +-- protected = true, +-- arguments = { "string", "number", "number", "dimen", "string" } -- } - -local function umathfraction(how,left,right,width) - if how == v_no then - if left == 0x002E and right == 0x002E then - ctx_Uatop() - else - context("\\Uatopwithdelims%s%s",resolved[left],resolved[right]) - end - elseif how == v_yes or how == v_hidden then - local norule = how == v_hidden and " norule " or "" - if left == 0x002E and right == 0x002E then - context("\\Uabove %s%ssp",norule,width) - else - context("\\Uabovewithdelims %s%s%s%ssp",norule,resolved[left],resolved[right],width) - end - else -- v_auto - if left == 0x002E and right == 0x002E then - ctx_Uover() - else - context("\\Uoverwithdelims%s%s",resolved[left],resolved[right]) - end - end -end - -interfaces.implement { - name = "umathfraction", - actions = umathfraction, - protected = true, - arguments = { "string", "number", "number", "dimen" } -} diff --git a/tex/context/base/mkxl/math-frc.mkxl b/tex/context/base/mkxl/math-frc.mkxl index 8835ea997..6e41ee71e 100644 --- a/tex/context/base/mkxl/math-frc.mkxl +++ b/tex/context/base/mkxl/math-frc.mkxl @@ -31,11 +31,10 @@ %D \macros %D {frac, xfrac, xxfrac} %D -%D This is another one Tobias asked for. It replaces the primitive \type -%D {\over}. We also take the opportunity to handle math style restoring, -%D which makes sure units and chemicals come out ok. The \type {\frac} -%D macro kind of replaces the awkward \type {\over} primitive. Say that -%D we have the following formulas: +%D This is another one Tobias asked for. It replaces the primitive \type {\over}. We +%D also take the opportunity to handle math style restoring, which makes sure units +%D and chemicals come out ok. The \type {\frac} macro kind of replaces the awkward +%D \type {\over} primitive. Say that we have the following formulas: %D %D \startbuffer[sample] %D test $\frac {1}{2}$ test $$1 + \frac {1}{2} = 1.5$$ @@ -78,23 +77,8 @@ %D So we stick to the next definitions (watch the local overloading of %D \type {\xfrac}). %D -%D In the meantime, in \LUATEX, we have better control over styles so the -%D following macros are different from the \MKII\ ones. - -% obsolete, is now c!mathstyle -% -% 0=auto, 1=displaystyle, 2=textstyle, 3=scriptstyle, 4=scriptscriptstyle, 5=mathstyle -% -% $\mathfracmode0 \frac{1}{2}$ -% $\mathfracmode1 \frac{1}{2}$ -% $\mathfracmode2 \frac{1}{2}$ -% $\mathfracmode3 \frac{1}{2}$ -% $\mathfracmode4 \frac{1}{2}$ -% $\mathfracmode5 \frac{1}{2}$ -% -% we keep the constant for a while - -\setnewconstant\mathfracmode\zerocount +%D In the meantime, in \LUATEX, we have better control over styles so the following +%D macros are different from the \MKII\ ones. \installcorenamespace{mathfractions} \installcorenamespace{mathfractionstyle} @@ -108,16 +92,22 @@ \setupmathfractions [\c!mathstyle=, + \c!method=\v!vertical, \c!mathnumeratorstyle=\mathfractionparameter\c!mathstyle, \c!mathdenominatorstyle=\mathfractionparameter\c!mathstyle, \c!alternative=\v!inner, \c!margin=\zeropoint, - \c!rulethickness=.25\exheight, - \c!left=0x2E, - \c!right=0x2E, + % \c!rulethickness=.1\exheight, % was .25 for above / atop + \c!rulethickness=\v!font, + \c!left="2E, + \c!right="2E, + \c!middle="2F, \c!strut=\v!yes, \c!topdistance=, \c!bottomdistance=, + \c!source=\zerocount, + \c!hfactor=\plusthousand, + \c!vfactor=\plusthousand, \c!rule=\v!auto] \appendtoks @@ -207,10 +197,14 @@ %D $\frac {2}{3} ^4$ % we wrap in \mathfrac so we can also use prescripts %D \stoptyping -\protected\def\math_frac#1% - %{\begingroup +\installlocalcurrenthandler\??mathfractions {mathfraction} + +\tolerant\protected\def\math_frac#1#*[#2]%% {\mathfrac\bgroup - \edef\currentmathfraction{#1}% + % + \setlocalmathfractioncurrent{#1}% \edef\currentmathfraction{#1}% + % + \ifparameter#2\or\setupcurrentmathfraction[#2]\fi % \edef\p_math_fraction_fences{\mathfractionparameter\c!fences}% \ifempty\p_math_fraction_fences \else @@ -224,8 +218,6 @@ \let\math_fraction_margin_kern\math_fraction_margin_kern_indeed \fi % - \edef\p_math_fractions_color{\mathfractionparameter\c!color}% - % \edef\p_math_fractions_strut{\mathfractionparameter\c!strut}% \ifcsname\??mathfractionstrut\p_math_fractions_strut\endcsname \lastnamedcs @@ -233,30 +225,15 @@ \math_frac_no_strut \fi % - \ifempty\p_math_fractions_color - \expandafter\math_frac_normal - \else - \expandafter\math_frac_colored - \fi} + \expandnamespaceparameter\??mathfractionalternative\mathfractionparameter\c!alternative\v!inner} \protected\def\math_frac_wrapup {\ifempty\p_math_fraction_fences \else \math_fenced_fenced_stop\p_math_fraction_fences \fi - % \endgroup} \egroup} -\protected\def\math_frac_colored#1#2% - {\savecolor - \colo_helpers_activate\p_math_fractions_color - \math_frac_normal{\restorecolor#1}{\restorecolor#2}} - -\protected\def\math_frac_normal - {\expandnamespaceparameter\??mathfractionalternative\mathfractionparameter\c!alternative\v!inner} - -% we use utfchar anyway so we can as well do all at the lua end - -\def\math_frac_no_delim{0x2E} +\integerdef\math_frac_no_delim "2E % or just \zerocount % Having a \withmarginornot{#1}{#2} makes not much sense nor do 4 tests or 4 redundant % kerns (longer node lists plus possible interference). A split in normal and margin @@ -268,33 +245,90 @@ % See \MKIV\ for the old (more messy) implementation where we have to fight the over % related syntax (we now use a lmtx primitive). -% {\ifcstok{#1}\emptytoks\else\tomathstyle#1\fi}% -% -% {\expandedmathstyleparameter\mathfractionparameter\c!mathstyle}% - % timestamp: 01/2022 : (re)watching eNerd⁴ - Time Capsule 2020 a.k.a. Farewell Party % for Normalcy (UHD) with the soekris/neumanns combination +\installcorenamespace{fractionmethods} + +\defcsname\??fractionmethods\v!vertical \v!no \v!none\endcsname{\Uatop} +\defcsname\??fractionmethods\v!vertical \v!no \endcsname{\Uatopwithdelims + \Udelimiter\zerocount\fam\scratchcounterone + \Udelimiter\zerocount\fam\scratchcountertwo} +\defcsname\??fractionmethods\v!vertical \v!yes \v!none\endcsname{\Uabove} +\defcsname\??fractionmethods\v!vertical \v!yes \endcsname{\Uabovewithdelims + \Udelimiter\zerocount\fam\scratchcounterone + \Udelimiter\zerocount\fam\scratchcountertwo} +\defcsname\??fractionmethods\v!vertical \v!hidden\v!none\endcsname{\Uabove + norule} +\defcsname\??fractionmethods\v!vertical \v!hidden \endcsname{\Uabovewithdelims + \Udelimiter\zerocount\fam\scratchcounterone + \Udelimiter\zerocount\fam\scratchcountertwo + norule} +\defcsname\??fractionmethods\v!vertical \v!auto \v!none\endcsname{\Uover} +\defcsname\??fractionmethods\v!vertical \v!auto \endcsname{\Uoverwithdelims + \Udelimiter\zerocount\fam\scratchcounterone + \Udelimiter\zerocount\fam\scratchcountertwo} +\defcsname\??fractionmethods\v!horizontal \v!none\endcsname{\Uskewed + \Udelimiter\zerocount\fam\scratchcounterthree + \s!hfactor \numexpr\mathfractionparameter\c!hfactor\relax} +\defcsname\??fractionmethods\v!horizontal \endcsname{\Uskewedwithdelims + \Udelimiter\zerocount\fam\scratchcounterone + \Udelimiter\zerocount\fam\scratchcountertwo + \Udelimiter\zerocount\fam\scratchcounterthree + \s!hfactor \numexpr\mathfractionparameter\c!hfactor\relax} +\defcsname\??fractionmethods\v!line \v!none\endcsname{\Uskewed + \Udelimiter\zerocount\fam\scratchcounterthree + \s!noaxis \space + \s!hfactor \numexpr\mathfractionparameter\c!hfactor\relax} +\defcsname\??fractionmethods\v!line \endcsname{\Uskewedwithdelims + \Udelimiter\zerocount\fam\scratchcounterone + \Udelimiter\zerocount\fam\scratchcountertwo + \Udelimiter\zerocount\fam\scratchcounterthree + \s!noaxis \space + \s!hfactor \numexpr\mathfractionparameter\c!hfactor\relax} + \def\math_frac_command_u - {\clf_umathfraction - {\mathfractionparameter\c!rule}% - \ifempty\p_math_fraction_fences - \mathfractionparameter\c!left \space - \mathfractionparameter\c!right\space - \else - \math_frac_no_delim\space - \math_frac_no_delim\space - \fi - \dimexpr\mathfractionparameter\c!rulethickness\relax - \relax} + {\edef\p_method {\mathfractionparameter\c!method}% + \edef\p_rule {\mathfractionparameter\c!rule}% + \edef\p_thickness{\mathfractionparameter\c!rulethickness}% + \scratchcounterone \mathfractionparameter\c!left \relax + \scratchcountertwo \mathfractionparameter\c!right \relax + \scratchcounterthree \mathfractionparameter\c!middle \relax + \csname + \??fractionmethods + \p_method + \ifx\p_method\v!horizontal + \orelse\ifx\p_method\v!line + \orelse\ifcsname\??fractionmethods\p_method\p_rule\endcsname + \p_rule + \else + \v!auto + \fi + \ifnum\scratchcounterone=\math_frac_no_delim + \ifnum\scratchcountertwo=\math_frac_no_delim + \v!none + \fi + \fi + \endcsname + \usedcolorparameterattributes{\mathfractionparameter\c!color}% + thickness \ifx\p_thickness\v!font + \zeropoint + \s!font \space + \else + \dimexpr\p_thickness\relax + \fi + \s!vfactor \numexpr\mathfractionparameter\c!vfactor\relax + \s!source \number\namedboxanchor{\mathfractionparameter\c!source}} \protected\defcsname\??mathfractionalternative\v!inner\endcsname#1#2% {\math_frac_command_u - {\math_fraction_margin_kern + {\dousecolorparameter{\mathfractionparameter\c!topcolor}% + \math_fraction_margin_kern \usemathstyleparameter\mathfractionparameter\c!mathnumeratorstyle \m_fractions_strut_top#1% \math_fraction_margin_kern}% - {\math_fraction_margin_kern + {\dousecolorparameter{\mathfractionparameter\c!bottomcolor}% + \math_fraction_margin_kern \usemathstyleparameter\mathfractionparameter\c!mathdenominatorstyle \m_fractions_strut_bot#2% \math_fraction_margin_kern}% @@ -304,10 +338,12 @@ {\beginmathgroup \usemathstyleparameter\mathfractionparameter\c!mathstyle \math_frac_command_u - {\math_fraction_margin_kern + {\dousecolorparameter{\mathfractionparameter\c!topcolor}% + \math_fraction_margin_kern \m_fractions_strut_top#1% \math_fraction_margin_kern}% - {\math_fraction_margin_kern + {\dousecolorparameter{\mathfractionparameter\c!bottomcolor}% + \math_fraction_margin_kern \m_fractions_strut_bot#2% \math_fraction_margin_kern}% \endmathgroup @@ -317,11 +353,13 @@ {\beginmathgroup \usemathstyleparameter\mathfractionparameter\c!mathstyle \math_frac_command_u - {\math_fraction_margin_kern + {\dousecolorparameter{\mathfractionparameter\c!topcolor}% + \math_fraction_margin_kern \usemathstyleparameter\mathfractionparameter\c!mathnumeratorstyle \m_fractions_strut_top#1% \math_fraction_margin_kern}% - {\math_fraction_margin_kern + {\dousecolorparameter{\mathfractionparameter\c!bottomcolor}% + \math_fraction_margin_kern \usemathstyleparameter\mathfractionparameter\c!mathdenominatorstyle \m_fractions_strut_bot#2% \math_fraction_margin_kern}% @@ -339,10 +377,8 @@ %D Spacing (sensitive for definition of \triggermathstyle: -% \ifcase\contextlmtxmode - -\permanent\protected\def\nomathfractiongaps {\normalexpanded{\math_no_fraction_gaps \mathstyletrigger\mathstyle}} % maybe collect settings -\permanent\protected\def\overlaymathfractiongaps{\normalexpanded{\math_overlay_fraction_gaps\mathstyletrigger\mathstyle}} % maybe collect settings +\permanent\protected\def\nomathfractiongaps {\normalexpanded{\math_no_fraction_gaps \allmathstyles}} +\permanent\protected\def\overlaymathfractiongaps{\normalexpanded{\math_overlay_fraction_gaps\allmathstyles}} \protected\def\math_no_fraction_gaps#1% {\Umathfractionnumup #1\zeropoint @@ -351,25 +387,9 @@ \protected\def\math_overlay_fraction_gaps#1% {\Umathfractionnumup #1\zeropoint \Umathfractionnumvgap #1\zeropoint - %Umathfractionrule #1\zeropoint \Umathfractiondenomvgap#1\zeropoint \Umathfractiondenomdown#1\zeropoint} -% \else - -% \protected\def\math_no_fraction_gaps -% {\Umathfractionnumup \mathstyle\zeropoint -% \Umathfractiondenomdown\mathstyle\zeropoint} -% -% \protected\def\math_overlay_fraction_gaps -% {\Umathfractionnumup \mathstyle\zeropoint -% \Umathfractionnumvgap \mathstyle\zeropoint -% %Umathfractionrule \mathstyle\zeropoint -% \Umathfractiondenomvgap\mathstyle\zeropoint -% \Umathfractiondenomdown\mathstyle\zeropoint} - -% \fi - \installcorenamespace{mathfractiondistance} \letcsname\??mathfractiondistance\v!none \endcsname\nomathfractiongaps @@ -379,6 +399,8 @@ \setupmathfractions [\c!distance=\v!none] +% we need to keep it local, so not everybodyfont + \appendtoks \edef\p_distance{\rootmathfractionparameter\c!distance}% \ifempty\p_distance\else @@ -427,6 +449,17 @@ {\edef\p_threshold{\mathfractionparameter\c!displaythreshold}% \Umathfractiondelsize\displaystyle \p_threshold\dimexpr\textface\relax} +%D This is a variant + +\setupmathfractions + [%\c!inlinethreshold=.25, % no unit but fraction + %\c!displaythreshold=.25, % no unit but fraction + \c!threshold=.5\exheight] % wrong name, better is margin or offset or so + +\appendtoks + \Umathskeweddelimitertolerance\allmathstyles\mathfractionparameter\c!threshold +\to \everymathematics % else original lost: \to \everybodyfont + %D \macros %D {dfrac, tfrac, frac, dbinom, tbinom, binom} %D @@ -456,7 +489,7 @@ \definemathfraction[i:dfrac][\c!alternative=\v!inner,\c!mathstyle=\s!display] \definemathfraction[d:frac] [\c!alternative=\v!inner,\c!mathstyle=\s!cramped] -\definemathfraction[d:tfrac][\c!alternative=\v!both,\c!mathstyle={\s!cramped,\s!script}] +\definemathfraction[d:tfrac][\c!alternative=\v!inner,\c!mathstyle={\s!cramped,\s!script}] \definemathfraction[d:sfrac][\c!alternative=\v!both,\c!mathstyle={\s!cramped,\s!scriptscript}] \definemathfraction[d:dfrac][\c!alternative=\v!both,\c!mathstyle=\s!display] @@ -488,12 +521,6 @@ \permanent\protected\def\ctxfrac{\csname\inlineordisplaymath id:frac\endcsname} \permanent\protected\def\amsfrac{\csname\inlineordisplaymath id:ams:frac\endcsname} -% \appendtoks -% \doifelse{\mathfractionparameter\c!option}{ams}% -% {\let\frac\amsfrac}% -% {\let\frac\ctxfrac}% -% \to \everysetupmathfraction - \appendtoks \doifelse{\mathematicsparameter\c!fractions}{ams}% {\enforced\let\frac\amsfrac}% @@ -508,22 +535,50 @@ % \protected\def\dbinom#1#2{{\displaystyle{{#1}\normalabovewithdelims()\zeropoint{#2}}}} % \protected\def\tbinom#1#2{{\textstyle {{#1}\normalabovewithdelims()\zeropoint{#2}}}} +% \definemathfraction +% [binom] +% [\c!alternative=\v!outer, +% \c!rule=\v!no, +% \c!left="28, +% \c!right="29, +% \c!mathstyle=\s!auto] +% +% \definemathfraction +% [dbinom] +% [binom] +% [\c!mathstyle=\s!display] +% +% \definemathfraction +% [tbinom] +% [binom] +% [\c!mathstyle=\s!text] + \definemathfraction - [binom] - [\c!alternative=\v!outer, - \c!rule=\v!no, - \c!left=0x28, - \c!right=0x29, - \c!mathstyle=\s!auto] + [d:binom] + [d:frac] + [\c!rule=\v!no, + % \c!mathstyle=\s!display, + \c!left="28, + \c!right="29] + +\definemathfraction + [i:binom] + [i:frac] + [\c!rule=\v!no, + %\c!mathstyle=\s!text, + \c!left="28, + \c!right="29] + +\permanent\protected\def\binom {\csname\inlineordisplaymath id:binom\endcsname} \definemathfraction [dbinom] - [binom] + [d:binom] [\c!mathstyle=\s!display] \definemathfraction [tbinom] - [binom] + [i:binom] [\c!mathstyle=\s!text] %D \macros @@ -570,8 +625,8 @@ %D \macros %D {splitfrac, splitdfrac} %D -%D Occasionally one needs to typeset multi||line fractions. -%D These commands use \tex{genfrac} to create such fractions. +%D Occasionally one needs to typeset multi||line fractions. These commands use \type +%D {\genfrac} to create such fractions. %D %D \startbuffer %D \startformula @@ -590,54 +645,59 @@ %D %D \typebuffer \getbuffer %D -%D These macros are based on Michael J.~Downes posting on -%D comp.text.tex on 2001/12/06 but adapted a bit. +%D These macros are based on Michael J.~Downes posting on comp.text.tex on 2001/12/06 +%D but adapted a bit. +%D +%D Does anyone actually use this kinf of stuff? \permanent\protected\def\splitfrac #1#2{{\textstyle {{\textstyle#1\quad\hfill}\normalabove\zeropoint{\textstyle\hfill\quad\mathstrut#2}}}} \permanent\protected\def\splitdfrac#1#2{{\displaystyle{{ #1\quad\hfill}\normalabove\zeropoint{ \hfill\quad\mathstrut#2}}}} -%D For testing: +%D More fracking (for Alan): -% \protected\def\ShowMathFractions#1#2% -% {\mathematics{x+\tfrac{#1}{#2}+1+\frac{#1}{#2}+2+\sfrac{#1}{#2}+g}} +% \appendtoks +% \Umathskewedfractionhgap\allmathstyles\namedmathfractionparameter\s!vfrac\c!hfactor\fontemwidth \mathstylefont\textstyle +% \Umathskewedfractionvgap\allmathstyles\namedmathfractionparameter\s!vfrac\c!vfactor\fontexheight\mathstylefont\textstyle +% \to \everymathematics -%D More fracking (for Alan): +\definemathfraction + [\v!horizontal] + [\c!method=\v!horizontal] -\protected\def\math_frac_colored_vulgar#1#2% - {\savecolor - \colo_helpers_activate\p_math_fractions_color - {\restorecolor#1}\Uskewed/{\restorecolor#2}} +\definemathfraction + [\s!vfrac] + [\v!horizontal] + [\c!hfactor=20, + \c!vfactor=10] -\protected\def\math_frac_normal_vulgar#1#2% - {{#1}\Uskewed/{#2}} +%D For Mikael Sundqvist who found out that most inline fractions look real bad: -\permanent\protected\def\vfrac#1#2% - {\bgroup - \edef\p_math_fractions_color{\namedmathfractionparameter\s!vfrac\c!color}% - \ifempty\p_math_fractions_color - \expandafter\math_frac_normal_vulgar - \else - \expandafter\math_frac_colored_vulgar - \fi - {#1}% - {#2}% - \egroup} +\pushoverloadmode -\appendtoks - \edef\p_hfactor{\namedmathfractionparameter\s!vfrac\c!hfactor}% - \edef\p_vfactor{\namedmathfractionparameter\s!vfrac\c!vfactor}% - \Umathskewedfractionhgap\textstyle \p_hfactor\fontemwidth \mathstylefont\textstyle - \Umathskewedfractionhgap\scriptstyle \p_hfactor\fontemwidth \mathstylefont\scriptstyle - \Umathskewedfractionhgap\scriptscriptstyle\p_hfactor\fontemwidth \mathstylefont\scriptscriptstyle - \Umathskewedfractionvgap\textstyle \p_vfactor\fontexheight\mathstylefont\textstyle - \Umathskewedfractionvgap\scriptstyle \p_vfactor\fontexheight\mathstylefont\scriptstyle - \Umathskewedfractionvgap\scriptscriptstyle\p_vfactor\fontexheight\mathstylefont\scriptscriptstyle -\to \everysetupmathfraction +%ifdefined\d \let\text_d\d \else \let\text_d\firstofoneargument \fi +\ifdefined\f \let\text_f\f \else \let\text_f\firstofoneargument \fi -\setupmathfraction - [\s!vfrac] - [\c!hfactor=.2, - \c!vfactor=.1] +\definemathfraction + [f] + [\c!strut=\v!math] + +% \definemathfraction +% [d] +% [\c!method=\v!line, +% \c!strut=\v!math] + +\aliased\let\math_f\f +%aliased\let\math_d\d + +\permanent\protected\def\d{\mathortext\math_d\text_d} +%permanent\protected\def\f{\mathortext\math_f\text_f} + +% \setupmathfraction +% [%strut=math, +% \c!hfactor=100, +% \c!vfactor=100] + +\popoverloadmode \protect \endinput @@ -716,7 +776,7 @@ % \hss$\textstyle/$\hss % \egroup % \lower -% \Umathskewedfractionvgap\textstyle +% \Umathskewedfractionvgapskewedfractionvgap\textstyle % \hbox\bgroup % $\hskip\dimexpr\Umathskewedfractionhgap\textstyle/2\relax\scriptstyle#2$% % \egroup diff --git a/tex/context/base/mkxl/math-ini.lmt b/tex/context/base/mkxl/math-ini.lmt index 4ac76fa62..f41170a97 100644 --- a/tex/context/base/mkxl/math-ini.lmt +++ b/tex/context/base/mkxl/math-ini.lmt @@ -31,6 +31,8 @@ local ctx_doifelsesomething = commands.doifelsesomething local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) +trace_defining = true + local report_math = logs.reporter("mathematics","initializing") mathematics = mathematics or { } @@ -47,86 +49,159 @@ local texsetattribute = tex.setattribute local setmathcode = tex.setmathcode local setdelcode = tex.setdelcode -local families = allocate { - mr = 0, - mb = 1, -} +-- These are different from mkiv with luatex. ---- to be checked .. a few defaults in char-def that should be alpha - -local classes = allocate { - ord = 0, -- mathordcomm mathord - op = 1, -- mathopcomm mathop - bin = 2, -- mathbincomm mathbin - rel = 3, -- mathrelcomm mathrel - open = 4, -- mathopencomm mathopen - middle = 4, - close = 5, -- mathclosecomm mathclose - punct = 6, -- mathpunctcomm mathpunct - alpha = 7, -- mathalphacomm firstofoneargument - accent = 8, -- class 0 - radical = 9, - xaccent = 10, -- class 3 - topaccent = 11, -- class 0 - botaccent = 12, -- class 0 - under = 13, - over = 14, - delimiter = 15, - inner = 0, -- mathinnercomm mathinner - nothing = 0, -- mathnothingcomm firstofoneargument - choice = 0, -- mathchoicecomm @@mathchoicecomm - box = 0, -- mathboxcomm @@mathboxcomm - limop = 1, -- mathlimopcomm @@mathlimopcomm - nolop = 1, -- mathnolopcomm @@mathnolopcomm - -- - ordinary = 0, -- ord - alphabetic = 7, -- alpha - unknown = 0, -- nothing - default = 0, -- nothing - punctuation = 6, -- punct - normal = 0, -- nothing - opening = 4, -- open - closing = 5, -- close - binary = 2, -- bin - relation = 3, -- rel - fence = 0, -- unknown - diacritic = 8, -- accent - large = 1, -- op - variable = 7, -- alphabetic - number = 7, -- alphabetic - root = 16, -- a private one +local classes = allocate { } +local classnames = allocate { } +local maxengineclass = 63 +local lastengineclass = 0 +local lastprivateclass = maxengineclass + +for k, v in next, nodes.noadcodes do + if type(k) == "string"then + classes[k] = v + local n = classnames[v] + if not n or #k < #n then + classnames[v] = k + end + elseif k > lastengineclass then + lastengineclass = k + end +end + +local ordinary_class = classes.ordinary +local operator_class = classes.operator +local binary_class = classes.binary +local relation_class = classes.relation +local open_class = classes.open +local close_class = classes.close +local punctuation_class = classes.punctuation +local middle_class = classes.middle +local accent_class = classes.accent +local radical_class = classes.radical +local fraction_class = classes.fraction +local under_class = classes.under +local over_class = classes.over +local fenced_class = classes.fenced +local ghost_class = classes.ghost + +classes.ord = ordinary_class +classes.op = operator_class +classes.bin = binary_class +classes.rel = relation_class +classes.opening = open_class -- will go +classes.closing = close_class -- will go +classes.punct = punctuation_class +classes.frac = fraction_class +classes.rad = radical_class +classes.fen = fenced_class +classes.gst = ghost_class + +classes.limop = operator_class +classes.limoperator = operator_class +classes.nolop = operator_class +classes.nolimoperator = operator_class +classes.large = operator_class +classes.largeoperator = operator_class + +-- special in the engine : variable active inner vcenter + +local function registerengineclass(name,short) + local class = classes[name] + if not class then + if lastengineclass < maxengineclass then + lastengineclass = lastengineclass + 1 + class = lastengineclass + classnames[class] = short or name + else + class = ordinary_class + end + classes[name] = class + end + return class +end + +local explicit_class = registerengineclass("explicit","expl") +local imaginary_class = registerengineclass("imaginary","im") +local diferential_class = registerengineclass("differential","dif") +local exponential_class = registerengineclass("exponential","exp") +local function_class = registerengineclass("function","fnc") +local digit_class = registerengineclass("digit","dig") +local division_class = registerengineclass("division","div") +local factorial_class = registerengineclass("factorial","fac") + +classes["begin"] = 62 classnames[62] = "begin" +classes["end"] = 63 classnames[63] = "end" + +local function registerprivateclass(name) + local class = classes[name] + if not class then + lastprivateclass = lastprivateclass + 1 + class = lastprivateclass + classes[name] = class + -- also setup + end + return class +end + +local function toengineclass(class) + if type(class) == "string" then + return classes[class] or ordinary_class + elseif class > lastengineclass then + return ordinary_class + else + return class + end +end + +implement { + name = "registerengineclass", + public = true, + protected = true, + arguments = { "optional", "optional" }, + actions = registerengineclass, } -local open_class = 4 -local middle_class = 4 -local close_class = 5 -local accent_class = 8 -local radical_class = 9 -local topaccent_class = 11 -local botaccent_class = 12 -local under_class = 13 -local over_class = 14 -local delimiter_class = 15 -local root_class = 16 +local topaccent_class = registerprivateclass("topaccent") +local botaccent_class = registerprivateclass("botaccent") +local delimiter_class = registerprivateclass("delimiter") +local root_class = registerprivateclass("root") +local prime_class = registerprivateclass("prime") local accents = allocate { accent = true, -- some can be both - topaccent = true, [11] = true, - botaccent = true, [12] = true, - under = true, [13] = true, - over = true, [14] = true, + topaccent = true, [topaccent_class] = true, + botaccent = true, [botaccent_class] = true, + under = true, [under_class] = true, + over = true, [over_class] = true, unknown = false, } +local integer_value = tokens.values.integer + +implement { + name = "mathclassvalue", + -- usage = "value", + public = true, + arguments = "string", + actions = function(name) + -- return integer_value, classes[name] or ordinary_class + context(tostring(classes[name] or ordinary_class)) + end +} + +-- used in math-tag: so there we need to make things ord etc to fit within +-- mathml + local codes = allocate { - ordinary = 0, [0] = "ordinary", - largeoperator = 1, "largeoperator", - binaryoperator = 2, "binaryoperator", - relation = 3, "relation", - openingsymbol = 4, "openingsymbol", - closingsymbol = 5, "closingsymbol", - punctuation = 6, "punctuation", - variable = 7, "variable", + ordinary = ordinary_class, [ordinary_class] = "ordinary", + largeoperator = operator_class, [operator_class] = "largeoperator", + binaryoperator = binary_class, [binary_class] = "binaryoperator", + relation = relation_class, [relation_class] = "relation", + openingsymbol = open_class, [open_class] = "openingsymbol", + closingsymbol = close_class, [close_class] = "closingsymbol", + punctuation = punctuation_class, [punctuation_class] = "punctuation", + middlesymbol = middle_class, [middle_class] = "middlesymbol", } local extensibles = allocate { @@ -169,61 +244,69 @@ function mathematics.virtualize(unicode,virtual) end end -mathematics.extensibles = extensibles -mathematics.classes = classes -mathematics.codes = codes ------------.accents = codes -mathematics.families = families -mathematics.virtualized = virtualized +mathematics.extensibles = extensibles +mathematics.classes = classes +mathematics.toengineclass = toengineclass +mathematics.classnames = classnames +mathematics.codes = codes +-----------.accents = codes +mathematics.virtualized = virtualized do - -- not that many so no need to reuse tables - local setmathcharacter = function(class,family,slot,unicode,mset,dset) - if mset and codes[class] then -- regular codes < 7 + if mset and class ~= ordinary_class then setmathcode("global",slot,class,family,unicode) mset = false end - if dset and class == open_class or class == close_class or class == middle_class then + if dset and (class == open_class or class == close_class or class == middle_class or class == division_class) then setdelcode("global",slot,family,unicode,0,0) dset = false end return mset, dset end - -- todo: make nice setters for this in lua + local function report(class,engine,family,unicode,name) + local nametype = type(name) + if nametype == "string" then + report_math("class %a, engine %a, family %a, char %C, name %a",class,engine,family,unicode,name) + elseif nametype == "number" then + report_math("class %a, engine %a, family %a, char %C, number %U",class,engine,family,unicode,name) + else + report_math("class %a, engine %a, family %a, char %C",class,engine,family,unicode) + end + end - local f_accent = formatters[ [[\defUmathtopaccent \%s{%X}{%X}{%X}]] ] - local f_topaccent = formatters[ [[\defUmathtopaccent \%s{%X}{%X}{%X}]] ] - local f_botaccent = formatters[ [[\defUmathbotaccent \%s{%X}{%X}{%X}]] ] - local f_over = formatters[ [[\defUdelimiterover \%s{%X}{%X}{%X}]] ] - local f_under = formatters[ [[\defUdelimiterunder\%s{%X}{%X}{%X}]] ] - local f_fence = formatters[ [[\defUdelimiter \%s{%X}{%X}{%X}]] ] - local f_delimiter = formatters[ [[\defUdelimiter \%s{%X}{%X}{%X}]] ] - local f_radical = formatters[ [[\defUradical \%s{%X}{%X}]] ] - local f_root = formatters[ [[\defUroot \%s{%X}{%X}]] ] - local f_char = formatters[ [[\defUmathchar \%s{%X}{%X}{%X}]] ] + local f_accent = formatters[ [[\defUmathtopaccent \%s{%X}{%X}{%X}]] ] + local f_fixedtopaccent = formatters[ [[\defUmathfixedtopaccent \%s{%X}{%X}{%X}]] ] + local f_fixedbotaccent = formatters[ [[\defUmathfixedbotaccent \%s{%X}{%X}{%X}]] ] + local f_topaccent = formatters[ [[\defUmathtopaccent \%s{%X}{%X}{%X}]] ] + local f_botaccent = formatters[ [[\defUmathbotaccent \%s{%X}{%X}{%X}]] ] + local f_over = formatters[ [[\defUdelimiterover \%s{%X}{%X}{%X}]] ] + local f_under = formatters[ [[\defUdelimiterunder\%s{%X}{%X}{%X}]] ] + local f_fence = formatters[ [[\defUdelimiter \%s{%X}{%X}{%X}]] ] + local f_delimiter = formatters[ [[\defUdelimiter \%s{%X}{%X}{%X}]] ] + local f_radical = formatters[ [[\defUradical \%s{%X}{%X}]] ] + local f_root = formatters[ [[\defUroot \%s{%X}{%X}]] ] + local f_char = formatters[ [[\defUmathchar \%s{%X}{%X}{%X}]] ] local texmathchardef = tex.mathchardef - local setmathsymbol = function(name,class,family,slot) -- hex is nicer for tracing + local setmathsymbol = function(name,class,engine,family,slot,stretch) -- hex is nicer for tracing if class == accent_class then ctx_sprint(f_topaccent(name,0,family,slot)) elseif class == topaccent_class then - ctx_sprint(f_topaccent(name,0,family,slot)) + ctx_sprint((stretch and f_topaccent or f_fixedtopaccent)(name,0,family,slot)) elseif class == botaccent_class then - ctx_sprint(f_botaccent(name,0,family,slot)) + ctx_sprint((stretch and f_botaccent or f_fixedbotaccent)(name,0,family,slot)) elseif class == over_class then ctx_sprint(f_over(name,0,family,slot)) elseif class == under_class then ctx_sprint(f_under(name,0,family,slot)) elseif class == open_class or class == close_class or class == middle_class then --- setdelcode("global",slot,{family,slot,0,0}) setdelcode("global",slot,family,slot,0,0) - ctx_sprint(f_fence(name,class,family,slot)) + ctx_sprint(f_fence(name,engine,family,slot)) elseif class == delimiter_class then --- setdelcode("global",slot,{family,slot,0,0}) setdelcode("global",slot,family,slot,0,0) ctx_sprint(f_delimiter(name,0,family,slot)) elseif class == radical_class then @@ -231,29 +314,31 @@ do elseif class == root_class then ctx_sprint(f_root(name,family,slot)) elseif texmathchardef then - texmathchardef(name,class,family,slot,"permanent") + texmathchardef(name,engine,family,slot,"permanent") else -- beware, open/close and other specials should not end up here - ctx_sprint(f_char(name,class,family,slot)) + ctx_sprint(f_char(name,engine,family,slot)) end end - local function report(class,family,unicode,name) - local nametype = type(name) - if nametype == "string" then - report_math("class name %a, class %a, family %a, char %C, name %a",classname,class,family,unicode,name) - elseif nametype == "number" then - report_math("class name %a, class %a, family %a, char %C, number %U",classname,class,family,unicode,name) - else - report_math("class name %a, class %a, family %a, char %C", classname,class,family,unicode) + function mathematics.define() + if trace_defining then + logs.startfilelogging(report_math,"math defined from character definitions") end - end - - -- there will be a combined \(math)chardef (tracker) - - function mathematics.define() -- we now always use family zero local family = 0 local data = characters.data + -- + local function remap(first,last) + for unicode=utfbyte(first),utfbyte(last) do + setmathcode("global",unicode,ordinary_class,family,unicode) + end + end + remap("0","9") + remap("A","Z") + remap("a","z") + -- + setdelcode("global",0x2E,0,0,0,0) -- period is special + -- for unicode, character in sortedhash(data) do local symbol = character.mathsymbol local mset = true @@ -262,11 +347,11 @@ do local other = data[symbol] local class = other.mathclass if class then - class = classes[class] or class -- no real checks needed + local engine = toengineclass(class) if trace_defining then - report(class,family,unicode,symbol) + report(class,engine,family,unicode,symbol) end - mset, dset = setmathcharacter(class,family,unicode,symbol,mset,dset) + mset, dset = setmathcharacter(engine,family,unicode,symbol,mset,dset) end local spec = other.mathspec if spec then @@ -274,84 +359,103 @@ do local m = spec[i] local class = m.class if class then - class = classes[class] or class -- no real checks needed - mset, dset = setmathcharacter(class,family,unicode,symbol,mset,dset) + local engine = toengineclass(class) + -- todo: trace + mset, dset = setmathcharacter(engine,family,unicode,symbol,mset,dset) end end end end - local mathclass = character.mathclass - local mathspec = character.mathspec - if mathspec then - if mathclass then - local name = character.mathname + local class = character.mathclass + local spec = character.mathspec + local name = character.mathname + local stretch = character.mathstretch + if spec then + local done = false + if class then if name then report_math("fatal error, conflicting mathclass and mathspec for %C",unicode) os.exit() else - local class = classes[mathclass] or mathclass -- no real checks needed - if not class then - if trace_defining then - report("unknown",family,unicode) - end - else - if trace_defining then - report(class,family,unicode) - end - mset, dset = setmathcharacter(class,family,unicode,unicode,mset,dset) + class = classes[class] or ordinary_class + local engine = toengineclass(class) + if trace_defining then + report(class,engine,family,unicode) end + mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset) + done = true end end - for i=1,#mathspec do - local m = mathspec[i] - local name = m.name - local class = m.class + for i=1,#spec do + local m = spec[i] + local name = m.name + local class = m.class or class if class then - class = classes[class] or class -- no real checks needed + class = classes[class] or ordinary_class + else + class = ordinary_class + end + if class then + local engine = toengineclass(class) if name then if trace_defining then - report(class,family,unicode,name) + report(class,engine,family,unicode,name) end - setmathsymbol(name,class,family,unicode) + setmathsymbol(name,class,engine,family,unicode,stretch) else - name = (class == classes.variable or class == classes.number) and character.adobename -- bad + name = (class == classes.ordinary or class == classes.digit) and character.adobename -- bad if name and trace_defining then - report(class,family,unicode,name) + report(class,engine,family,unicode,name) end end - mset, dset = setmathcharacter(class,family,unicode,m.unicode or unicode,mset,dset) -- see solidus + if not done then + mset, dset = setmathcharacter(engine,family,unicode,m.unicode or unicode,mset,dset) -- see solidus + done = true + end end end - elseif mathclass then - local name = character.mathname - local class = classes[mathclass] or mathclass -- no real checks needed - if not class then - if trace_defining then - report("unknown",family,unicode,name) - end - elseif name == false then - if trace_defining then - report(class,family,unicode,name) - end - mset, dset = setmathcharacter(class,family,unicode,unicode,mset,dset) + else + if class then + class = classes[class] or ordinary_class else - -- if not name then - -- name = character.contextname -- too dangerous, we loose textslash and a few more - -- end - if name then + class = ordinary_class + end + if name ~= nil then + local engine = toengineclass(class) + if name == false then if trace_defining then - report(class,family,unicode,name) + report(class,engine,family,unicode,name) end - setmathsymbol(name,class,family,unicode) + mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset) else - if trace_defining then - report(class,family,unicode,character.adobename) + -- if not name then + -- name = character.contextname -- too dangerous, we loose textslash and a few more + -- end + if name then + if trace_defining then + report(class,engine,family,unicode,name) + end + setmathsymbol(name,class,engine,family,unicode,stretch) + else + if trace_defining then + report(class,engine,family,unicode,character.adobename) + end end + mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset) end - mset, dset = setmathcharacter(class,family,unicode,unicode,mset,dset) + elseif class ~= ordinary_class then + local engine = toengineclass(class) + if trace_defining then + report(class,engine,family,unicode,character.adobename) + end + mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset) end end end + -- + if trace_defining then + logs.stopfilelogging() + end end end @@ -596,17 +700,19 @@ end -- 2: step 2 -- 3: htdp * 1.33^n -- 4: size * 1.33^n +-- 5: use lfg function mathematics.big(tfmdata,unicode,n,method) local t = tfmdata.characters local c = t[unicode] if c and n > 0 then - local vv = c.vvariants or c.next and t[c.next].vvariants - if vv then - local vvn = vv[n] - return vvn and vvn.glyph or vv[#vv].glyph or unicode - elseif method == 1 or method == 2 then - if method == 2 then -- large steps + if method == 1 or method == 2 or method == 5 then + if method == 5 then + local b = tfmdata.bigslots + if b then + n = (n > #b and b[#b]) or b[n] or n + end + elseif method == 2 then -- large steps n = n * 2 end local next = c.next @@ -754,7 +860,7 @@ implement { -- weird to do this here but it's a side affect of math anyway -interfaces.implement { +implement { name = "enableasciimode", onlyonce = true, actions = resolvers.macros.enablecomment, diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index 990341c99..fbfc7a972 100644 --- a/tex/context/base/mkxl/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -76,10 +76,343 @@ \registerctxluafile{math-tag}{autosuffix} \registerctxluafile{math-fbk}{autosuffix} \registerctxluafile{math-dir}{} -\registerctxluafile{math-spa}{} +\registerctxluafile{math-spa}{autosuffix} \registerctxluafile{math-fnt}{autosuffix} \registerctxluafile{math-pre}{autosuffix} +%D Basic spacing: + +\mathfencesmode \plusone % unpack + +% These need to be set because otherwise the engine will not honor some font +% properties. It also permits tracing. These might become engine defaults. As a +% consequence we no longer check for traditional fonts but one can use font control +% options. + +% \mathcontrolmode\plusone + +\mathfontcontrol\numexpr + \zerocount + +\overrulemathcontrolcode % let the node family/font win over current family/font + +\underrulemathcontrolcode % idem + +\radicalrulemathcontrolcode % idem + +\fractionrulemathcontrolcode % idem + +\accentskewhalfmathcontrolcode % fall back to half width skewing when no topaccent is given + +\accentskewapplymathcontrolcode % use topaccent, otherwise use skew char + % + checkligatureandkernmathcontrolcode % old fonts + +\applyverticalitalickernmathcontrolcode % best do this indeed + +\applyordinaryitalickernmathcontrolcode % best do this indeed + % +\applycharitalickernmathcontrolcode % not done + % +\reboxcharitalickernmathcontrolcode % old code path + +\applyboxeditalickernmathcontrolcode % best do this indeed + +\staircasekernmathcontrolcode % use these when set + +\applytextitalickernmathcontrolcode + +\checktextitalickernmathcontrolcode + % +\checkspaceitalickernmathcontrolcode % old code path + +\applyscriptitalickernmathcontrolcode + +\italicshapekernmathcontrolcode % instead of adding pre italic to the shift, inject a kern +\relax + +% \mathpenaltiesmode\plusone + +% These are frozen values because otherwise we need to sunc them when the predefined +% muskip (internal) registers are changed. + +\immutable\mugluespecdef\defaultthickermuskip 7mu plus 5.0mu +\immutable\mugluespecdef\defaultthickmuskip 5mu plus 5mu +\immutable\mugluespecdef\defaultmedmuskip 4mu plus 2mu minus 4mu +\immutable\mugluespecdef\defaultthinmuskip 3mu +\immutable\mugluespecdef\defaulttinymuskip 1mu + +\immutable\mugluespecdef\halfthickmuskip 2.5mu plus 2.5mu +\immutable\mugluespecdef\halfmedmuskip 2.0mu plus 1.0mu minus 2.0mu +\immutable\mugluespecdef\halfthinmuskip 1.5mu +\immutable\mugluespecdef\halftinymuskip 0.5mu + +\immutable\mugluespecdef\hairmuskip .15mu + +\immutable\integerdef \defaultrelpenalty 500 +\immutable\integerdef \defaultbinoppenalty 700 +\immutable\integerdef \defaultprerelpenalty -100 +\immutable\integerdef \defaultprebinoppenalty -100 + +\newmuskip\thickermuskip \thickermuskip \defaultthickermuskip + +% more friendly in setups: + +\setnewconstant\mathordinarycode \mathclassvalue ordinary \aliased\let\mathordcode \mathordinarycode +\setnewconstant\mathoperatorcode \mathclassvalue operator \aliased\let\mathopcode \mathoperatorcode +\setnewconstant\mathbinarycode \mathclassvalue binary \aliased\let\mathbincode \mathbinarycode +\setnewconstant\mathrelationcode \mathclassvalue relation \aliased\let\mathrelcode \mathrelationcode +\setnewconstant\mathopencode \mathclassvalue open +\setnewconstant\mathclosecode \mathclassvalue close +\setnewconstant\mathpunctuationcode \mathclassvalue punctuation \aliased\let\mathpunctcode\mathpunctuationcode +\setnewconstant\mathinnercode \mathclassvalue inner +\setnewconstant\mathovercode \mathclassvalue over +\setnewconstant\mathundercode \mathclassvalue under +\setnewconstant\mathfractioncode \mathclassvalue fraction +\setnewconstant\mathradicalcode \mathclassvalue radical +\setnewconstant\mathmiddlecode \mathclassvalue middle +\setnewconstant\mathaccentcode \mathclassvalue accent +\setnewconstant\mathfencedcode \mathclassvalue fenced +\setnewconstant\mathghostcode \mathclassvalue ghost +\setnewconstant\mathvariablecode \mathclassvalue variable +\setnewconstant\mathactivecode \mathclassvalue active +\setnewconstant\mathvcentercode \mathclassvalue vcenter +\setnewconstant\mathimaginarycode \mathclassvalue imaginary +\setnewconstant\mathdifferentialcode \mathclassvalue differential +\setnewconstant\mathexponentialcode \mathclassvalue exponential +\setnewconstant\mathfunctioncode \mathclassvalue function +\setnewconstant\mathdigitcode \mathclassvalue digit +\setnewconstant\mathexplicitcode \mathclassvalue explicit +\setnewconstant\mathdivisioncode \mathclassvalue division +\setnewconstant\mathfactorialcode \mathclassvalue factorial + +\setnewconstant\mathbegincode \mathclassvalue begin +\setnewconstant\mathendcode \mathclassvalue end + +%setnewconstant\mathtopaccentcode \mathclassvalue topaccent % these are private and above 31 +%setnewconstant\mathbotaccentcode \mathclassvalue botaccent % these are private and above 31 +%setnewconstant\mathdelimitercode \mathclassvalue delimiter % these are private and above 31 +%setnewconstant\mathrootcode \mathclassvalue root % these are private and above 31 +%setnewconstant\mathprimecode \mathclassvalue prime % these are private and above 31 + +%letmathspacing \mathimaginarycode \mathordinarycode \mathordinarycode \mathordinarycode \mathordinarycode +%letmathspacing \mathdifferentialcode \mathordinarycode \mathordinarycode \mathordinarycode \mathordinarycode +%letmathspacing \mathexponentialcode \mathordinarycode \mathordinarycode \mathordinarycode \mathordinarycode +%letmathspacing \mathfunctioncode \mathordinarycode \mathordinarycode \mathordinarycode \mathordinarycode +%letmathspacing \mathdigitcode \mathordinarycode \mathordinarycode \mathordinarycode \mathordinarycode + +\copymathspacing \mathimaginarycode \mathordinarycode +\copymathspacing \mathdifferentialcode \mathordinarycode +\copymathspacing \mathfactorialcode \mathordinarycode +\copymathspacing \mathexponentialcode \mathordinarycode +\copymathspacing \mathfunctioncode \mathordinarycode +\copymathspacing \mathdigitcode \mathordinarycode + +\setnewconstant\mathlimopcode \plusone +\setnewconstant\mathnolopcode \plusone + +% obsolete + +\setnewconstant\mathboxcode \zerocount +\setnewconstant\mathchoicecode \zerocount +\setnewconstant\mathalphacode \zerocount +\setnewconstant\mathnothingcode \zerocount + +\pushoverloadmode + \untraced\permanent\protected\def\binoppenalty {\setmathpostpenalty\mathbinarycode} + \untraced\permanent\protected\def\prebinoppenalty{\setmathprepenalty \mathbinarycode} + \untraced\permanent\protected\def\relpenalty {\setmathpostpenalty\mathrelationcode} + \untraced\permanent\protected\def\prerelpenalty {\setmathprepenalty \mathrelationcode} +\popoverloadmode + +% \newcount\binoppenalty +% \newcount\prebinoppenalty +% \newcount\relpenalty +% \newcount\prerelpenalty + +% topaccent botaccent .. but do we ever need these + +\permanent\protected\def\ordordspacing {\setmathspacing \mathordinarycode \mathordinarycode } +\permanent\protected\def\ordopspacing {\setmathspacing \mathordinarycode \mathoperatorcode } +\permanent\protected\def\ordbinspacing {\setmathspacing \mathordinarycode \mathbinarycode } +\permanent\protected\def\ordrelspacing {\setmathspacing \mathordinarycode \mathrelationcode } +\permanent\protected\def\ordopenspacing {\setmathspacing \mathordinarycode \mathopencode } +\permanent\protected\def\ordclosespacing {\setmathspacing \mathordinarycode \mathclosecode } +\permanent\protected\def\ordpunctspacing {\setmathspacing \mathordinarycode \mathpunctuationcode} +\permanent\protected\def\ordinnerspacing {\setmathspacing \mathordinarycode \mathinnercode } +\permanent\protected\def\ordfracspacing {\setmathspacing \mathordinarycode \mathfractioncode } +\permanent\protected\def\ordradspacing {\setmathspacing \mathordinarycode \mathradicalcode } +\permanent\protected\def\ordmiddlespacing {\setmathspacing \mathordinarycode \mathmiddlecode } +\permanent\protected\def\ordaccentspacing {\setmathspacing \mathordinarycode \mathaccentcode } + +\permanent\protected\def\opordspacing {\setmathspacing \mathoperatorcode \mathordinarycode } +\permanent\protected\def\opopspacing {\setmathspacing \mathoperatorcode \mathoperatorcode } +\permanent\protected\def\opbinspacing {\setmathspacing \mathoperatorcode \mathbinarycode } +\permanent\protected\def\oprelspacing {\setmathspacing \mathoperatorcode \mathrelationcode } +\permanent\protected\def\opopenspacing {\setmathspacing \mathoperatorcode \mathopencode } +\permanent\protected\def\opclosespacing {\setmathspacing \mathoperatorcode \mathclosecode } +\permanent\protected\def\oppunctspacing {\setmathspacing \mathoperatorcode \mathpunctuationcode} +\permanent\protected\def\opinnerspacing {\setmathspacing \mathoperatorcode \mathinnercode } +\permanent\protected\def\opfracspacing {\setmathspacing \mathoperatorcode \mathfractioncode } +\permanent\protected\def\opradspacing {\setmathspacing \mathoperatorcode \mathradicalcode } +\permanent\protected\def\opmiddlespacing {\setmathspacing \mathoperatorcode \mathmiddlecode } +\permanent\protected\def\opaccentspacing {\setmathspacing \mathoperatorcode \mathaccentcode } + +\permanent\protected\def\binordspacing {\setmathspacing \mathbinarycode \mathordinarycode } +\permanent\protected\def\binopspacing {\setmathspacing \mathbinarycode \mathoperatorcode } +\permanent\protected\def\binbinspacing {\setmathspacing \mathbinarycode \mathbinarycode } +\permanent\protected\def\binrelspacing {\setmathspacing \mathbinarycode \mathrelationcode } +\permanent\protected\def\binopenspacing {\setmathspacing \mathbinarycode \mathopencode } +\permanent\protected\def\binclosespacing {\setmathspacing \mathbinarycode \mathclosecode } +\permanent\protected\def\binpunctspacing {\setmathspacing \mathbinarycode \mathpunctuationcode} +\permanent\protected\def\bininnerspacing {\setmathspacing \mathbinarycode \mathinnercode } +\permanent\protected\def\binfracspacing {\setmathspacing \mathbinarycode \mathfractioncode } +\permanent\protected\def\binradspacing {\setmathspacing \mathbinarycode \mathradicalcode } +\permanent\protected\def\binmiddlespacing {\setmathspacing \mathbinarycode \mathmiddlecode } +\permanent\protected\def\binaccentspacing {\setmathspacing \mathbinarycode \mathaccentcode } + +\permanent\protected\def\relordspacing {\setmathspacing \mathrelationcode \mathordinarycode } +\permanent\protected\def\relopspacing {\setmathspacing \mathrelationcode \mathoperatorcode } +\permanent\protected\def\relbinspacing {\setmathspacing \mathrelationcode \mathbinarycode } +\permanent\protected\def\relrelspacing {\setmathspacing \mathrelationcode \mathrelationcode } +\permanent\protected\def\relopenspacing {\setmathspacing \mathrelationcode \mathopencode } +\permanent\protected\def\relclosespacing {\setmathspacing \mathrelationcode \mathclosecode } +\permanent\protected\def\relpunctspacing {\setmathspacing \mathrelationcode \mathpunctuationcode} +\permanent\protected\def\relinnerspacing {\setmathspacing \mathrelationcode \mathinnercode } +\permanent\protected\def\relfracspacing {\setmathspacing \mathrelationcode \mathfractioncode } +\permanent\protected\def\relradspacing {\setmathspacing \mathrelationcode \mathradicalcode } +\permanent\protected\def\relmiddlespacing {\setmathspacing \mathrelationcode \mathmiddlecode } +\permanent\protected\def\relaccentspacing {\setmathspacing \mathrelationcode \mathaccentcode } + +\permanent\protected\def\openordspacing {\setmathspacing \mathopencode \mathordinarycode } +\permanent\protected\def\openopspacing {\setmathspacing \mathopencode \mathoperatorcode } +\permanent\protected\def\openbinspacing {\setmathspacing \mathopencode \mathbinarycode } +\permanent\protected\def\openrelspacing {\setmathspacing \mathopencode \mathrelationcode } +\permanent\protected\def\openopenspacing {\setmathspacing \mathopencode \mathopencode } +\permanent\protected\def\openclosespacing {\setmathspacing \mathopencode \mathclosecode } +\permanent\protected\def\openpunctspacing {\setmathspacing \mathopencode \mathpunctuationcode} +\permanent\protected\def\openinnerspacing {\setmathspacing \mathopencode \mathinnercode } +\permanent\protected\def\openfracspacing {\setmathspacing \mathopencode \mathfractioncode } +\permanent\protected\def\openradspacing {\setmathspacing \mathopencode \mathradicalcode } +\permanent\protected\def\openmiddlespacing {\setmathspacing \mathopencode \mathmiddlecode } +\permanent\protected\def\openaccentspacing {\setmathspacing \mathopencode \mathaccentcode } + +\permanent\protected\def\closeordspacing {\setmathspacing \mathclosecode \mathordinarycode } +\permanent\protected\def\closeopspacing {\setmathspacing \mathclosecode \mathoperatorcode } +\permanent\protected\def\closebinspacing {\setmathspacing \mathclosecode \mathbinarycode } +\permanent\protected\def\closerelspacing {\setmathspacing \mathclosecode \mathrelationcode } +\permanent\protected\def\closeopenspacing {\setmathspacing \mathclosecode \mathopencode } +\permanent\protected\def\closeclosespacing {\setmathspacing \mathclosecode \mathclosecode } +\permanent\protected\def\closepunctspacing {\setmathspacing \mathclosecode \mathpunctuationcode} +\permanent\protected\def\closeinnerspacing {\setmathspacing \mathclosecode \mathinnercode } +\permanent\protected\def\closefracspacing {\setmathspacing \mathclosecode \mathfractioncode } +\permanent\protected\def\closeradspacing {\setmathspacing \mathclosecode \mathradicalcode } +\permanent\protected\def\closemiddlespacing {\setmathspacing \mathclosecode \mathmiddlecode } +\permanent\protected\def\closeaccentspacing {\setmathspacing \mathclosecode \mathaccentcode } + +\permanent\protected\def\punctordspacing {\setmathspacing \mathpunctuationcode \mathordinarycode } +\permanent\protected\def\punctopspacing {\setmathspacing \mathpunctuationcode \mathoperatorcode } +\permanent\protected\def\punctbinspacing {\setmathspacing \mathpunctuationcode \mathbinarycode } +\permanent\protected\def\punctrelspacing {\setmathspacing \mathpunctuationcode \mathrelationcode } +\permanent\protected\def\punctopenspacing {\setmathspacing \mathpunctuationcode \mathopencode } +\permanent\protected\def\punctclosespacing {\setmathspacing \mathpunctuationcode \mathclosecode } +\permanent\protected\def\punctpunctspacing {\setmathspacing \mathpunctuationcode \mathpunctuationcode} +\permanent\protected\def\punctinnerspacing {\setmathspacing \mathpunctuationcode \mathinnercode } +\permanent\protected\def\punctfracspacing {\setmathspacing \mathpunctuationcode \mathfractioncode } +\permanent\protected\def\punctradspacing {\setmathspacing \mathpunctuationcode \mathradicalcode } +\permanent\protected\def\punctmiddlespacing {\setmathspacing \mathpunctuationcode \mathmiddlecode } +\permanent\protected\def\punctaccentspacing {\setmathspacing \mathpunctuationcode \mathaccentcode } + +\permanent\protected\def\innerordspacing {\setmathspacing \mathinnercode \mathordinarycode } +\permanent\protected\def\inneropspacing {\setmathspacing \mathinnercode \mathoperatorcode } +\permanent\protected\def\innerbinspacing {\setmathspacing \mathinnercode \mathbinarycode } +\permanent\protected\def\innerrelspacing {\setmathspacing \mathinnercode \mathrelationcode } +\permanent\protected\def\inneropenspacing {\setmathspacing \mathinnercode \mathopencode } +\permanent\protected\def\innerclosespacing {\setmathspacing \mathinnercode \mathclosecode } +\permanent\protected\def\innerpunctspacing {\setmathspacing \mathinnercode \mathpunctuationcode} +\permanent\protected\def\innerinnerspacing {\setmathspacing \mathinnercode \mathinnercode } +\permanent\protected\def\innerfracspacing {\setmathspacing \mathinnercode \mathfractioncode } +\permanent\protected\def\innerradspacing {\setmathspacing \mathinnercode \mathradicalcode } +\permanent\protected\def\innermiddlespacing {\setmathspacing \mathinnercode \mathmiddlecode } +\permanent\protected\def\inneraccentspacing {\setmathspacing \mathinnercode \mathaccentcode } + +\permanent\protected\def\fracordspacing {\setmathspacing \mathfractioncode \mathordinarycode } +\permanent\protected\def\fracopspacing {\setmathspacing \mathfractioncode \mathoperatorcode } +\permanent\protected\def\fracbinspacing {\setmathspacing \mathfractioncode \mathbinarycode } +\permanent\protected\def\fracrelspacing {\setmathspacing \mathfractioncode \mathrelationcode } +\permanent\protected\def\fracopenspacing {\setmathspacing \mathfractioncode \mathopencode } +\permanent\protected\def\fracclosespacing {\setmathspacing \mathfractioncode \mathclosecode } +\permanent\protected\def\fracpunctspacing {\setmathspacing \mathfractioncode \mathpunctuationcode} +\permanent\protected\def\fracinnerspacing {\setmathspacing \mathfractioncode \mathinnercode } +\permanent\protected\def\fracfracspacing {\setmathspacing \mathfractioncode \mathfractioncode } +\permanent\protected\def\fracradspacing {\setmathspacing \mathfractioncode \mathradicalcode } +\permanent\protected\def\fracmiddlespacing {\setmathspacing \mathfractioncode \mathmiddlecode } +\permanent\protected\def\fracaccentspacing {\setmathspacing \mathfractioncode \mathaccentcode } + +\permanent\protected\def\radordspacing {\setmathspacing \mathradicalcode \mathordinarycode } +\permanent\protected\def\radopspacing {\setmathspacing \mathradicalcode \mathoperatorcode } +\permanent\protected\def\radbinspacing {\setmathspacing \mathradicalcode \mathbinarycode } +\permanent\protected\def\radrelspacing {\setmathspacing \mathradicalcode \mathrelationcode } +\permanent\protected\def\radopenspacing {\setmathspacing \mathradicalcode \mathopencode } +\permanent\protected\def\radclosespacing {\setmathspacing \mathradicalcode \mathclosecode } +\permanent\protected\def\radpunctspacing {\setmathspacing \mathradicalcode \mathpunctuationcode} +\permanent\protected\def\radinnerspacing {\setmathspacing \mathradicalcode \mathinnercode } +\permanent\protected\def\radfracspacing {\setmathspacing \mathradicalcode \mathfractioncode } +\permanent\protected\def\radradspacing {\setmathspacing \mathradicalcode \mathradicalcode } +\permanent\protected\def\radmiddlespacing {\setmathspacing \mathradicalcode \mathmiddlecode } +\permanent\protected\def\radaccentspacing {\setmathspacing \mathradicalcode \mathaccentcode } + +\permanent\protected\def\middleordspacing {\setmathspacing \mathmiddlecode \mathordinarycode } +\permanent\protected\def\middleopspacing {\setmathspacing \mathmiddlecode \mathoperatorcode } +\permanent\protected\def\middlebinspacing {\setmathspacing \mathmiddlecode \mathbinarycode } +\permanent\protected\def\middlerelspacing {\setmathspacing \mathmiddlecode \mathrelationcode } +\permanent\protected\def\middleopenspacing {\setmathspacing \mathmiddlecode \mathopencode } +\permanent\protected\def\middleclosespacing {\setmathspacing \mathmiddlecode \mathclosecode } +\permanent\protected\def\middlepunctspacing {\setmathspacing \mathmiddlecode \mathpunctuationcode} +\permanent\protected\def\middleinnerspacing {\setmathspacing \mathmiddlecode \mathinnercode } +\permanent\protected\def\middlefracspacing {\setmathspacing \mathmiddlecode \mathfractioncode } +\permanent\protected\def\middleradspacing {\setmathspacing \mathmiddlecode \mathradicalcode } +\permanent\protected\def\middlemiddlespacing{\setmathspacing \mathmiddlecode \mathmiddlecode } +\permanent\protected\def\middleaccentspacing{\setmathspacing \mathmiddlecode \mathaccentcode } + +\permanent\protected\def\accentordspacing {\setmathspacing \mathaccentcode \mathordinarycode } +\permanent\protected\def\accentopspacing {\setmathspacing \mathaccentcode \mathoperatorcode } +\permanent\protected\def\accentbinspacing {\setmathspacing \mathaccentcode \mathbinarycode } +\permanent\protected\def\accentrelspacing {\setmathspacing \mathaccentcode \mathrelationcode } +\permanent\protected\def\accentopenspacing {\setmathspacing \mathaccentcode \mathopencode } +\permanent\protected\def\accentclosespacing {\setmathspacing \mathaccentcode \mathclosecode } +\permanent\protected\def\accentpunctspacing {\setmathspacing \mathaccentcode \mathpunctuationcode} +\permanent\protected\def\accentinnerspacing {\setmathspacing \mathaccentcode \mathinnercode } +\permanent\protected\def\accentfracspacing {\setmathspacing \mathaccentcode \mathfractioncode } +\permanent\protected\def\accentradspacing {\setmathspacing \mathaccentcode \mathradicalcode } +\permanent\protected\def\accentmiddlespacing{\setmathspacing \mathaccentcode \mathmiddlecode } +\permanent\protected\def\accentaccentspacing{\setmathspacing \mathaccentcode \mathaccentcode } + +%D In the end Mikael and I prefer for this: + +% \setmathignore\Umathspacebeforescript\plusone +% \setmathignore\Umathspaceafterscript \plusone + +\setmathignore \Umathspacebeforescript\zerocount +\setmathignore \Umathspaceafterscript \zerocount + +\mathslackmode \plusone + +\setmathoptions\mathoperatorcode \plusthree +\setmathoptions\mathbinarycode \plusthree +\setmathoptions\mathrelationcode \plusthree +\setmathoptions\mathopencode \plusthree +\setmathoptions\mathclosecode \plusthree +\setmathoptions\mathpunctuationcode\plusthree +\setmathoptions\mathfractioncode \plusthree + +%D For now \unknown + +\permanent\protected\def\math_discretionary_plus {\discretionary class \mathbinarycode {$+$}{$+$}{$+$}} +\permanent\protected\def\math_discretionary_minus{\discretionary class \mathbinarycode {$-$}{$-$}{$-$}} + +\newtoks\everymathdiscretionaries + +\appendtoks + \enforced\let\+\math_discretionary_plus + \enforced\let\-\math_discretionary_minus +\to \everymathdiscretionaries + +\appendtoks + \ifconditional\c_math_discretionaries + \the\everymathdiscretionaries + \fi +\to \everymathematics + +\setfalse\c_math_discretionaries + +\installtexexperiment + {mathematics.discretionaries} + {\settrue \c_math_discretionaries} + {\setfalse\c_math_discretionaries} + %D A starter: %D %D \startbuffer @@ -123,13 +456,13 @@ \definesystemattribute[displaymath] [public] -\mathflattenmode\numexpr - \ordmathflattencode - +\binmathflattencode - +\relmathflattencode - +\punctmathflattencode - +\innermathflattencode -\relax +% \mathflattenmode\numexpr +% \ordmathflattencode +% +\binmathflattencode +% +\relmathflattencode +% +\punctmathflattencode +% +\innermathflattencode +% \relax \ifdefined\ordlimits\else \let\ordlimits\Umathlimits % downward compatible @@ -166,6 +499,12 @@ \settrue\indisplaymath \fi} +\permanent\protected\def\forceinlinemath + {\ifmmode + \textstyle + \setfalse\indisplaymath + \fi} + \permanent\protected\def\startforceddisplaymath {\startimath \displaystyle @@ -223,19 +562,6 @@ \installmacrostack\currentmathematics -% \permanent\protected\def\startmathematics % no grouping, if ever then also an optional second -% {\doifelsenextoptionalcs\math_mathematics_start_yes\math_mathematics_start_nop} -% -% \protected\def\math_mathematics_start_yes[#1]% -% {\push_macro_currentmathematics -% \edef\currentmathematics{#1}% check for valid -% \the\everyswitchmathematics} -% -% \protected\def\math_mathematics_start_nop -% {\push_macro_currentmathematics -% \let\currentmathematics\empty -% \the\everyswitchmathematics} - \permanent\protected\tolerant\def\startmathematics[#1]% no grouping, if ever then also an optional second {\push_macro_currentmathematics \edef\currentmathematics{#1}% check for valid @@ -267,7 +593,7 @@ \fi} \def\math_m_yes_math[#1]#2% - {#2} + {#2} % grouping permits \mathbf etc \def\math_m_yes_text[#1]% {\begingroup @@ -304,7 +630,7 @@ \def\math_m_yes_text_normal#1% {\the\everyswitchmathematics\relax \normalstartimath - #1% + \begingroup#1\endgroup % grouping permits aftergroups trickery \normalstopimath \endgroup} @@ -314,26 +640,31 @@ #1% \else \normalstartimath - #1% + \begingroup#1\endgroup % grouping permits aftergroups trickery \normalstopimath \fi} -% e.g.: \definemathematics[i:mp][setups=i:tight,openup=yes] +%D maybe more setters -\immutable\mugluespecdef\defaultthickmuskip 5mu plus 5mu -\immutable\mugluespecdef\defaultmedmuskip 4mu plus 2mu minus 4mu -\immutable\mugluespecdef\defaultthinmuskip 3mu +\permanent\protected\def\dm#1% + {\relax + \ifmmode + \beginmathgroup\forcedisplaymath#1\endmathgroup + \else + \startimath\begingroup\forcedisplaymath#1\endgroup\stopimath + \fi} -\immutable\mugluespecdef\halfthickmuskip 2.5mu plus 2.5mu -\immutable\mugluespecdef\halfmedmuskip 2.0mu plus 1.0mu minus 2.0mu -\immutable\mugluespecdef\halfthinmuskip 1.5mu +\permanent\protected\def\im#1% + {\relax + \ifmmode + \beginmathgroup\forceinlinemath#1\endmathgroup + \else + \startimath#1\stopimath + \fi} -\immutable\mugluespecdef\hairmuskip .15mu +% \aliased\let\m \mathematics % we keep the simple versions -\immutable\integerdef \defaultrelpenalty 500 -\immutable\integerdef \defaultbinoppenalty 700 -\immutable\integerdef \defaultprerelpenalty -100 -\immutable\integerdef \defaultprebinoppenalty -100 +% e.g.: \definemathematics[i:mp][setups=i:tight,openup=yes] % we need to control these otherwise: % @@ -344,6 +675,7 @@ \thickmuskip \defaultthickmuskip \medmuskip \defaultmedmuskip \thinmuskip \defaultthinmuskip + \tinymuskip \defaulttinymuskip \relpenalty \defaultrelpenalty \binoppenalty \defaultbinoppenalty \prebinoppenalty\maxdimen @@ -354,6 +686,7 @@ \thickmuskip \defaultthickmuskip \medmuskip \defaultmedmuskip \thinmuskip \defaultthinmuskip + \tinymuskip \defaulttinymuskip \relpenalty \defaultrelpenalty \binoppenalty \defaultbinoppenalty \prebinoppenalty\defaultprebinoppenalty @@ -364,6 +697,7 @@ \thickmuskip \halfthickmuskip \medmuskip \halfmedmuskip \thinmuskip \halfthinmuskip + \tinymuskip \halftinymuskip \relpenalty \defaultrelpenalty \binoppenalty \defaultbinoppenalty \prebinoppenalty\maxdimen @@ -375,10 +709,12 @@ \thickmuskip \halfthickmuskip \medmuskip \halfmedmuskip \thinmuskip \halfthinmuskip + \tinymuskip \halftinymuskip \else \thickmuskip 1\halfthickmuskip \medmuskip 1\halfmedmuskip \thinmuskip 1\halfthinmuskip + \tinymuskip 1\halftinymuskip \fi \relpenalty \defaultrelpenalty \binoppenalty \maxdimen @@ -391,10 +727,12 @@ \thickmuskip \halfthickmuskip \medmuskip \halfmedmuskip \thinmuskip \halfthinmuskip + \tinymuskip \halftinymuskip \else \thickmuskip 1\halfthickmuskip \medmuskip 1\halfmedmuskip \thinmuskip 1\halfthinmuskip + \tinymuskip 1\halftinymuskip \fi \relpenalty \maxdimen \binoppenalty \maxdimen @@ -402,8 +740,209 @@ \prerelpenalty \maxdimen \stopsetups +% this will reset the spacing to default values + +% \Umathspacingmode\allmathstyles\plusone % always pair driven + +% todo: use fullnames instead shirt ones + +\startsetups math:spacing:presets + \resetmathspacing + % \ordordspacing \allmathstyles \zeromuskip + \inherited\ordopspacing \allmathstyles \thinmuskip + \inherited\ordbinspacing \allsplitstyles \medmuskip + \inherited\ordbinspacing \allscriptstyles\tinymuskip + \inherited\ordrelspacing \allsplitstyles \thickmuskip + \inherited\ordrelspacing \allscriptstyles\tinymuskip + % \inherited\ordopenspacing \allmathstyles \zeromuskip + \inherited\ordmiddlespacing \allsplitstyles \medmuskip + \inherited\ordmiddlespacing \allscriptstyles\tinymuskip + % \inherited\ordclosespacing \allmathstyles \zeromuskip + % \inherited\ordpunctspacing \allmathstyles \zeromuskip + \inherited\ordinnerspacing \allsplitstyles \thinmuskip + \inherited\ordinnerspacing \allscriptstyles\tinymuskip + \inherited\ordfracspacing \allmathstyles \tinymuskip + \inherited\ordradspacing \allmathstyles \tinymuskip + \inherited\opordspacing \allmathstyles \thinmuskip + \inherited\opopspacing \allmathstyles \thinmuskip + %%\inherited \opbinspacing \allmathstyles \zeromuskip + \inherited\oprelspacing \allsplitstyles \thickmuskip + \inherited\oprelspacing \allscriptstyles\tinymuskip + % \inherited\opopenspacing \allmathstyles \zeromuskip + \inherited\opmiddlespacing \allsplitstyles \medmuskip + \inherited\opmiddlespacing \allscriptstyles\tinymuskip + % \inherited\opclosespacing \allmathstyles \zeromuskip + % \inherited\oppunctspacing \allmathstyles \zeromuskip + \inherited\opinnerspacing \allsplitstyles \thinmuskip + \inherited\opinnerspacing \allscriptstyles\tinymuskip + \inherited\opfracspacing \allmathstyles \thinmuskip + \inherited\opradspacing \allmathstyles \thinmuskip + \inherited\binordspacing \allsplitstyles \medmuskip + \inherited\binordspacing \allscriptstyles\tinymuskip + \inherited\binopspacing \allsplitstyles \medmuskip + \inherited\binopspacing \allscriptstyles\tinymuskip + %% \inherited\binbinspacing \allmathstyles \zeromuskip + %% \inherited\binrelspacing \allmathstyles \zeromuskip + \inherited\binopenspacing \allsplitstyles \medmuskip + \inherited\binopenspacing \allscriptstyles\tinymuskip + \inherited\binmiddlespacing \allsplitstyles \medmuskip + \inherited\binmiddlespacing \allscriptstyles\tinymuskip + %% \inherited\binclosespacing \allmathstyles \zeromuskip + %% \inherited\binpunctspacing \allmathstyles \zeromuskip + \inherited\bininnerspacing \allsplitstyles \medmuskip + \inherited\bininnerspacing \allscriptstyles\tinymuskip + \inherited\binfracspacing \allsplitstyles \medmuskip + \inherited\binfracspacing \allscriptstyles\tinymuskip + \inherited\binradspacing \allsplitstyles \medmuskip + \inherited\binradspacing \allscriptstyles\tinymuskip + \inherited\relordspacing \allsplitstyles \thickmuskip + \inherited\relordspacing \allscriptstyles\tinymuskip + \inherited\relopspacing \allsplitstyles \thickmuskip + \inherited\relopspacing \allscriptstyles\tinymuskip + %% \inherited\relbinspacing \allmathstyles \zeromuskip + % \inherited\relrelspacing \allmathstyles \zeromuskip + \inherited\relopenspacing \allsplitstyles \thickmuskip + \inherited\relopenspacing \allscriptstyles\tinymuskip + \inherited\relmiddlespacing \allsplitstyles \thickmuskip + \inherited\relmiddlespacing \allscriptstyles\thinmuskip + % \inherited\relclosespacing \allmathstyles \zeromuskip + % \inherited\relpunctspacing \allmathstyles \zeromuskip + \inherited\relinnerspacing \allsplitstyles \thickmuskip + \inherited\relinnerspacing \allscriptstyles\tinymuskip + \inherited\relfracspacing \allsplitstyles \thickmuskip + \inherited\relfracspacing \allscriptstyles\tinymuskip + \inherited\relradspacing \allsplitstyles \thickmuskip + \inherited\relradspacing \allscriptstyles\tinymuskip + % \inherited\openordspacing \allmathstyles \zeromuskip + % \inherited\openopspacing \allmathstyles \zeromuskip + %% \inherited\openbinspacing \allmathstyles \zeromuskip + % \inherited\openrelspacing \allmathstyles \zeromuskip + % \inherited\openopenspacing \allmathstyles \zeromuskip + % \inherited\openmiddlespacing \allmathstyles \zeromuskip + % \inherited\openclosespacing \allmathstyles \zeromuskip + % \inherited\openpunctspacing \allmathstyles \zeromuskip + % \inherited\openinnerspacing \allmathstyles \zeromuskip + \inherited\openfracspacing \allmathstyles \tinymuskip + % \inherited\openradspacing \allmathstyles \zeromuskip + % \inherited\closeordspacing \allmathstyles \zeromuskip + \inherited\closeopspacing \allmathstyles \thinmuskip + \inherited\closebinspacing \allsplitstyles \medmuskip + \inherited\closebinspacing \allscriptstyles\tinymuskip + \inherited\closerelspacing \allsplitstyles \thickmuskip + \inherited\closerelspacing \allscriptstyles\tinymuskip + % \inherited\closeopenspacing \allmathstyles \zeromuskip + % \inherited\closemiddlespacing \allmathstyles \zeromuskip + % \inherited\closeclosespacing \allmathstyles \zeromuskip + % \inherited\closepunctspacing \allmathstyles \zeromuskip + \inherited\closeinnerspacing \allsplitstyles \thinmuskip + \inherited\closeinnerspacing \allscriptstyles\tinymuskip + \inherited\closefracspacing \allsplitstyles \thinmuskip + \inherited\closefracspacing \allscriptstyles\tinymuskip + % \inherited\closeradspacing \allmathstyles \zeromuskip + \inherited\punctordspacing \allsplitstyles \thinmuskip + \inherited\punctordspacing \allscriptstyles\tinymuskip + \inherited\punctopspacing \allsplitstyles \thinmuskip + \inherited\punctopspacing \allscriptstyles\tinymuskip + %% \inherited\punctbinspacing \allmathstyles \zeromuskip + \inherited\punctrelspacing \allsplitstyles \thinmuskip + \inherited\punctrelspacing \allscriptstyles\tinymuskip + \inherited\punctopenspacing \allsplitstyles \thinmuskip + \inherited\punctopenspacing \allscriptstyles\tinymuskip + \inherited\punctmiddlespacing \allsplitstyles \thinmuskip + \inherited\punctmiddlespacing \allscriptstyles\tinymuskip + \inherited\punctclosespacing \allsplitstyles \thinmuskip + \inherited\punctclosespacing \allscriptstyles\tinymuskip + \inherited\punctpunctspacing \allsplitstyles \thinmuskip + \inherited\punctpunctspacing \allscriptstyles\tinymuskip + \inherited\punctinnerspacing \allsplitstyles \thinmuskip + \inherited\punctinnerspacing \allscriptstyles\tinymuskip + \inherited\punctfracspacing \allsplitstyles \thinmuskip + \inherited\punctfracspacing \allscriptstyles\tinymuskip + \inherited\punctradspacing \allsplitstyles \thinmuskip + \inherited\punctradspacing \allscriptstyles\tinymuskip + \inherited\innerordspacing \allsplitstyles \thinmuskip + \inherited\innerordspacing \allscriptstyles\tinymuskip + \inherited\inneropspacing \allmathstyles \thinmuskip + \inherited\innerbinspacing \allsplitstyles \medmuskip + \inherited\innerbinspacing \allscriptstyles\tinymuskip + \inherited\innerrelspacing \allsplitstyles \thickmuskip + \inherited\innerrelspacing \allscriptstyles\tinymuskip + \inherited\inneropenspacing \allsplitstyles \thinmuskip + \inherited\inneropenspacing \allscriptstyles\tinymuskip + \inherited\innermiddlespacing \allsplitstyles \thinmuskip + \inherited\innermiddlespacing \allscriptstyles\tinymuskip + % \inherited\innerclosespacing \allmathstyles \zeromuskip + \inherited\innerpunctspacing \allsplitstyles \thinmuskip + \inherited\innerpunctspacing \allscriptstyles\tinymuskip + \inherited\innerinnerspacing \allsplitstyles \thinmuskip + \inherited\innerinnerspacing \allscriptstyles\tinymuskip + \inherited\innerfracspacing \allsplitstyles \thinmuskip + \inherited\innerfracspacing \allscriptstyles\tinymuskip + \inherited\innerradspacing \allsplitstyles \thinmuskip + \inherited\innerradspacing \allscriptstyles\tinymuskip + \inherited\fracordspacing \allmathstyles \tinymuskip + \inherited\fracopspacing \allmathstyles \thinmuskip + \inherited\fracbinspacing \allsplitstyles \medmuskip + \inherited\fracbinspacing \allscriptstyles\tinymuskip + \inherited\fracrelspacing \allsplitstyles \thickmuskip + \inherited\fracrelspacing \allscriptstyles\tinymuskip + \inherited\fracopenspacing \allsplitstyles \thinmuskip + \inherited\fracopenspacing \allscriptstyles\tinymuskip + \inherited\fracmiddlespacing \allsplitstyles \medmuskip + \inherited\fracmiddlespacing \allscriptstyles\tinymuskip + \inherited\fracclosespacing \allmathstyles \tinymuskip + % \inherited\fracpunctspacing \allmathstyles \zeromuskip + \inherited\fracinnerspacing \allsplitstyles \thinmuskip + \inherited\fracinnerspacing \allscriptstyles\tinymuskip + \inherited\fracfracspacing \allsplitstyles \thinmuskip + \inherited\fracfracspacing \allscriptstyles\tinymuskip + \inherited\fracradspacing \allmathstyles \tinymuskip + \inherited\radordspacing \allsplitstyles \tinymuskip + \inherited\radopspacing \allmathstyles \thinmuskip + \inherited\radbinspacing \allsplitstyles \medmuskip + \inherited\radbinspacing \allscriptstyles\tinymuskip + \inherited\radrelspacing \allsplitstyles \thickmuskip + \inherited\radrelspacing \allscriptstyles\tinymuskip + % \inherited\radopenspacing \allmathstyles \zeromuskip + % \inherited\radmiddlespacing \allmathstyles \zeromuskip + % \inherited\radclosespacing \allmathstyles \zeromuskip + % \inherited\radpunctspacing \allmathstyles \zeromuskip + \inherited\radinnerspacing \allsplitstyles \thinmuskip + \inherited\radinnerspacing \allscriptstyles\tinymuskip + \inherited\radfracspacing \allmathstyles \tinymuskip + \inherited\radradspacing \allmathstyles \tinymuskip + \inherited\middleordspacing \allsplitstyles \medmuskip + \inherited\middleordspacing \allscriptstyles\tinymuskip + \inherited\middleopspacing \allmathstyles \thinmuskip + \inherited\middlebinspacing \allsplitstyles \medmuskip + \inherited\middlebinspacing \allscriptstyles\tinymuskip + \inherited\middlerelspacing \allsplitstyles \thickmuskip + \inherited\middlerelspacing \allscriptstyles\tinymuskip + % \inherited\middleopenspacing \allmathstyles \zeromuskip + % \inherited\middlemiddlespacing \allmathstyles \zeromuskip + % \inherited\middleclosespacing \allmathstyles \zeromuskip + % \inherited\middlepunctspacing \allmathstyles \zeromuskip + \inherited\middleinnerspacing \allsplitstyles \thinmuskip + \inherited\middleinnerspacing \allscriptstyles\tinymuskip + \inherited\middlefracspacing \allsplitstyles \medmuskip + \inherited\middlefracspacing \allscriptstyles\tinymuskip + % \inherited\middleradspacing \allmathstyles \zeromuskip + % + \inherited\setmathspacing \mathclosecode \mathdifferentialcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathclosecode \mathdifferentialcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathordinarycode \mathdifferentialcode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathordinarycode \mathdifferentialcode \allscriptstyles \tinymuskip + \inherited\setmathspacing \mathfactorialcode \mathordinarycode \allsplitstyles \thinmuskip + \inherited\setmathspacing \mathfactorialcode \mathordinarycode \allscriptstyles \tinymuskip +\stopsetups + +\directsetup{math:spacing:default} +\directsetup{math:spacing:presets} + % \dorecurse{80}{test \m[i:tight]{\red \fakeformula} test } +%setupmathematics [\c!setups=math:spacing:default] + \definemathematics[i:default][\c!setups=math:spacing:equal] \definemathematics[i:half] [\c!setups=math:spacing:half] \definemathematics[i:tight] [\c!setups=math:spacing:tight] @@ -488,33 +1027,71 @@ \aliased\let\setmathfontstylealternative\setmathfontstylealternate \aliased\let\mathalternate \setmathfontalternate -\permanent\protected\def\mathupright {\setmathattribute\s!regular\s!tf\setmathfontstylealternate\s!tf} -\permanent\protected\def\mathitalic {\setmathattribute\s!regular\s!it\setmathfontstylealternate\s!it} +% \permanent\protected\def\mathupright {\setmathattribute\s!regular\s!tf\setmathfontstylealternate\s!tf} +% \permanent\protected\def\mathitalic {\setmathattribute\s!regular\s!it\setmathfontstylealternate\s!it} +% \permanent\protected\def\mathscript {\setmathalphabet \s!script \setmathfontstylealternate\s!script} +% \permanent\protected\def\mathfraktur {\setmathalphabet \s!fraktur \setmathfontstylealternate\s!fraktur} +% \permanent\protected\def\mathblackboard{\setmathalphabet \s!blackboard\setmathfontstylealternate\s!blackboard} + +\permanent\protected\def\math_upright {\setmathattribute\s!regular\s!tf\setmathfontstylealternate\s!tf} +\permanent\protected\def\math_italic {\setmathattribute\s!regular\s!it\setmathfontstylealternate\s!it} +\permanent\protected\def\math_script {\setmathalphabet \s!script \setmathfontstylealternate\s!script} +\permanent\protected\def\math_fraktur {\setmathalphabet \s!fraktur \setmathfontstylealternate\s!fraktur} +\permanent\protected\def\math_blackboard{\setmathalphabet \s!blackboard\setmathfontstylealternate\s!blackboard} + +\permanent\protected\def\mathupright {\mathgroupedcommandcs\math_upright} +\permanent\protected\def\mathitalic {\mathgroupedcommandcs\math_italic} +\permanent\protected\def\mathscript {\mathgroupedcommandcs\math_script} +\permanent\protected\def\mathfraktur {\mathgroupedcommandcs\math_fraktur} +\permanent\protected\def\mathblackboard{\mathgroupedcommandcs\math_blackboard} -\permanent\protected\def\mathscript {\setmathalphabet \s!script \setmathfontstylealternate\s!script} -\permanent\protected\def\mathfraktur {\setmathalphabet \s!fraktur \setmathfontstylealternate\s!fraktur} -\permanent\protected\def\mathblackboard{\setmathalphabet \s!blackboard\setmathfontstylealternate\s!blackboard} +% \permanent\protected\def\mathrm{\setmathattribute\s!rm\s!tf\setmathfontstylealternate\s!tf} +% \permanent\protected\def\mathss{\setmathattribute\s!ss\s!tf\setmathfontstylealternate\s!tf} +% \permanent\protected\def\mathtt{\setmathattribute\s!tt\s!tf\setmathfontstylealternate\s!tf} +% +% \permanent\protected\def\mathtf{\setmathfontstyle\s!tf\setmathfontstylealternate\s!tf} +% \permanent\protected\def\mathsl{\setmathfontstyle\s!it\setmathfontstylealternate\s!it} % no sl +% \permanent\protected\def\mathit{\setmathfontstyle\s!it\setmathfontstylealternate\s!it} +% +% \permanent\protected\def\mathbf{\setmathfontstyle\s!bf\setmathfontstylealternate\s!bf} +% \permanent\protected\def\mathbs{\setmathfontstyle\s!bi\setmathfontstylealternate\s!bi} % no sl +% \permanent\protected\def\mathbi{\setmathfontstyle\s!bi\setmathfontstylealternate\s!bi} -\permanent\protected\def\mathrm {\setmathattribute\s!rm\s!tf\setmathfontstylealternate\s!tf} -\permanent\protected\def\mathss {\setmathattribute\s!ss\s!tf\setmathfontstylealternate\s!tf} -\permanent\protected\def\mathtt {\setmathattribute\s!tt\s!tf\setmathfontstylealternate\s!tf} +\permanent\protected\def\math_rm{\setmathattribute\s!rm\s!tf\setmathfontstylealternate\s!tf} +\permanent\protected\def\math_ss{\setmathattribute\s!ss\s!tf\setmathfontstylealternate\s!tf} +\permanent\protected\def\math_tt{\setmathattribute\s!tt\s!tf\setmathfontstylealternate\s!tf} -\permanent\protected\def\mathtf {\setmathfontstyle\s!tf\setmathfontstylealternate\s!tf} -\permanent\protected\def\mathsl {\setmathfontstyle\s!it\setmathfontstylealternate\s!it} % no sl -\permanent\protected\def\mathit {\setmathfontstyle\s!it\setmathfontstylealternate\s!it} +\permanent\protected\def\math_tf{\setmathfontstyle\s!tf\setmathfontstylealternate\s!tf} +\permanent\protected\def\math_sl{\setmathfontstyle\s!it\setmathfontstylealternate\s!it} % no sl +\permanent\protected\def\math_it{\setmathfontstyle\s!it\setmathfontstylealternate\s!it} -\permanent\protected\def\mathbf {\setmathfontstyle\s!bf\setmathfontstylealternate\s!bf} -\permanent\protected\def\mathbs {\setmathfontstyle\s!bi\setmathfontstylealternate\s!bi} % no sl -\permanent\protected\def\mathbi {\setmathfontstyle\s!bi\setmathfontstylealternate\s!bi} +\permanent\protected\def\math_bf{\setmathfontstyle\s!bf\setmathfontstylealternate\s!bf} +\permanent\protected\def\math_bs{\setmathfontstyle\s!bi\setmathfontstylealternate\s!bi} % no sl +\permanent\protected\def\math_bi{\setmathfontstyle\s!bi\setmathfontstylealternate\s!bi} -\aliased\let\mathdefault\mathitalic +\permanent\protected\def\mathrm{\mathgroupedcommandcs\math_rm\relax} +\permanent\protected\def\mathss{\mathgroupedcommandcs\math_ss\relax} +\permanent\protected\def\mathtt{\mathgroupedcommandcs\math_tt\relax} + +\permanent\protected\def\mathtf{\mathgroupedcommandcs\math_tf\relax} +\permanent\protected\def\mathsl{\mathgroupedcommandcs\math_sl\relax} +\permanent\protected\def\mathit{\mathgroupedcommandcs\math_it\relax} + +\permanent\protected\def\mathbf{\mathgroupedcommandcs\math_bf\relax} +\permanent\protected\def\mathbs{\mathgroupedcommandcs\math_bs\relax} +\permanent\protected\def\mathbi{\mathgroupedcommandcs\math_bi\relax} + +\aliased\let\math_default\math_italic +\aliased\let\mathdefault \math_italic \appendtoks \edef\p_default{\mathematicsparameter\c!default}% \ifx\p_default\v!normal - \enforced\let\mathdefault\mathupright + \enforced\let\mathdefault \math_upright + \enforced\let\math_default\math_upright \else - \enforced\let\mathdefault\mathitalic + \enforced\let\mathdefault \math_italic + \enforced\let\math_default\math_italic \fi \to \everysetupmathematics @@ -538,9 +1115,9 @@ \permanent\protected\def\fraktur {\ifmmode\expandafter\mathfraktur \fi} \permanent\protected\def\gothic {\ifmmode\expandafter\mathfraktur \fi} -\permanent\protected\def\mathcal #1{{\mathscript #1}} % for AMS compatibility -\permanent\protected\def\mathfrak#1{{\mathfraktur #1}} % for AMS compatibility -\permanent\protected\def\mathbb #1{{\mathblackboard#1}} % for AMS compatibility +\permanent\protected\def\mathcal {\mathgroupedcommandcs\math_script \relax} % for AMS compatibility +\permanent\protected\def\mathfrak{\mathgroupedcommandcs\math_fraktur \relax} % for AMS compatibility +\permanent\protected\def\mathbb {\mathgroupedcommandcs\math_blackboard\relax} % for AMS compatibility \ifdefined\normaltf \else \permanent\let\normaltf\tf \fi \permanent\protected\def\tf{\ifmmode\expandafter\mathtf\else\expandafter\normaltf\fi} \ifdefined\normalbf \else \permanent\let\normalbf\bf \fi \permanent\protected\def\bf{\ifmmode\expandafter\mathbf\else\expandafter\normalbf\fi} @@ -563,7 +1140,7 @@ % 5: $e=mc^2 \quad \mb e=mc^2$ \prependtoks - \mathdefault + \math_default \to \everymathematics %D We could set the rendering attribute at the \LUA\ end but as there can be many @@ -635,32 +1212,40 @@ \installcorenamespace{mathcodecommand} -\permanent\protected\def\mathlimop#1{\mathop{#1}} %no \limits +\permanent\protected\def\mathlimop#1{\normalmathop{#1}} %no \limits \permanent\protected\def\mathbox #1{\dontleavehmode\hbox\Ustartmath\mathsurround\zeropoint#1\Ustopmath} -\permanent\protected\def\mathnolop#1{\mathop{#1}\nolimits} +\permanent\protected\def\mathnolop#1{\normalmathop{#1}\nolimits} + +% \permanent\protected\def\mathlimop#1{\mathatom \mathoperatorcode options "C0000 {#1}} % auto "40000 + "80000 +% \permanent\protected\def\mathnolop#1{\mathatom \mathoperatorcode options "80000 {#1}} \aliased\let\mathnothing\firstofoneunexpanded \aliased\let\mathalpha \firstofoneunexpanded % todo 'frac' and 'rad' -\setnewconstant\mathordcode \zerocount \letcsname\??mathcodecommand ord\endcsname\mathord -\setnewconstant\mathopcode \plusone \letcsname\??mathcodecommand op\endcsname\mathop -\setnewconstant\mathbincode \plustwo \letcsname\??mathcodecommand bin\endcsname\mathbin -\setnewconstant\mathrelcode \plusthree \letcsname\??mathcodecommand rel\endcsname\mathrel -\setnewconstant\mathopencode \plusfour \letcsname\??mathcodecommand open\endcsname\mathopen -\setnewconstant\mathclosecode \plusfive \letcsname\??mathcodecommand close\endcsname\mathclose -\setnewconstant\mathpunctcode \plussix \letcsname\??mathcodecommand punct\endcsname\mathpunct -\setnewconstant\mathalphacode \plusseven \letcsname\??mathcodecommand alpha\endcsname\mathalpha -\setnewconstant\mathinnercode \zerocount \letcsname\??mathcodecommand inner\endcsname\mathinner -\setnewconstant\mathnothingcode \zerocount \letcsname\??mathcodecommand nothing\endcsname\mathnothing -\setnewconstant\mathlimopcode \plusone \letcsname\??mathcodecommand limop\endcsname\mathlimop -\setnewconstant\mathnolopcode \plusone \letcsname\??mathcodecommand nolop\endcsname\mathnolop -\setnewconstant\mathboxcode \zerocount \letcsname\??mathcodecommand box\endcsname\mathbox -\setnewconstant\mathchoicecode \zerocount %letcsname\??mathcodecommand choice\endcsname\mathnothing - -\setnewconstant\mathaccentcode \pluseight -\setnewconstant\mathradicalcode \plusnine +% why not \aliased ? + +\letcsname\??mathcodecommand ord\endcsname\mathord +\letcsname\??mathcodecommand op\endcsname\mathop +\letcsname\??mathcodecommand bin\endcsname\mathbin +\letcsname\??mathcodecommand rel\endcsname\mathrel +\letcsname\??mathcodecommand open\endcsname\mathopen +\letcsname\??mathcodecommand close\endcsname\mathclose +\letcsname\??mathcodecommand punct\endcsname\mathpunct +\letcsname\??mathcodecommand inner\endcsname\mathinner % hm +%letcsname\??mathcodecommand fraction\endcsname\mathnothing +%letcsname\??mathcodecommand radical\endcsname\mathnothing +%letcsname\??mathcodecommand middle\endcsname\mathnothing +\letcsname\??mathcodecommand limop\endcsname\mathlimop +\letcsname\??mathcodecommand nolop\endcsname\mathnolop + +% obsolete + +\letcsname\??mathcodecommand box\endcsname\mathbox +%letcsname\??mathcodecommand choice\endcsname\mathnothing +\letcsname\??mathcodecommand alpha\endcsname\mathalpha % hm +\letcsname\??mathcodecommand nothing\endcsname\mathnothing \permanent \def\mathcodenumber #1{\the\csname math#1code\endcsname} \permanent\protected\def\mathcodecommand#1{\csname\??mathcodecommand#1\endcsname} @@ -742,79 +1327,51 @@ % \relax % \hskip-.01\emwidth} -\protected\def\math_strut_ht#1% nasty! - {\s!height\dimexpr(\fontcharht#1\c_math_strut/\glyphscale)*\mathscale#1\relax} +\let\math_strut_math_style\normalmathstyle -\protected\def\math_strut_dp#1% nasty! - {\s!depth \dimexpr(\fontchardp#1\c_math_strut/\glyphscale)*\mathscale#1\relax} +% using \s!font \mathstylefontid\mathstyle\fam would needs expansion and guesswork -\protected\def\math_strut_htdp#1% nasty! - {\math_strut_ht{#1}% - \math_strut_dp{#1}} - -\protected\def\math_strut_normal - {\vrule +\appendtoks + \Umathruleheight\alltextstyles \strutheightfactor\fontspecifiedsize\textfont \zerocount + \Umathruledepth \alltextstyles \strutdepthfactor \fontspecifiedsize\textfont \zerocount + \Umathruleheight\allscriptstyles \strutheightfactor\fontspecifiedsize\scriptfont \zerocount + \Umathruledepth \allscriptstyles \strutdepthfactor \fontspecifiedsize\scriptfont \zerocount + \Umathruleheight\allscriptscriptstyles\strutheightfactor\fontspecifiedsize\scriptscriptfont\zerocount + \Umathruledepth \allscriptscriptstyles\strutdepthfactor \fontspecifiedsize\scriptscriptfont\zerocount + \Umathruleheight\alldisplaystyles \Umathruleheight\textstyle + \Umathruledepth \alldisplaystyles \Umathruledepth \textstyle +\to \everybodyfont + +\protected\def\math_strut + {\normalsrule \s!width \zeropoint - \normalexpanded{\math_strut_htdp{\mathstylefont\normalmathstyle}}% + \s!fam \fam + \s!char \c_math_strut \relax} -\protected\def\math_strut_visual - {\hskip-.01\emwidth - \vrule - \s!width .02\emwidth - \normalexpanded{\math_strut_htdp{\mathstylefont\normalmathstyle}}% - \relax - \hskip-.01\emwidth} - -\permanent\protected\def\math_strut_height_normal - {\vrule +\permanent\protected\def\math_strut_height + {\normalsrule \s!width \zeropoint - \normalexpanded{\math_strut_ht{\mathstylefont\normalmathstyle}}% \s!depth \zeropoint + \s!fam \fam + \s!char \c_math_strut \relax} -\permanent\protected\def\math_strut_height_visual - {\hskip-.01\emwidth - \vrule - \s!width .02\emwidth - \normalexpanded{\math_strut_ht{\mathstylefont\normalmathstyle}}% - \s!depth \zeropoint - \relax - \hskip-.01\emwidth} - -\permanent\protected\def\math_strut_depth_normal - {\vrule +\permanent\protected\def\math_strut_depth + {\normalsrule \s!width \zeropoint \s!height\zeropoint - \normalexpanded{\math_strut_dp{\mathstylefont\normalmathstyle}}% + \s!fam \fam + \s!char \c_math_strut \relax} -\permanent\protected\def\math_strut_depth_visual - {\hskip-.01\emwidth - \vrule - \s!width .02\emwidth - \s!height\zeropoint - \normalexpanded{\math_strut_dp{\mathstylefont\normalmathstyle}}% - \relax - \hskip-.01\emwidth} - \permanent\protected\def\showmathstruts % let's not overload \math_strut_normal - {\enforced\let\math_strut \math_strut_visual - \enforced\let\math_strut_height\math_strut_height_visual - \enforced\let\math_strut_depth \math_strut_depth_visual} - -\let\math_strut \math_strut_normal -\let\math_strut_height\math_strut_height_normal -\let\math_strut_depth \math_strut_depth_normal - -% \protected\def\mathstrut{\mathcodecommand{nothing}{\math_strut}} + {\showmakeup[strut]} \pushoverloadmode - - \definemathcommand [mathstrut] {\math_strut} - \definemathcommand [mathheightstrut] {\math_strut_height} - \definemathcommand [mathdepthstrut] {\math_strut_depth} - + \permanent\protected\def\mathstrut {\math_strut} + \permanent\protected\def\mathheightstrut{\math_strut_height} + \permanent\protected\def\mathdepthstrut {\math_strut_depth} \popoverloadmode %D We could have a arg variant \unknown\ but not now. @@ -887,8 +1444,8 @@ \let\math_tags_mo\firstofoneunexpanded \let\math_tags_mi\firstofoneunexpanded -\protected\def\math_tags_mn#1{\begingroup\mathupright\math_set_o_both#1\endgroup} -\protected\def\math_tags_ms#1{\begingroup\mathupright\math_set_p_both#1\endgroup} % why not just \text +\protected\def\math_tags_mn#1{\begingroup\math_upright\math_set_o_both#1\endgroup} +\protected\def\math_tags_ms#1{\begingroup\math_upright\math_set_p_both#1\endgroup} % why not just \text % Once this is stable we can store the number at the tex end which is % faster. Functions getnumbers >= 1000. @@ -901,52 +1458,72 @@ \c!functionstyle=, % rm ss etc i.e. known alternatives, otherwise math \c!functioncolor=] -\protected\def\math_mfunction_styled +% \protected\def\math_mfunction_styled +% {%\begingroup +% \usemathematicscolorparameter\c!functioncolor +% \edef\p_functionstyle{\mathematicsparameter\c!functionstyle}% +% \ifempty\p_functionstyle +% \expandafter\math_mfunction_styled_none +% \orelse\ifcsname\??alternativestyle\p_functionstyle\endcsname +% \expandafter\math_mfunction_styled_text +% \else +% \expandafter\math_mfunction_styled_math +% \fi} +% +% \protected\def\math_mfunction_styled_text#1% +% {\expandafter$\expandafter\mathoptext\expandafter{\lastnamedcs#1}$% +% %{\normalexpanded{$\mathoptext{\csname\??alternativestyle\p_functionstyle\endcsname#1}$}% +% }%\endgroup} +% +% \protected\def\math_mfunction_styled_math#1% +% {\p_functionstyle +% #1% +% }%\endgroup} +% +% \protected\def\math_mfunction_styled_none#1% +% {\math_upright +% #1% +% }%\endgroup} +% +% \permanent\protected\def\mfunction#1% +% {\mathatom mathfont class \mathfunctioncode \bgroup +% \math_tags_mfunctiontxt{#1}\c_apply_function +% \hbox{\math_mfunction_styled{#1}}% +% \egroup} +% +% \permanent\protected\def\mfunctionlabeltext#1% +% {\mathatom mathfont class \mathfunctioncode \bgroup +% \math_tags_mfunctionlab{#1}\c_apply_function +% \hbox{\math_mfunction_styled{\mathlabeltext{#1}}}% +% \egroup} + +\def\math_function_handle#1#2% {\begingroup \usemathematicscolorparameter\c!functioncolor \edef\p_functionstyle{\mathematicsparameter\c!functionstyle}% \ifempty\p_functionstyle - \expandafter\math_mfunction_styled_none + \expandafter\math_upright \orelse\ifcsname\??alternativestyle\p_functionstyle\endcsname - \expandafter\math_mfunction_styled_text + \expandafter\lastnamedcs \else - \expandafter\math_mfunction_styled_math - \fi} - -\protected\def\math_mfunction_styled_text#1% - %{\mathoptext{\csname\??alternativestyle\p_functionstyle\endcsname#1}% - {\expandafter\mathoptext\expandafter{\lastnamedcs#1}% - \endgroup} - -\protected\def\math_mfunction_styled_math#1% - {\p_functionstyle - #1% - \endgroup} - -\protected\def\math_mfunction_styled_none#1% - {\mathupright - #1% - \endgroup} - -\permanent\protected\def\mfunction#1% - {\begingroup - \math_tags_mfunctiontxt{#1}\c_apply_function - \math_mfunction_styled{#1}% + \expandafter\p_functionstyle + \fi + \mathatom mathfont class \mathfunctioncode \bgroup + \math_tags_mfunctionlab{#2}\c_apply_function % maybe move this before mathatom + #1{#2}% + \egroup \endgroup} -\permanent\protected\def\mfunctionlabeltext#1% - {\begingroup - \math_tags_mfunctionlab{#1}\c_apply_function - \math_mfunction_styled{\mathlabeltext{#1}}% - \endgroup} +\permanent\protected\def\mfunction {\math_function_handle\firstofoneargument} +\permanent\protected\def\mfunctionlabeltext{\math_function_handle\mathlabeltext} \let\math_tags_mfunctiontxt\gobbletwoarguments \let\math_tags_mfunctionlab\gobbletwoarguments -\permanent\protected\def\math_tags_mo_indeed#1{\begingroup \c_attr_mathcategory\plusone #1\endgroup} -\permanent\protected\def\math_tags_mi_indeed#1{\begingroup \c_attr_mathcategory\plustwo #1\endgroup} -\permanent\protected\def\math_tags_mn_indeed#1{\begingroup\mathupright\c_attr_mathcategory\plusthree\math_set_o_both#1\endgroup} -\permanent\protected\def\math_tags_ms_indeed#1{\begingroup\mathupright\c_attr_mathcategory\plusfour \math_set_p_both#1\endgroup} % todo: mathoptext +\permanent\protected\def\math_tags_mo_indeed#1{\begingroup \c_attr_mathcategory\plusone #1\endgroup} +\permanent\protected\def\math_tags_mi_indeed#1{\begingroup \c_attr_mathcategory\plustwo #1\endgroup} +\permanent\protected\def\math_tags_mn_indeed#1{\begingroup\math_upright\c_attr_mathcategory\plusthree\math_set_o_both#1\endgroup} +\permanent\protected\def\math_tags_ms_indeed#1{\begingroup\math_upright\c_attr_mathcategory\plusfour \math_set_p_both#1\endgroup} % todo: mathoptext \newconditional\c_apply_function @@ -1063,7 +1640,7 @@ \activatemathcharacter\underscoreasciicode \activatemathcharacter\ampersandasciicode -\permanent\def\normalmathaligntab{&} % \let\normalmathaligntab\aligntab does to work well in a let to & (a def works ok) +\permanent\def\normalmathaligntab{&} % \let\normalmathaligntab\aligntab doesn;t work well in a let to & (a def works ok) \appendtoks \edef\p_ampersand{\mathematicsparameter\s!ampersand}% @@ -1773,6 +2350,8 @@ \bgroup + % This can adn will be replaced by classes: + \catcode\c_math_comma \activecatcode \catcode\c_math_period \activecatcode \catcode\c_math_semicolon\activecatcode @@ -1902,20 +2481,24 @@ % 7 = crampedscriptscript \permanent\def\uncramped#1% - {{\ifmathstyle + {\beginmathgroup + \ifmathstyle \or \displaystyle \or \or \textstyle \or \or \scriptstyle \or \or \scriptscriptstyle \fi - #1}} + #1% + \endmathgroup} \permanent\def\cramped#1% - {{\ifmathstyle + {\beginmathgroup + \ifmathstyle \crampeddisplaystyle \or \or % 0 -> 1 \crampedtextstyle \or \or % 2 -> 3 \crampedscriptstyle \or \or % 4 -> 5 \crampedscriptscriptstyle \fi % 6 -> 7 - #1}} + #1% + \endmathgroup} \permanent\def\triggermathstyle#1{\Ustyle\numexpr#1\relax} %permanent\def\mathstyletrigger#1{\numexpr#1\relax} @@ -1986,6 +2569,9 @@ \textface \fi} +% \permanent\def\mathstyleface#1% #1 is number (\normalmathstyle) +% {\mathstylefont#1\relax} + \permanent\def\mathsmallstyleface#1% #1 is number (\normalmathstyle) {\ifcase\numexpr#1\relax \scriptface \or @@ -1999,6 +2585,19 @@ \scriptface \fi} +% \permanent\def\mathsmallstyleface#1% #1 is number (\normalmathstyle) +% {\mathstylefont\ifcase\numexpr#1\relax +% \scriptstyle \or +% \scriptstyle \or +% \scriptstyle \or +% \scriptstyle \or +% \scriptscriptstyle \or +% \scriptscriptstyle \or +% \scriptscriptstyle \or +% \scriptscriptstyle \else +% \scriptstyle +% \fi} + \permanent\def\mathstylecommand#1#2#3% {\ifcase\numexpr\normalmathstyle\relax \expandafter#1\or @@ -2570,7 +3169,7 @@ \mathscriptboxmode \plustwo % lists and boxes \mathscriptcharmode \plusone % lists and boxes %mathscriptboxmode \plusthree % lists and boxes with \boundary=1 (also for testing and demo) -\mathrulethicknessmode\plusone % adaptive +%mathrulethicknessmode\plusone % adaptive \permanent\protected\def\mathtext {\mathortext{\math_text_choice_font\relax}\hbox} \permanent\protected\def\mathword {\mathortext{\math_text_choice_word\relax}\hbox} @@ -3132,28 +3731,41 @@ \installcorenamespace{mathspacing} -\protected\def\math_spacing_set#1#2% maybe some day \allmathstyles - {\relax - #1\displaystyle #2% - #1\crampeddisplaystyle#2% - #1\textstyle #2% - #1\scriptstyle #2% - #1\crampedscriptstyle #2% - #1\scriptstyle #2% - #1\crampedscriptstyle #2% - \relax} +% \protected\def\math_spacing_set#1#2% maybe some day \allmathstyles +% {\relax +% #1\displaystyle #2% +% #1\crampeddisplaystyle#2% +% #1\textstyle #2% +% #1\scriptstyle #2% +% #1\crampedscriptstyle #2% +% #1\scriptstyle #2% +% #1\crampedscriptstyle #2% +% \relax} +% +% \permanent\tolerant\protected\def\definemathspacing[#1]#*[#2]#*[#3]% +% {\ifcstok{#2}\v!horizontal +% \edefcsname\??mathspacing#1\endcsname +% {\math_spacing_set\Umathxscale{\ifchknum#3\or#3\else\plusthousand\fi\relax}}% +% \orelse\ifcstok{#2}\v!vertical +% \edefcsname\??mathspacing#1\endcsname +% {\math_spacing_set\Umathyscale{\ifchknum#3\or#3\else\plusthousand\fi\relax}}% +% \else +% \edefcsname\??mathspacing#1\endcsname +% {\math_spacing_set\Umathxscale{\ifchknum#2\or\number#2\else\plusthousand\fi\relax}% +% \math_spacing_set\Umathyscale{\ifchknum#3\or\number#3\orelse\ifchknum#2\or\number#2\else\plusthousand\fi\relax}}% +% \fi} \permanent\tolerant\protected\def\definemathspacing[#1]#*[#2]#*[#3]% {\ifcstok{#2}\v!horizontal \edefcsname\??mathspacing#1\endcsname - {\math_spacing_set\Umathxscale{\ifchknum#3\or#3\else\plusthousand\fi\relax}}% + {\Umathxscale\allmathstyles\ifchknum#3\or#3\else\plusthousand\fi\relax}% \orelse\ifcstok{#2}\v!vertical \edefcsname\??mathspacing#1\endcsname - {\math_spacing_set\Umathyscale{\ifchknum#3\or#3\else\plusthousand\fi\relax}}% + {\Umathyscale\allmathstyles\ifchknum#3\or#3\else\plusthousand\fi\relax}% \else \edefcsname\??mathspacing#1\endcsname - {\math_spacing_set\Umathxscale{\ifchknum#2\or\number#2\else\plusthousand\fi\relax}% - \math_spacing_set\Umathyscale{\ifchknum#3\or\number#3\orelse\ifchknum#2\or\number#2\else\plusthousand\fi\relax}}% + {\Umathxscale\allmathstyles\ifchknum#2\or\number#2\else\plusthousand\fi\relax + \Umathyscale\allmathstyles\ifchknum#3\or\number#3\orelse\ifchknum#2\or\number#2\else\plusthousand\fi\relax}% \fi} \definemathspacing[\v!normal] [1000] [1000] @@ -3167,6 +3779,66 @@ \permanent\protected\def\setupmathspacing[#1]% {\begincsname\??mathspacing#1\endcsname} +\installcorenamespace {mathclasses} + +% \defcsname\??mathspacing +\endcsname +% {\expandedloop\zerocount\plusseven\plusone +% {\Umathxscale +% \the\currentloopiterator +% \numexpr\Umathxscale\the\currentloopiterator+\plushundred\relax +% \Umathyscale +% \the\currentloopiterator +% \numexpr\Umathxscale\the\currentloopiterator+\plushundred\relax}} +% +% \defcsname\??mathspacing -\endcsname +% {\expandedloop\zerocount\plusseven\plusone +% {\Umathxscale +% \the\currentloopiterator +% \numexpr\Umathxscale\the\currentloopiterator-\plushundred\relax +% \Umathyscale +% \the\currentloopiterator +% \numexpr\Umathxscale\the\currentloopiterator-\plushundred\relax}} + +% can become a lua call that globally defined it, then we can have +% partials + +% todo: fences and stackers should be done the same: number or +% name + +\letcsname\??mathclasses \endcsname\normalmathord +\letcsname\??mathclasses ord\endcsname\normalmathord +\letcsname\??mathclasses ordinary\endcsname\normalmathord +\letcsname\??mathclasses op\endcsname\normalmathop +\letcsname\??mathclasses operator\endcsname\normalmathop +\letcsname\??mathclasses rel\endcsname\normalmathrel +\letcsname\??mathclasses relation\endcsname\normalmathrel +\letcsname\??mathclasses bin\endcsname\normalmathbin +\letcsname\??mathclasses binary\endcsname\normalmathbin +\letcsname\??mathclasses punct\endcsname\normalmathbin +\letcsname\??mathclasses punctuation\endcsname\normalmathbin +\letcsname\??mathclasses frac\endcsname\normalmathfrac +\letcsname\??mathclasses fraction\endcsname\normalmathfrac +\letcsname\??mathclasses rad\endcsname\normalmathrad +\letcsname\??mathclasses radical\endcsname\normalmathrad + +\def\math_class_by_parameter#1% + {\normalexpanded{\noexpand\math_class_by_parameter_indeed{#1\c!mathclass}}} + +\def\math_class_by_parameter_indeed#1% + {\csname\??mathclasses\ifcsname\??mathclasses#1\endcsname#1\fi\endcsname} + +%D For now we define this here: + +\ifdefined\d \let\text_d\d \else \let\text_d\firstofoneargument \fi + +\pushoverloadmode + + \permanent\protected\def\math_d{\mathatom unpack \mathdifferentialcode{d}} + + \permanent\protected\def\d{\mathortext\math_d\text_d} + +\popoverloadmode + \protect \endinput % % not used (yet) diff --git a/tex/context/base/mkxl/math-int.mkxl b/tex/context/base/mkxl/math-int.mkxl index 462c6587b..30d9643cf 100644 --- a/tex/context/base/mkxl/math-int.mkxl +++ b/tex/context/base/mkxl/math-int.mkxl @@ -13,29 +13,10 @@ \writestatus{loading}{ConTeXt Math Macros / Integrals} -% todo: int and sum etc can be stackers +%D This is replaced by the operator module. \unprotect -%D \startbuffer -%D $\int _a^b f(x) dx $ and also -%D $\iint _a^b f(x,y) dxdy$, -%D $\iiint _a^b f(x,y) dxdy$, -%D \startformula -%D \int _a^b f(x) dx \quad -%D \iint _a^b f(x) dx \quad -%D \iiint _a^b f(x) dx \quad -%D \stopformula -%D \stopbuffer -%D -%D Default: \getbuffer -%D -%D Displaylimits: \setupmathematics[integral=displaylimits] \getbuffer -%D -%D Limits: \setupmathematics[integral=limits] \getbuffer - -%D Adapted to mkiv by HH from code by AM. - \installcorenamespace{mathintegral} \newconstant\mathintlimitmode @@ -64,78 +45,16 @@ \letcsname\??mathintegral none\endcsname\plusfour \appendtoks - \mathintlimitmode\executeifdefined{\??mathintegral\mathematicsparameter\s!integral}\zerocount + \mathintlimitmode + \ifcsname\??mathintegral\mathematicsparameter\s!integral\endcsname + \lastnamedcs + \else + \zerocount + \fi \to \everyswitchmathematics \setupmathematics -% [\v!integral=nolimits] - [\v!integral=autolimits] - -%D The following code is used for fallbacks and might become obsolete once -%D we have enough \OPENTYPE\ math fonts. - -% \def\math_repeated_integal_i -% {\int} - -% \def\math_repeated_integal_ii -% {\math_repeated_integal_i -% \math_repeated_integral_kern -% \math_repeated_integal_i -% \math_repeat_integral_finish -% \intlimits} - -% \def\math_repeated_integal_iii -% {\math_repeated_integal_i -% \math_repeated_integral_kern -% \math_repeated_integal_ii} -% -% \def\math_repeated_integal_iiii -% {\math_repeated_integal_i -% \math_repeated_integral_kern -% \math_repeated_integal_iii} -% -% \protected\def\math_repeat_integral#1% -% {\let\math_repeat_integral_finish\donothing -% \iffontchar\textfont\zerocount#1\relax -% \expandafter\math_repeat_integral_real -% \else -% \expandafter\math_repeat_integral_fake -% \fi} -% -% \def\math_repeat_integral_fake#1#2% -% {\let\math_repeat_integral_fake_symbol#2% -% \futurelet\next\math_repeat_integral_fake_indeed} -% -% \def\math_repeat_integral_real#1#2% -% {#1} -% -% \definemathcommand [iint] {\math_repeat_integral{"0222C}\normalint \math_repeated_integal_ii } % double -% \definemathcommand [iiint] {\math_repeat_integral{"0222D}\normaliint \math_repeated_integal_iii } % tripple -% \definemathcommand [iiiint] {\math_repeat_integral{"FFFFF}\normaliiint\math_repeated_integal_iiii} % quadruple -% -% \def\math_repeated_integral_kern -% {\mkern-6mu\mathchoice{\mkern-3mu}{}{}{}} -% -% \def\math_repeat_integral_fake_indeed -% {\ifx\next\limits -% \math_repeated_integral_correction -% \orelse\ifx\next\displaylimits -% \math_repeated_integral_correction -% \orelse\ifx\next\nolimits -% % nothing -% \orelse\ifcase\mathintlimitmode -% % nothing -% \else -% \math_repeated_integral_correction -% \fi -% \math_repeat_integral_fake_symbol} -% -% \def\math_repeated_integral_correction -% {\mkern-7mu\mathchoice{\mkern-2mu}{}{}{}% -% \mathop\bgroup\mkern7mu\mathchoice{\mkern2mu}{}{}{}\let\math_repeat_integral_finish\egroup} -% -% %D If the \type{\limits} option is used after \type {\iint}, use \type -% %D {\mathop} and fudge the left hand space a bit to make the subscript -% %D visually centered. +% [\c!integral=nolimits] + [\c!integral=autolimits] \protect \endinput diff --git a/tex/context/base/mkxl/math-lop.mkxl b/tex/context/base/mkxl/math-lop.mkxl new file mode 100644 index 000000000..c860b1318 --- /dev/null +++ b/tex/context/base/mkxl/math-lop.mkxl @@ -0,0 +1,143 @@ +%D \module +%D [ file=math-lop, +%D version=2022.02.10, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Large operators, +%D author={Hans Hagen & Mikael Sundqvist}, +%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 Math Macros / Large Operators} + +% $\textstyle \Uoperator \Udelimiter "0 \fam "222B {t} {b} {x}$\blank +% $\textstyle \Uoperator \Udelimiter "0 \fam "222B {t} {b} {\frac{1}{x}}$\blank +% $\displaystyle x + \Uoperator \Udelimiter "0 \fam "222B {t} {b} {\frac{1}{x}}$\blank +% $ x + \Uoperator nolimits \Udelimiter "0 \fam "222B {t} {b} {\frac{1}{x}}$\blank +% $ x + \Uoperator limits \Udelimiter "0 \fam "222B {t} {b} {\frac{1}{x}}$\blank + +\unprotect + +\installcorenamespace{mathoperators} +\installcorenamespace{mathoperatormethod} + +\installcommandhandler \??mathoperators {mathoperator} \??mathoperators + +\setupmathoperator + [\c!left=\zerocount]% so we always have something + +\aliased\let\setupmathoperators\setupmathoperator + +\appendtoks + % todo: only define when there's left or right + \protected\instance\edefcsname\currentmathoperator\endcsname{\math_operator{\currentmathoperator}}% + % todo: under definition control + \protected\instance\edefcsname\e!start\currentmathoperator\endcsname{\math_operator_start{\currentmathoperator}}% + \protected\instance\edefcsname\e!stop \currentmathoperator\endcsname{\math_operator_stop}% +\to \everydefinemathoperator + +% more generic: + +\defcsname\??mathoperatormethod\v!horizontal\endcsname{nolimits } +\defcsname\??mathoperatormethod\v!vertical \endcsname{limits } + +% The ones we wlready had: + +\letcsname\??mathoperatormethod \v!auto\endcsname\empty +\letcsname\??mathoperatormethod autolimits\endcsname\empty +\letcsname\??mathoperatormethod nolimits\expandafter\endcsname\csname\??mathoperatormethod\v!horizontal\endcsname +\letcsname\??mathoperatormethod limits\expandafter\endcsname\csname\??mathoperatormethod\v!vertical \endcsname + +\installlocalcurrenthandler\??mathoperators {mathoperator} + +\protected\def\math_operator_operator#1#2% + {\setlocalmathoperatorcurrent{#1}% \edef\currentmathoperator{#1}% + \setupcurrentmathoperator[#2]% + \Uoperator + \usedcolorparameterattributes{\mathoperatorparameter\c!color}% + \begincsname\??mathoperatormethod\mathoperatorparameter\c!method\endcsname + \ifchkdim\mathoperatorparameter\c!size\or + \s!depth \mathoperatorparameter\c!size + \s!height\mathoperatorparameter\c!size + \s!axis + \orelse\ifcstok{\mathoperatorparameter\c!size}\v!auto + \s!auto + \fi + \s!class \mathoperatorcode + % todo: find a way to pick up or pass sup/sub to here + \Udelimiter \zerocount \fam \mathoperatorparameter\c!left + {\edef\m_operator_text{\mathoperatorparameter\c!top}% + \ifempty\m_operator_text\else + \mathstrut % todo: make option + \dousecolorparameter{\mathoperatorparameter\c!topcolor} + \m_operator_text + \fi}% + {\edef\m_operator_text{\mathoperatorparameter\c!bottom}% + \ifempty\m_operator_text\else + \mathstrut % todo: make option + \dousecolorparameter{\mathoperatorparameter\c!bottomcolor} + \m_operator_text + \fi}} + +\tolerant\protected\def\math_operator#1#*[#2]#*#:#=% mandate braces + {\math_operator_operator{#1}{#2}#3\Uright.} + +\tolerant\protected\def\math_operator_start#1#*[#2]% + {\math_operator_operator{#1}{#2}} + +\protected\def\math_operator_stop + {\Uright.} +% {\Uright\Udelimiter\zerocount \fam \zerocount } + +% \def\math_operator_default_size % is now the auto option +% {\ifconditional\indisplaymath\ifcase\Umathoperatorsize=\maxdimen\else +% \Umathoperatorsize\displaystyle +% \fi\fi} + +% TODO: Add 4 (inherited) classes and then define them automatically from char-def +% instead. + +\setupmathoperators [integrals] [\c!size=\v!auto,\c!method=\mathematicsparameter\c!integral] % cf Mikael's wish +\setupmathoperators [summations] [\c!size=\v!auto] +\setupmathoperators [products] [\c!size=\v!auto] +\setupmathoperators [operators] [\c!size=\v!auto] + +\definemathoperator [integral] [integrals] [\c!left="222B] % these might go unless we decide +\definemathoperator [iintegral] [integrals] [\c!left="222C] % to have verbose parents but who +\definemathoperator [iiintegral] [integrals] [\c!left="222D] % will use them + +\definemathoperator [int] [integrals] [\c!left="222B] % INTEGRAL +\definemathoperator [iint] [integrals] [\c!left="222C] % DOUBLE INTEGRAL +\definemathoperator [iiint] [integrals] [\c!left="222D] % TRIPLE INTEGRAL +\definemathoperator [iiiint] [integrals] [\c!left="2A0C] % QUADRUPLE INTEGRAL OPERATOR +\definemathoperator [oint] [integrals] [\c!left="222E] % CONTOUR INTEGRAL +\definemathoperator [oiint] [integrals] [\c!left="222F] % SURFACE INTEGRAL +\definemathoperator [oiiint] [integrals] [\c!left="2230] % VOLUME INTEGRAL +\definemathoperator [intc] [integrals] [\c!left="2231] % CLOCKWISE INTEGRAL +\definemathoperator [ointc] [integrals] [\c!left="2232] % CLOCKWISE CONTOUR INTEGRAL +\definemathoperator [aointc] [integrals] [\c!left="2233] % ANTI CLOCKWISE CONTOUR INTEGRAL + +\definemathoperator [sum] [summations] [\c!left="2211] % N-ARY SUMMATION + +\definemathoperator [prod] [products] [\c!left="220F] % N-ARY PRODUCT +\definemathoperator [coprod] [products] [\c!left="2210] % N-ARY COPRODUCT + +% todo: middles too + +\definemathoperator [bigwedge] [operators] [\c!left="22C0] % N-ARY LOGICAL AND +\definemathoperator [bigvee] [operators] [\c!left="22C1] % N-ARY LOGICAL OR +\definemathoperator [bigcap] [operators] [\c!left="22C2] % N-ARY LOGICAL INTERSECTION +\definemathoperator [bigcup] [operators] [\c!left="22C3] % N-ARY UNION +\definemathoperator [bigodot] [operators] [\c!left="2A00] % N-ARY CIRCLED DOT OPERATOR +\definemathoperator [bigoplus] [operators] [\c!left="2A01] % N-ARY CIRCLED PLUS OPERATOR +\definemathoperator [bigotimes] [operators] [\c!left="2A02] % N-ARY CIRCLED TIMES OPERATOR +\definemathoperator [bigudot] [operators] [\c!left="2A03] % N-ARY UNION OPERATOR WITH DOT +\definemathoperator [biguplus] [operators] [\c!left="2A04] % N-ARY UNION OPERATOR WITH PLUS +\definemathoperator [bigsqcap] [operators] [\c!left="2A05] % N-ARY SQUARE INTERSECTION OPERATOR +\definemathoperator [bigsqcup] [operators] [\c!left="2A06] % N-ARY SQUARE UNION OPERATOR +\definemathoperator [bigtimes] [operators] [\c!left="2A09] % N-ARY TIMES OPERATOR + +\protect \endinput diff --git a/tex/context/base/mkxl/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt index 3699ae03c..e035a9f68 100644 --- a/tex/context/base/mkxl/math-noa.lmt +++ b/tex/context/base/mkxl/math-noa.lmt @@ -7,6 +7,9 @@ if not modules then modules = { } end modules ['math-noa'] = { license = "see context related readme files" } +-- if specials and (specials[1] == "char" or specials[1] == "font") then -- can we avoid this +-- ... better create a reverse mapping from the already present vectors + -- beware: this is experimental code and there will be a more generic (attribute value -- driven) interface too but for the moment this is ok (sometime in 2015-2016 i will -- start cleaning up as by then the bigger picture is clear and code has been used for @@ -108,6 +111,7 @@ local setattrlist = nuts.setattrlist local setwidth = nuts.setwidth local setheight = nuts.setheight local setdepth = nuts.setdepth +local setoptions = nuts.setoptions local getfield = nuts.getfield local getnext = nuts.getnext @@ -185,19 +189,22 @@ local nodecodes = nodes.nodecodes local noadcodes = nodes.noadcodes local fencecodes = nodes.fencecodes -local ordinarynoad_code = noadcodes.ordinary -local operatornoad_code = noadcodes.operator -local binarynoad_code = noadcodes.binary -local relationnoad_code = noadcodes.relation -local opennoad_code = noadcodes.open -local closenoad_code = noadcodes.close +local ordinarynoad_code = noadcodes.ordinary +local operatornoad_code = noadcodes.operator +local binarynoad_code = noadcodes.binary +local relationnoad_code = noadcodes.relation +local opennoad_code = noadcodes.open +local closenoad_code = noadcodes.close +local middlenoad_code = noadcodes.middle local punctuationnoad_code = noadcodes.punctuation -local innernoad_code = noadcodes.inner -local undernoad_code = noadcodes.under -local overnoad_code = noadcodes.over -local vcenternoad_code = noadcodes.vcenter -local fractionnoad_code = noadcodes.fraction -local radicalnoad_code = noadcodes.radical +local innernoad_code = noadcodes.inner +local fencednoad_code = noadcodes.fenced +local undernoad_code = noadcodes.under +local overnoad_code = noadcodes.over +local vcenternoad_code = noadcodes.vcenter +local fractionnoad_code = noadcodes.fraction +local radicalnoad_code = noadcodes.radical +local accentnoad_code = noadcodes.accent local noad_code = nodecodes.noad local accent_code = nodecodes.accent @@ -230,6 +237,8 @@ local rightfence_code = fencecodes.right -- local gf = getfield local gt = setmetatableindex("number") getfield = function(n,f) gt[f] = gt[f] + 1 return gf(n,f) end mathematics.GETFIELD = gt -- local sf = setfield local st = setmetatableindex("number") setfield = function(n,f,v) st[f] = st[f] + 1 sf(n,f,v) end mathematics.SETFIELD = st +-- TODO : get rid of done + local function process(start,what,n,parent) if n then @@ -280,10 +289,9 @@ local function process(start,what,n,parent) local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list noad = getsup (start) if noad then process(noad,what,n,start) end -- list noad = getsub (start) if noad then process(noad,what,n,start) end -- list - if getsubpre then noad = getsuppre (start) if noad then process(noad,what,n,start) end -- list noad = getsubpre (start) if noad then process(noad,what,n,start) end -- list - end + noad = getfield(start,"prime") if noad then process(noad,what,n,start) end -- list elseif id == mathchar_code or id == mathtextchar_code or id == delimiter_code then break elseif id == subbox_code or id == submlist_code then @@ -300,24 +308,24 @@ local function process(start,what,n,parent) noad = getfield(start,"scriptscript") if noad then process(noad,what,n,start) end -- list elseif id == fence_code then local noad = getfield(start,"delimiter") if noad then process(noad,what,n,start) end -- delimiter + noad = getfield(start,"top") if noad then process(noad,what,n,start) end -- list + noad = getfield(start,"bottom") if noad then process(noad,what,n,start) end -- list elseif id == radical_code then local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list noad = getsup (start) if noad then process(noad,what,n,start) end -- list noad = getsub (start) if noad then process(noad,what,n,start) end -- list - if getsubpre then noad = getsuppre (start) if noad then process(noad,what,n,start) end -- list noad = getsubpre (start) if noad then process(noad,what,n,start) end -- list - end + noad = getfield(start,"prime") if noad then process(noad,what,n,start) end -- delimiter noad = getfield(start,"left") if noad then process(noad,what,n,start) end -- delimiter noad = getfield(start,"degree") if noad then process(noad,what,n,start) end -- list elseif id == accent_code then local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list noad = getsup (start) if noad then process(noad,what,n,start) end -- list noad = getsub (start) if noad then process(noad,what,n,start) end -- list - if getsubpre then noad = getsuppre (start) if noad then process(noad,what,n,start) end -- list noad = getsubpre (start) if noad then process(noad,what,n,start) end -- list - end + noad = getfield(start,"prime") if noad then process(noad,what,n,start) end -- list noad = getfield(start,"topaccent") if noad then process(noad,what,n,start) end -- list noad = getfield(start,"botaccent") if noad then process(noad,what,n,start) end -- list -- elseif id == style_code then @@ -341,10 +349,9 @@ local function processnested(current,what,n) noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list noad = getsup (current) if noad then process(noad,what,n,current) end -- list noad = getsub (current) if noad then process(noad,what,n,current) end -- list - if getsubpre then noad = getsuppre (current) if noad then process(noad,what,n,current) end -- list noad = getsubpre (current) if noad then process(noad,what,n,current) end -- list - end + noad = getfield (current,"prime") if noad then process(noad,what,n,current) end -- list elseif id == subbox_code or id == submlist_code then noad = getlist(current) if noad then process(noad,what,n,current) end -- list (not getlist !) elseif id == fraction_code then @@ -359,24 +366,24 @@ local function processnested(current,what,n) noad = getfield(current,"scriptscript") if noad then process(noad,what,n,current) end -- list elseif id == fence_code then noad = getfield(current,"delimiter") if noad then process(noad,what,n,current) end -- delimiter + noad = getfield(current,"top") if noad then process(noad,what,n,current) end -- list + noad = getfield(current,"bottom") if noad then process(noad,what,n,current) end -- list elseif id == radical_code then noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list noad = getsup (current) if noad then process(noad,what,n,current) end -- list noad = getsub (current) if noad then process(noad,what,n,current) end -- list - if getsubpre then noad = getsuppre (current) if noad then process(noad,what,n,current) end -- list noad = getsubpre (current) if noad then process(noad,what,n,current) end -- list - end + noad = getfield(current,"prime") if noad then process(noad,what,n,current) end -- list noad = getfield(current,"left") if noad then process(noad,what,n,current) end -- delimiter noad = getfield(current,"degree") if noad then process(noad,what,n,current) end -- list elseif id == accent_code then noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list noad = getsup (current) if noad then process(noad,what,n,current) end -- list noad = getsub (current) if noad then process(noad,what,n,current) end -- list - if getsubpre then noad = getsuppre (current) if noad then process(noad,what,n,current) end -- list noad = getsubpre (current) if noad then process(noad,what,n,current) end -- list - end + noad = getfield(current,"prime") if noad then process(noad,what,n,current) end -- list noad = getfield(current,"topaccent") if noad then process(noad,what,n,current) end -- list noad = getfield(current,"botaccent") if noad then process(noad,what,n,current) end -- list end @@ -389,10 +396,9 @@ local function processstep(current,process,n,id) noad = getnucleus(current) if noad then process(noad,n,current) end -- list noad = getsup (current) if noad then process(noad,n,current) end -- list noad = getsub (current) if noad then process(noad,n,current) end -- list - if getsubpre then noad = getsuppre (current) if noad then process(noad,n,current) end -- list noad = getsubpre (current) if noad then process(noad,n,current) end -- list - end + noad = getfield (current,"prime") if noad then process(noad,n,current) end -- list elseif id == subbox_code or id == submlist_code then noad = getlist(current) if noad then process(noad,n,current) end -- list (not getlist !) elseif id == fraction_code then @@ -407,24 +413,24 @@ local function processstep(current,process,n,id) noad = getfield(current,"scriptscript") if noad then process(noad,n,current) end -- list elseif id == fence_code then noad = getfield(current,"delimiter") if noad then process(noad,n,current) end -- delimiter + noad = getfield(current,"top") if noad then process(noad,n,current) end -- list + noad = getfield(current,"bottom") if noad then process(noad,n,current) end -- list elseif id == radical_code then noad = getnucleus(current) if noad then process(noad,n,current) end -- list noad = getsup (current) if noad then process(noad,n,current) end -- list noad = getsub (current) if noad then process(noad,n,current) end -- list - if getsubpre then noad = getsuppre (current) if noad then process(noad,n,current) end -- list noad = getsubpre (current) if noad then process(noad,n,current) end -- list - end + noad = getfield(current,"prime") if noad then process(noad,n,current) end -- delimiter noad = getfield(current,"left") if noad then process(noad,n,current) end -- delimiter noad = getfield(current,"degree") if noad then process(noad,n,current) end -- list elseif id == accent_code then noad = getnucleus(current) if noad then process(noad,n,current) end -- list noad = getsup (current) if noad then process(noad,n,current) end -- list noad = getsub (current) if noad then process(noad,n,current) end -- list - if getsubpre then noad = getsuppre (current) if noad then process(noad,n,current) end -- list noad = getsubpre (current) if noad then process(noad,n,current) end -- list - end + noad = getfield(current,"prime") if noad then process(noad,n,current) end -- list noad = getfield(current,"topaccent") if noad then process(noad,n,current) end -- list noad = getfield(current,"botaccent") if noad then process(noad,n,current) end -- list end @@ -837,40 +843,44 @@ end do + -- todo: use registerattribute + local a_mathsize = privateattribute("mathsize") -- this might move into other fence code local resize = { } resize[fence_code] = function(pointer) local subtype = getsubtype(pointer) - if subtype == leftfence_code or subtype == rightfence_code then + -- if subtype == leftfence_code or subtype == rightfence_code then local a = getattr(pointer,a_mathsize) if a and a > 0 then local method = div(a,100) local size = a % 100 setattr(pointer,a_mathsize,0) local delimiter = getfield(pointer,"delimiter") - local chr, fnt, fam = getcharspec(delimiter) - if chr > 0 and fnt > 0 then - local data = fontdata[fnt] - local char = mathematics.big(data,chr,size,method) - local ht = getheight(pointer) - local dp = getdepth(pointer) - if ht == 1 or dp == 1 then -- 1 scaled point is a signal - local chardata = data.characters[char] - if ht == 1 then - setheight(pointer,chardata.height) + if delimiter then + local chr, fnt, fam = getcharspec(delimiter) + if chr > 0 and fnt > 0 then + local data = fontdata[fnt] + local char = mathematics.big(data,chr,size,method) + local ht = getheight(pointer) + local dp = getdepth(pointer) + if ht == 1 or dp == 1 then -- 1 scaled point is a signal + local chardata = data.characters[char] + if ht == 1 then + setheight(pointer,chardata.height) + end + if dp == 1 then + setdepth(pointer,chardata.depth) + end end - if dp == 1 then - setdepth(pointer,chardata.depth) + if trace_fences then + report_fences("replacing %C by %C using method %a and size %a",chr,char,method,size) end + setchar(delimiter,char) end - if trace_fences then - report_fences("replacing %C by %C using method %a and size %a",chr,char,method,size) - end - setchar(delimiter,char) end end - end + -- end end function handlers.resize(head,style,penalties) @@ -930,7 +940,7 @@ do -- f_c or "?" -- ) local list = new_submlist() - setsubtype(noad,innernoad_code) + setsubtype(noad,fencednoad_code) setnucleus(noad,list) setlist(list,f_o) setlink(f_o,o_next) -- prev of list is nil @@ -993,8 +1003,8 @@ do local f_c = makefence(rightfence_code,close) local c_prev = getprev(close) local f_next = getnext(first) - makelist(middle, close, f_o,f_next,c_prev,f_c) - -- close is now a list + makelist(middle,close,f_o,f_next,c_prev,f_c) + -- close is now a list : inner but should be fenced if c_prev ~= first then setlink(first,close) end @@ -1003,7 +1013,7 @@ do local stacks = setmetatableindex("table") - -- 1=open 2=close 3=middle 4=both + -- 1=open 2=close 3=middle 4=both : todo check both local function processfences(pointer,n,parent) local current = pointer @@ -1811,14 +1821,17 @@ do [binarynoad_code] = true, -- new [relationnoad_code] = true, [opennoad_code] = true, -- new + [middlenoad_code] = true, -- new [closenoad_code] = true, -- new [punctuationnoad_code] = true, -- new [innernoad_code] = false, + [fencednoad_code] = false, [undernoad_code] = false, [overnoad_code] = false, [vcenternoad_code] = false, - [fractionnoad_code] = false, + [fractionnoad_code] = true, [radicalnoad_code] = false, + [accentnoad_code] = true, } local reported = setmetatableindex("table") @@ -1928,111 +1941,64 @@ do end do - -- inner under over vcenter + -- todo: make a primes class local fixscripts = { } --- local movesub = { --- -- primes --- [0x2032] = 0xFE932, --- [0x2033] = 0xFE933, --- [0x2034] = 0xFE934, --- [0x2057] = 0xFE957, --- -- reverse primes --- [0x2035] = 0xFE935, --- [0x2036] = 0xFE936, --- [0x2037] = 0xFE937, --- } --- --- mathematics.virtualize(movesub) - local movesub = { + local primes = { -- primes - [0x2032] = 0x2032, - [0x2033] = 0x2033, - [0x2034] = 0x2034, - [0x2057] = 0x2057, + [0x2032] = true, + [0x2033] = true, + [0x2034] = true, + [0x2057] = true, -- reverse primes - [0x2035] = 0x2035, - [0x2036] = 0x2036, - [0x2037] = 0x2037, + [0x2035] = true, + [0x2036] = true, + [0x2037] = true, } - local nosuperscript_code = tex.mathoptioncodes.nosuperscript - - local function fixsupscript(parent,current,current_char,new_char) - if new_char ~= current_char and new_char ~= true then - setchar(current,new_char) - if trace_fixing then - report_fixing("fixing subscript, replacing superscript %U by %U",current_char,new_char) - end - else - if trace_fixing then - report_fixing("fixing subscript, superscript %U",current_char) - end - end - setfield(parent,"options",nosuperscript_code) - end - - local function move_none_none(parent,prev,nuc,oldchar,newchar) - fixsupscript(prev,nuc,oldchar,newchar) - local sub = getsub(parent) - setsup(prev,nuc) - setsub(prev,sub) - local dummy = copy_node(nuc) - setchar(dummy,0) - setnucleus(parent,dummy) - setsub(parent) - end - - local function move_none_psub(parent,prev,nuc,oldchar,newchar) - fixsupscript(prev,nuc,oldchar,newchar) - setsup(prev,nuc) - local dummy = copy_node(nuc) - setchar(dummy,0) - setnucleus(parent,dummy) - end + local fixable = { + [noad_code] = true, + [accent_code] = true, + [radical_code] = true, + [fraction_code] = true, + } fixscripts[mathchar_code] = function(pointer,what,n,parent,nested) -- todo: switch to turn in on and off if parent then - local oldchar = getchar(pointer) - local newchar = movesub[oldchar] - if newchar then + local char = getchar(pointer) + if char and primes[char] then local nuc = getnucleus(parent) if pointer == nuc then - local sub = getsub(pointer) - local sup = getsup(pointer) - if sub then - if sup then - -- print("[char] sub sup") - else - -- print("[char] sub ---") + local prev = getprev(parent) + if prev and fixable[getid(prev)] then + local prevsup = getsup(prev) + local prevsub = getsub(prev) + local primesup = getsup(parent) + local primesub = getsub(parent) + setfield(prev,"scriptorder",prevsub and 2 or 1) -- sub first + if primesup and not prevsup then + setsup(prev,primesup) + primesup = nil end - elseif sup then - -- print("[char] --- sup") - else - local prev = getprev(parent) - if prev and getid(prev) == noad_code then - local psub = getsub(prev) - local psup = getsup(prev) - if psub then - if psup then - -- print("sub sup [char] --- ---") - else - -- print("sub --- [char] --- ---") - move_none_psub(parent,prev,nuc,oldchar,newchar) - end - elseif psup then - -- print("--- sup [char] --- ---") - else - -- print("[char] --- ---") - move_none_none(parent,prev,nuc,oldchar,newchar) - end - else - -- print("no prev [char]") + if primesub and not prevsub then + setsub(prev,primesub) + primesub = nil + end + setfield(prev,"prime",nuc) + setnucleus(parent) + if not primesup then + setsup(parent) + end + if not primesub then + setsub(parent) + end + if not (primesup or primesub) then + setlink(prev,getnext(parent)) + flushnode(parent) + return true, prev, prev end end - else - -- print("[char]") end end end @@ -2119,10 +2085,12 @@ do [ordinarynoad_code] = "trace:db", [binarynoad_code] = "trace:dg", [opennoad_code] = "trace:dm", + [middlenoad_code] = "trace:dm", [closenoad_code] = "trace:dm", [punctuationnoad_code] = "trace:dc", -- [operatornoad_code] = "", -- [innernoad_code = "", + -- [fencednoad_code = "", -- [undernoad_code] = "", -- [overnoad_code] = "", -- [vcenternoad_code] = "", @@ -2176,6 +2144,7 @@ do relation = relationnoad_code, punctuation = punctuationnoad_code, inner = innernoad_code, + fenced = fencednoad_code, -- fraction = fractionnoad_code, -- radical = radicalnoad_code, } diff --git a/tex/context/base/mkxl/math-pln.mkxl b/tex/context/base/mkxl/math-pln.mkxl index 81008f37b..354f33a5f 100644 --- a/tex/context/base/mkxl/math-pln.mkxl +++ b/tex/context/base/mkxl/math-pln.mkxl @@ -26,7 +26,7 @@ \permanent\protected\def\hrulefill{\leaders\hrule\hfill} %protected\def\dotfill {\cleaders\hbox{\normalstartimath\mathsurround\zeropoint\mkern1.5mu.\mkern1.5mu\normalstopimath}\hfill} -% will move +% will move .. not used anyway \permanent\def\oalign#1% {\leavevmode % plain tex uses this @@ -41,9 +41,9 @@ % needs checking -\permanent\protected\def\choose{\atopwithdelims()} -\permanent\protected\def\brack {\atopwithdelims[]} -\permanent\protected\def\brace {\atopwithdelims\{\}} +\permanent\protected\def\choose{\atopwithdelims()} % used in korean test file, has to go +%permanent\protected\def\brack {\atopwithdelims[]} +%permanent\protected\def\brace {\atopwithdelims\{\}} % needs checking diff --git a/tex/context/base/mkxl/math-rad.mklx b/tex/context/base/mkxl/math-rad.mklx index 041681f0b..de8c2e9a6 100644 --- a/tex/context/base/mkxl/math-rad.mklx +++ b/tex/context/base/mkxl/math-rad.mklx @@ -30,19 +30,19 @@ \protected\def\sqrt{\doifelsenextoptionalcs\rootwithdegree\rootwithoutdegree} % will be redefined -\permanent\protected\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird - {\normalexpanded{\rootradical - {\normalunexpanded{#1}}% - {\noexpand\triggermathstyle{\number\normalmathstyle}% - \normalunexpanded{#2}}}} +% \permanent\protected\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird +% {\normalexpanded{\math_radical_common +% {\normalunexpanded{#1}}% +% {\noexpand\triggermathstyle{\number\normalmathstyle}% +% \normalunexpanded{#2}}}} % experimental new keyword: (maybe keywords should come after the symbol) % % \permanent\protected\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird % {\Uroot style \normalmathstyle "0 "221A {#1}{#2}} -\permanent\protected\def\rootwithdegree[#1]{\rootradical{#1}} -\permanent\protected\def\rootwithoutdegree {\rootradical {}} +\permanent\protected\def\rootwithdegree[#1]{\math_radical_common{#1}} +\permanent\protected\def\rootwithoutdegree {\math_radical_common {}} %D Even older stuff: @@ -89,7 +89,8 @@ \setupmathradical [\c!alternative=\v!normal, - \c!mpoffset=.25\exheight] + \c!mpoffset=.25\exheight, + \c!source=\zerocount] \appendtoks \frozen\protected\instance\edefcsname\currentmathradical\endcsname{\math_radical_handle{\currentmathradical}} @@ -98,10 +99,17 @@ \mutable\let\currentmathradical \empty \mutable\let\currentmathradicaldegree\empty -\tolerant\protected\def\math_radical_handle#tag#*[#degree]#:#body% +\setmathignore\Umathradicaldegreebefore\plusone + +\tolerant\protected\def\math_radical_handle#tag#*[#settings]#*[#degree]#:#body% {\begingroup \edef\currentmathradical{#tag}% - \edef\currentmathradicaldegree{#degree}% + \ifparameter#degree\or + \edef\currentmathradicaldegree{#degree}% + \setupcurrentmathradical[#settings]% + \else + \edef\currentmathradicaldegree{#settings}% + \fi \ifempty\currentmathradicaldegree \let\currentmathradicaldegree\m_math_no_degree \fi @@ -110,24 +118,38 @@ \def\m_math_no_degree{{}} +% for every font +% +% \appendtoks +% \Umathradicaldegreebefore\allmathstyles\zeropoint +% \to \everymathematics + % style width [options: left middle right] \def\math_radical_alternative{\csname\??mathradicalalternative\mathradicalparameter\c!alternative\endcsname} +\integerdef\c_radical_unicode "221A + +\protected\def\math_radical_common + {\Uroot + \s!source\numexpr\namedboxanchor{\mathradicalparameter\c!source}\relax + \s!style \normalmathstyle + \zerocount \c_radical_unicode} + \defcsname\??mathradicalalternative\v!default\endcsname % #body% - {\rootradical{\currentmathradicaldegree}} % {#body}} + {\math_radical_common{\currentmathradicaldegree}} % {#body}} \defcsname\??mathradicalalternative\v!normal\endcsname#body% {\edef\p_color{\mathradicalparameter\c!color}% \ifempty\p_color - \styledrootradical{\currentmathradicaldegree}{#body}% {} really needed as \rootradical expands first + \math_radical_common{\currentmathradicaldegree}{#body}% {} really needed as \rootradical expands first \orelse\ifempty\currentmathradicaldegree \pushcolor[\p_color]% - \styledrootradical{\currentmathradicaldegree}% + \math_radical_common{\currentmathradicaldegree}% {\popcolor#body}% \else \pushcolor[\p_color]% - \styledrootradical{\popcolor\currentmathradicaldegree\pushcolor[\p_color]}% + \math_radical_common{\popcolor\currentmathradicaldegree\pushcolor[\p_color]}% {\popcolor#body}% \fi} @@ -206,7 +228,8 @@ \c!mpoffset=.25\exheight] \appendtoks - \frozen\instance\setuevalue{\currentmathornament}{\math_ornament_handle{\currentmathornament}}% + \frozen\protected\instance\edefcsname\currentmathornament\endcsname + {\math_ornament_handle{\currentmathornament}}% \to \everydefinemathornament \protected\def\math_ornament_handle#tag#body% diff --git a/tex/context/base/mkxl/math-scr.mkxl b/tex/context/base/mkxl/math-scr.mkxl index 555f549f1..207f7fbf6 100644 --- a/tex/context/base/mkxl/math-scr.mkxl +++ b/tex/context/base/mkxl/math-scr.mkxl @@ -28,7 +28,7 @@ {\math_scripts_raised_symbol_indeed3\txx{#1}}} \def\math_scripts_raised_symbol_indeed#1#2#3% - {\mathord{{#2\raise.#1ex\hbox{#2\symbol[#3]}}}} + {\mathord{#2\raise.#1\exheight\hbox{#2\symbol[#3]}}} % redundant {} removed \def\math_scripts_raised_number#1% {\mathchoice diff --git a/tex/context/base/mkxl/math-spa.lmt b/tex/context/base/mkxl/math-spa.lmt new file mode 100644 index 000000000..35684847f --- /dev/null +++ b/tex/context/base/mkxl/math-spa.lmt @@ -0,0 +1,83 @@ +if not modules then modules = { } end modules ['math-spa'] = { + version = 1.001, + comment = "companion to math-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- for the moment (when testing) we use a penalty 1 + +local boundary_code = nodes.nodecodes.boundary +local glue_code = nodes.nodecodes.glue + +local nuts = nodes.nuts +local tonut = nodes.tonut +local tonode = nodes.tonode + +local getid = nuts.getid +local getnext = nuts.getnext +local getwidth = nuts.getwidth +local setglue = nuts.setglue +local getdimensions = nuts.dimensions +local nextglue = nuts.traversers.glue + +local texsetdimen = tex.setdimen + +local v_none = interfaces.variables.none +local v_auto = interfaces.variables.auto + +local method = v_none +local distance = 0 + +function noads.handlers.align(h) + if method ~= v_none then + if method == v_auto then + local s = h + while s do + local id = getid(s) + local n = getnext(s) + if id == boundary_code then -- check some type + if n and getid(n) == glue_code then + s = n + n = getnext(s) + end + local w = getdimensions(h,n) + distance + texsetdimen("global","d_strc_math_indent",w) + break + end + s = n + end + else + texsetdimen("global","d_strc_math_indent",distance) + end + for n in nextglue, h do + setglue(n,getwidth(n),0,0) + end + else + -- texsetdimen("global","d_strc_math_indent",0) + end +end + +interfaces.implement { + name = "setmathhang", + arguments = { + { + { "method", "string" }, + { "distance", "dimension" }, + } + }, + actions = function(t) + method = t.method or v_none + distance = t.distance or 0 + end +} + +interfaces.implement { + name = "resetmathhang", + actions = function(t) + method = v_none + distance = 0 + end +} + diff --git a/tex/context/base/mkxl/math-stc.mklx b/tex/context/base/mkxl/math-stc.mklx index 5ae8857dd..970e1352d 100644 --- a/tex/context/base/mkxl/math-stc.mklx +++ b/tex/context/base/mkxl/math-stc.mklx @@ -153,7 +153,7 @@ \let\math_stackers_skip \hskip} \def\math_stackers_skip_indeed#amount% - {\filledhboxk{\unsetteststrut\strut\hskip#amount}} % \dontshowstruts + {\filledhboxk{\strut\hskip#amount}} \let\math_stackers_start_tagged_mid\relax \let\math_stackers_start_tagged_top\relax @@ -179,7 +179,7 @@ \c!right=, \c!mathclass=\s!rel, \c!alternative=\v!normal, - \c!voffset=.25\mathexheight, + \c!voffset=.25\mathexheight, % maybe less \c!hoffset=\zeropoint, \c!topoffset=\zeropoint, % for manual italic correction \c!distance=\mathstackersparameter\c!voffset, % distance between symbol and base (can be different from voffset) @@ -492,9 +492,9 @@ \permanent\tolerant\protected\def\definemathextensible[#1]#*[#2]#*[#3]% category name unicode {\ifarguments\or\or - \frozen\setuevalue{#1}{\math_stackers_auto_normal\noexpand\currentmathstackers{\number#2}}% + \frozen\protected\edefcsname#1\endcsname{\math_stackers_auto_normal\noexpand\currentmathstackers{\number#2}}% \or - \frozen\setuevalue{#2}{\math_stackers_auto_normal{#1}{\number#3}}% + \frozen\protected\edefcsname#2\endcsname{\math_stackers_auto_normal{#1}{\number#3}}% \fi} \tolerant\protected\def\math_stackers_auto_normal#1#2#*[#3]#:#=#*#=% @@ -522,20 +522,6 @@ {\math_stackers_triplet\zerocount{#category}{#codepoint}{#toptext}{#bottomtext}% \endgroup} -%D The next one deals with under and over extensibles (arrows mostly): - -\installcorenamespace {mathclasses} - -\letcsname\??mathclasses \endcsname\mathord -\letcsname\??mathclasses rel\endcsname\mathrel -\letcsname\??mathclasses ord\endcsname\mathord - -\def\math_class_by_parameter#1% - {\normalexpanded{\noexpand\math_class_by_parameter_indeed{#1\c!mathclass}}} - -\def\math_class_by_parameter_indeed#1% - {\csname\??mathclasses\ifcsname\??mathclasses#1\endcsname#1\fi\endcsname} - % 1 0 name n 0 | 0 1 name n 0 | 1 1 name n n \let\math_stackers_stop_group\endgroup @@ -680,33 +666,33 @@ \permanent\tolerant\protected\def\definemathoverextensible[#1]#*[#2]#*[#3]% {\ifparameter#3\or - \frozen\setuevalue{#2}{\math_stackers_make_double\plusone \zerocount{#1}{\number#3}{0}}% + \frozen\protected\edefcsname#2\endcsname{\math_stackers_make_double\plusone \zerocount{#1}{\number#3}{0}}% \else - \frozen\setuevalue{#1}{\math_stackers_make_double\plusone \zerocount\noexpand\currentmathstackers{\number#2}{0}}% + \frozen\protected\edefcsname#1\endcsname{\math_stackers_make_double\plusone \zerocount\noexpand\currentmathstackers{\number#2}{0}}% \fi} \permanent\tolerant\protected\def\definemathunderextensible[#1]#*[#2]#*[#3]% {\ifparameter#3\or - \frozen\setuevalue{#2}{\math_stackers_make_double\zerocount\plusone{#1}{\number#3}{0}}% + \frozen\protected\edefcsname#2\endcsname{\math_stackers_make_double\zerocount\plusone{#1}{\number#3}{0}}% \else - \frozen\setuevalue{#1}{\math_stackers_make_double\zerocount\plusone\noexpand\currentmathstackers{\number#2}{0}}% + \frozen\protected\edefcsname#1\endcsname{\math_stackers_make_double\zerocount\plusone\noexpand\currentmathstackers{\number#2}{0}}% \fi} \permanent\tolerant\protected\def\definemathdoubleextensible[#1]#*[#2]#*[#3]#*[#4]% {\ifparameter#4\or - \frozen\setuevalue{#2}{\math_stackers_make_double\plusone \plusone{#1}{\number#3}{\number#4}}% + \frozen\protected\edefcsname#2\endcsname{\math_stackers_make_double\plusone \plusone{#1}{\number#3}{\number#4}}% \else - \frozen\setuevalue{#1}{\math_stackers_make_double\plusone \plusone\noexpand\currentmathstackers{\number#2}{\number#3}}% + \frozen\protected\edefcsname#1\endcsname{\math_stackers_make_double\plusone \plusone\noexpand\currentmathstackers{\number#2}{\number#3}}% \fi} \permanent\tolerant\protected\def\definemathover[#category]#spacer[#command]#spacer[#topcode]% - {\frozen\setuvalue{#command}{\math_stackers_handle_direct\plusone\zerocount{#category}{#topcode}{0}}} + {\frozen\protected\defcsname#command\endcsname{\math_stackers_handle_direct\plusone\zerocount{#category}{#topcode}{0}}} \permanent\tolerant\protected\def\definemathunder[#category]#spacer[#command]#spacer[#bottomcode]% - {\frozen\setuvalue{#command}{\math_stackers_handle_direct\zerocount\plusone{#category}{#bottomcode}{0}}} + {\frozen\protected\defcsname#command\endcsname{\math_stackers_handle_direct\zerocount\plusone{#category}{#bottomcode}{0}}} \permanent\tolerant\protected\def\definemathdouble[#category]#spacer[#command]#spacer[#topcode]#spacer[#bottomcode]% - {\frozen\setuvalue{#command}{\math_stackers_handle_direct\plusone\plusone{#category}{#topcode}{#bottomcode}}} + {\frozen\protected\defcsname#command\endcsname{\math_stackers_handle_direct\plusone\plusone{#category}{#topcode}{#bottomcode}}} \permanent\tolerant\protected\def\mathover[#category]#spacer[#settings]#:#topcode#text% {\begingroup @@ -883,16 +869,16 @@ \permanent\tolerant\protected\def\definemathovertextextensible[#1]#*[#2]#*[#3]% {\ifparameter#3\or - \frozen\setuevalue{#2}{\math_stackers_make_double_text\plusone{#1}{\number#3}}% + \frozen\protected\edefcsname#2\endcsname{\math_stackers_make_double_text\plusone{#1}{\number#3}}% \else - \frozen\setuevalue{#1}{\math_stackers_make_double_text\plusone\noexpand\currentmathstackers{\number#2}}% + \frozen\protected\edefcsname#1\endcsname{\math_stackers_make_double_text\plusone\noexpand\currentmathstackers{\number#2}}% \fi} \permanent\tolerant\protected\def\definemathundertextextensible[#1]#*[#2]#*[#3]% {\ifparameter#3\or - \frozen\setuevalue{#2}{\math_stackers_make_double_text\zerocount{#1}{\number#3}}% + \frozen\protected\edefcsname#2\endcsname{\math_stackers_make_double_text\zerocount{#1}{\number#3}}% \else - \frozen\setuevalue{#1}{\math_stackers_make_double_text\zerocount\noexpand\currentmathstackers{\number#2}}% + \frozen\protected\edefcsname#1\endcsname{\math_stackers_make_double_text\zerocount\noexpand\currentmathstackers{\number#2}}% \fi} \permanent\tolerant\protected\def\mathovertext[#category]% @@ -917,11 +903,11 @@ \permanent\tolerant\protected\def\definemathtriplet[#1]#*[#2]#*[#3]% category name default {\ifarguments\or - \frozen\setuevalue{#1}{\math_stackers_auto_triplet_nop[\noexpand\currentmathstackers]}% + \frozen\protected\edefcsname#1\endcsname{\math_stackers_auto_triplet_nop[\noexpand\currentmathstackers]}% \or - \frozen\setuevalue{#2}{\math_stackers_auto_triplet_nop[#1]}% + \frozen\protected\edefcsname#2\endcsname{\math_stackers_auto_triplet_nop[#1]}% \or - \frozen\setuevalue{#2}{\math_stackers_auto_triplet_yes[#1][#3]}% + \frozen\protected\edefcsname#2\endcsname{\math_stackers_auto_triplet_yes[#1][#3]}% \fi} \tolerant\protected\def\math_stackers_auto_triplet_yes[#1][#2]#*[#3]#:#=#*#=% [#2]% #2 gobble spaces @@ -1171,39 +1157,78 @@ % alternatively we can move the original to FE* -\definemathoverextensible [\v!vfenced] [overbar] ["FE33E] % ["203E] -\definemathunderextensible [\v!vfenced] [underbar] ["FE33F] % ["203E] -\definemathdoubleextensible [\v!vfenced] [doublebar] ["FE33E] ["FE33F] +% \definemathoverextensible [\v!vfenced] [overbar] ["FE33E] % ["203E] +% \definemathunderextensible [\v!vfenced] [underbar] ["FE33F] % ["203E] +% \definemathdoubleextensible [\v!vfenced] [doublebar] ["FE33E] ["FE33F] +% +% \definemathoverextensible [\v!vfenced] [overbrace] ["FE3DE] % ["023DE] +% \definemathunderextensible [\v!vfenced] [underbrace] ["FE3DF] % ["023DF] +% \definemathdoubleextensible [\v!vfenced] [doublebrace] ["FE3DE] ["FE3DF] +% +% \definemathoverextensible [\v!vfenced] [overparent] ["FE3DC] % ["023DC] +% \definemathunderextensible [\v!vfenced] [underparent] ["FE3DD] % ["023DD] +% \definemathdoubleextensible [\v!vfenced] [doubleparent] ["FE3DC] ["FE3DD] +% +% \definemathoverextensible [\v!vfenced] [overbracket] ["FE3B4] % ["023B4] +% \definemathunderextensible [\v!vfenced] [underbracket] ["FE3B5] % ["023B5] +% \definemathdoubleextensible [\v!vfenced] [doublebracket] ["FE3B4] ["FE3B5] + +% \definemathoverextensible [\v!vfenced] [overbar] ["203E] +% \definemathunderextensible [\v!vfenced] [underbar] ["203E] +% \definemathdoubleextensible [\v!vfenced] [doublebar] ["203E] ["203E] -\definemathoverextensible [\v!vfenced] [overbrace] ["FE3DE] % ["023DE] -\definemathunderextensible [\v!vfenced] [underbrace] ["FE3DF] % ["023DF] -\definemathdoubleextensible [\v!vfenced] [doublebrace] ["FE3DE] ["FE3DF] +\definemathoverextensible [\v!vfenced] [overbar] ["203E] +\definemathunderextensible [\v!vfenced] [underbar] ["203E] % ["0332] +\definemathdoubleextensible [\v!vfenced] [doublebar] ["203E] ["203E] % ["0332] -\definemathoverextensible [\v!vfenced] [overparent] ["FE3DC] % ["023DC] -\definemathunderextensible [\v!vfenced] [underparent] ["FE3DD] % ["023DD] -\definemathdoubleextensible [\v!vfenced] [doubleparent] ["FE3DC] ["FE3DD] +\definemathoverextensible [\v!vfenced] [overbrace] ["23DE] +\definemathunderextensible [\v!vfenced] [underbrace] ["23DF] +\definemathdoubleextensible [\v!vfenced] [doublebrace] ["23DE] ["23DF] -\definemathoverextensible [\v!vfenced] [overbracket] ["FE3B4] % ["023B4] -\definemathunderextensible [\v!vfenced] [underbracket] ["FE3B5] % ["023B5] -\definemathdoubleextensible [\v!vfenced] [doublebracket] ["FE3B4] ["FE3B5] +\definemathoverextensible [\v!vfenced] [overparent] ["23DC] +\definemathunderextensible [\v!vfenced] [underparent] ["23DD] +\definemathdoubleextensible [\v!vfenced] [doubleparent] ["23DC] ["23DD] + +\definemathoverextensible [\v!vfenced] [overbracket] ["23B4] +\definemathunderextensible [\v!vfenced] [underbracket] ["23B5] +\definemathdoubleextensible [\v!vfenced] [doublebracket] ["23B4] ["23B5] + +% If we do this, we need to adapt the dimensions, so wel leave them accents: +% +% \definemathoverextensible[\v!vfenced][widebar] ["0305] +% \definemathoverextensible[\v!vfenced][widetilde]["0303] % \protected\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits} %D For mathml: -\definemathdoubleextensible [\v!both] [overbarunderbar] ["FE33E] ["FE33F] -\definemathdoubleextensible [\v!both] [overbraceunderbrace] ["FE3DE] ["FE3DF] -\definemathdoubleextensible [\v!both] [overparentunderparent] ["FE3DC] ["FE3DD] -\definemathdoubleextensible [\v!both] [overbracketunderbracket] ["FE3B4] ["FE3B5] - -\definemathovertextextensible [\v!bothtext] [overbartext] ["FE33E] -\definemathundertextextensible [\v!bothtext] [underbartext] ["FE33F] -\definemathovertextextensible [\v!bothtext] [overbracetext] ["FE3DE] -\definemathundertextextensible [\v!bothtext] [underbracetext] ["FE3DF] -\definemathovertextextensible [\v!bothtext] [overparenttext] ["FE3DC] -\definemathundertextextensible [\v!bothtext] [underparenttext] ["FE3DD] -\definemathovertextextensible [\v!bothtext] [overbrackettext] ["FE3B4] -\definemathundertextextensible [\v!bothtext] [underbrackettext] ["FE3B5] +% \definemathdoubleextensible [\v!both] [overbarunderbar] ["FE33E] ["FE33F] +% \definemathdoubleextensible [\v!both] [overbraceunderbrace] ["FE3DE] ["FE3DF] +% \definemathdoubleextensible [\v!both] [overparentunderparent] ["FE3DC] ["FE3DD] +% \definemathdoubleextensible [\v!both] [overbracketunderbracket] ["FE3B4] ["FE3B5] +% +% \definemathovertextextensible [\v!bothtext] [overbartext] ["FE33E] +% \definemathundertextextensible [\v!bothtext] [underbartext] ["FE33F] +% \definemathovertextextensible [\v!bothtext] [overbracetext] ["FE3DE] +% \definemathundertextextensible [\v!bothtext] [underbracetext] ["FE3DF] +% \definemathovertextextensible [\v!bothtext] [overparenttext] ["FE3DC] +% \definemathundertextextensible [\v!bothtext] [underparenttext] ["FE3DD] +% \definemathovertextextensible [\v!bothtext] [overbrackettext] ["FE3B4] +% \definemathundertextextensible [\v!bothtext] [underbrackettext] ["FE3B5] + +\definemathdoubleextensible [\v!both] [overbarunderbar] ["203E] ["203E] +\definemathdoubleextensible [\v!both] [overbraceunderbrace] ["23DE] ["23DF] +\definemathdoubleextensible [\v!both] [overparentunderparent] ["23DC] ["23DD] +\definemathdoubleextensible [\v!both] [overbracketunderbracket] ["23B4] ["23B5] + +\definemathovertextextensible [\v!bothtext] [overbartext] ["203E] +\definemathundertextextensible [\v!bothtext] [underbartext] ["203E] +\definemathovertextextensible [\v!bothtext] [overbracetext] ["23DE] +\definemathundertextextensible [\v!bothtext] [underbracetext] ["23DF] +\definemathovertextextensible [\v!bothtext] [overparenttext] ["23DC] +\definemathundertextextensible [\v!bothtext] [underparenttext] ["23DD] +\definemathovertextextensible [\v!bothtext] [overbrackettext] ["23B4] +\definemathundertextextensible [\v!bothtext] [underbrackettext] ["23B5] %D Some bonus ones (for the moment here): @@ -1326,9 +1351,9 @@ \permanent\tolerant\protected\def\definemathunstacked[#1]#*[#2]#*[#3]% category name unicode {\ifarguments\or\or - \frozen\setuevalue{#1}{\math_stackers_unstacked_normal\noexpand\currentmathstackers{\number#2}}% + \frozen\protected\edefcsname#1\endcsname{\math_stackers_unstacked_normal\noexpand\currentmathstackers{\number#2}}% \else - \frozen\setuevalue{#2}{\math_stackers_unstacked_normal{#1}{\number#3}}% + \frozen\protected\edefcsname#2\endcsname{\math_stackers_unstacked_normal{#1}{\number#3}}% \fi} \protected\def\math_stackers_unstacked_normal#category#codepoint% diff --git a/tex/context/base/mkxl/math-tag.lmt b/tex/context/base/mkxl/math-tag.lmt index 9ecc7047a..429191546 100644 --- a/tex/context/base/mkxl/math-tag.lmt +++ b/tex/context/base/mkxl/math-tag.lmt @@ -98,7 +98,6 @@ local chardata = characters.data local getmathcodes = tex.getmathcodes local mathcodes = mathematics.codes local ordinary_mathcode = mathcodes.ordinary -local variable_mathcode = mathcodes.variable local fromunicode16 = fonts.mappings.fromunicode16 local fontcharacters = fonts.hashes.characters @@ -223,7 +222,8 @@ process = function(start) -- we cannot use the processor as we have no finalizer local char = getchar(start) local code = getmathcodes(char) local tag - if code == ordinary_mathcode or code == variable_mathcode then + -- todo: we have way more now + if code == ordinary_mathcode then local ch = chardata[char] local mc = ch and ch.mathclass if mc == "number" then diff --git a/tex/context/base/mkxl/math-vfu.lmt b/tex/context/base/mkxl/math-vfu.lmt index abe336f53..0540331ab 100644 --- a/tex/context/base/mkxl/math-vfu.lmt +++ b/tex/context/base/mkxl/math-vfu.lmt @@ -85,7 +85,7 @@ local shared = { } local function brace(main,characters,id,size,unicode,first,rule,left,right,rule,last) if not characters[unicode] then characters[unicode] = { - hvariants = { + hparts = { { extender = 0, glyph = first }, { extender = 1, glyph = rule }, { extender = 0, glyph = left }, @@ -123,7 +123,7 @@ local function extension(main,characters,id,size,unicode,first,middle,last) if lw == 0 then lw = 1 end - chr.hvariants = { + chr.hparts = { { extender = 0, glyph = first, ["end"] = fw/2, start = 0, advance = fw }, { extender = 1, glyph = middle, ["end"] = mw/2, start = mw/2, advance = mw }, { extender = 0, glyph = last, ["end"] = 0, start = lw/2, advance = lw }, @@ -133,7 +133,7 @@ end local function parent(main,characters,id,size,unicode,first,rule,last) if not characters[unicode] then characters[unicode] = { - hvariants = { + hparts = { { extender = 0, glyph = first }, { extender = 1, glyph = rule }, { extender = 0, glyph = last }, @@ -661,10 +661,10 @@ local function copy_glyph(main,target,original,unicode,slot) break -- safeguard (when testing stuff) end end - local hv = olddata.hvariants + local hv = olddata.hparts if hv then hv = fastcopy(hv) - newdata.hvariants = hv + newdata.hparts = hv for i=1,#hv do local hvi = hv[i] local oldglyph = hvi.glyph @@ -679,10 +679,10 @@ local function copy_glyph(main,target,original,unicode,slot) hvi.glyph = addprivate(main,formatters["M-H-%H"](oldglyph),newdata) end end - local vv = olddata.vvariants + local vv = olddata.vparts if vv then vv = fastcopy(vv) - newdata.vvariants = vv + newdata.vparts = vv for i=1,#vv do local vvi = vv[i] local oldglyph = vvi.glyph @@ -1017,30 +1017,30 @@ function vfmath.define(specification,set,goodies) if n then t.next = offset + n elseif variants_done then - local vv = fci.vvariants + local vv = fci.vparts if vv then - t.vvariants = vv + t.vparts = vv end - local hv = fci.hvariants + local hv = fci.hparts if hv then - t.hvariants = hv + t.hparts = hv end else - local vv = fci.vvariants + local vv = fci.vparts if vv then for i=1,#vv do local vvi = vv[i] vvi.glyph = vvi.glyph + offset end - t.vvariants = vv + t.vparts = vv end - local hv = fci.hvariants + local hv = fci.hparts if hv then for i=1,#hv do local hvi = hv[i] hvi.glyph = hvi.glyph + offset end - t.hvariants = hv + t.hparts = hv end end characters[offset + index] = t @@ -1122,13 +1122,18 @@ function vfmath.define(specification,set,goodies) main.properties.math_is_scaled = true -- signal fonts.constructors.assignmathparameters(main,main) -- - main.MathConstants = main.mathparameters -- we directly pass it to TeX (bypasses the scaler) so this is needed + main.mathconstants = main.mathparameters -- we directly pass it to TeX (bypasses the scaler) so this is needed -- if trace_virtual or trace_timings then report_virtual("loading and virtualizing font %a at size %p took %0.3f seconds",name,size,os.clock()-start) end -- - main.oldmath = true + -- main.oldmath = true + -- + -- We bypass the scaler so ... + -- + main.MathConstants = main.mathconstants + main.nomath = false return main end diff --git a/tex/context/base/mkxl/mlib-int.lmt b/tex/context/base/mkxl/mlib-int.lmt index 208370a3c..e294a4fe5 100644 --- a/tex/context/base/mkxl/mlib-int.lmt +++ b/tex/context/base/mkxl/mlib-int.lmt @@ -153,18 +153,18 @@ registerdirect("OverlayRegion", function() return getmacro("m_overlay_reg -- registerscript("OnRightPage", function() return mpboolean(on_right_page ()) end) -- registerscript("OnOddPage", function() return mpboolean(is_odd_page ()) end) -- registerscript("InPageBody", function() return mpboolean(in_body_page ()) end) --- registerscript("LayoutHasChanged", function() return mpboolean(layout_has_changed()) end) registerdirect("PageFraction", function() return page_fraction () end) registerdirect("OnRightPage", function() return on_right_page () end) registerdirect("OnOddPage", function() return is_odd_page () end) registerdirect("InPageBody", function() return in_body_page () end) -registerdirect("LayoutHasChanged", function() return layout_has_changed() end) +registerdirect("LastChangedLayoutPage",function() return getcount("c_page_layouts_changed") end) +registerdirect("SwapMarginDimensions", function() token.expandmacro("swapmargindimensions") end) registerdirect("PageFraction", page_fraction ) registerdirect("OnRightPage", on_right_page ) registerdirect("OnOddPage", is_odd_page ) registerdirect("InPageBody", in_body_page ) -registerdirect("LayoutHasChanged", layout_has_changed) +-- registerdirect("LayoutHasChanged", layout_has_changed) registerdirect("defaultcolormodel", defaultcolormodel) diff --git a/tex/context/base/mkxl/mult-aux.mkxl b/tex/context/base/mkxl/mult-aux.mkxl index 864516ad5..e5850668b 100644 --- a/tex/context/base/mkxl/mult-aux.mkxl +++ b/tex/context/base/mkxl/mult-aux.mkxl @@ -1073,6 +1073,22 @@ \expandafter\noexpand\csname current#2parent\endcsname \expandafter\noexpand\csname inject#2parent\endcsname}} +%D Cheaper (assumes grouping at some point): + +\permanent\protected\def\mult_interfaces_install_local_current_injector#1#2#3#4% + {\protected\def#4##1% + {\advance#2\plusone + \edef#3{##1:\the#2}% \currentXXX + \edefcsname#1#3:\s!parent\endcsname{#1##1}}} + +\permanent\protected\def\installlocalcurrenthandler#1#2% \??XXX {XXX} + {\expandafter\newcount\csname#1:\s!counter\endcsname + \normalexpanded{\mult_interfaces_install_local_current_injector + {\noexpand#1}% + \expandafter\noexpand\csname #1:\s!counter\endcsname + \expandafter\noexpand\csname current#2\endcsname + \expandafter\noexpand\csname setlocal#2current\endcsname}} + % The \LUA\ based variant is twice as fast as the above but as said, we don't use % this one that often. It's more about less tracing than speed here. diff --git a/tex/context/base/mkxl/mult-sys.mkxl b/tex/context/base/mkxl/mult-sys.mkxl index 1eae000e4..9ac124808 100644 --- a/tex/context/base/mkxl/mult-sys.mkxl +++ b/tex/context/base/mkxl/mult-sys.mkxl @@ -114,12 +114,14 @@ \definesystemconstant {all} \definesystemconstant {ampersand} \definesystemconstant {anchor} +\definesystemconstant {anchors} \definesystemconstant {ascii} \definesystemconstant {attribute} \definesystemconstant {attr} \definesystemconstant {author} \definesystemconstant {auto} \definesystemconstant {axis} +\definesystemconstant {noaxis} \definesystemconstant {exact} \definesystemconstant {a} \definesystemconstant {bf} @@ -151,9 +153,12 @@ \definesystemconstant {cg} \definesystemconstant {chain} \definesystemconstant {check} +\definesystemconstant {char} \definesystemconstant {child} \definesystemconstant {cite} \definesystemconstant {class} +\definesystemconstant {leftclass} +\definesystemconstant {rightclass} \definesystemconstant {clone} \definesystemconstant {cmyk} \definesystemconstant {cm} @@ -198,6 +203,7 @@ \definesystemconstant {fallbacks} \definesystemconstant {fallback} \definesystemconstant {false} +\definesystemconstant {fam} \definesystemconstant {fax} \definesystemconstant {features} \definesystemconstant {file} @@ -205,6 +211,7 @@ \definesystemconstant {fill} \definesystemconstant {fil} \definesystemconstant {first} +\definesystemconstant {fixed} \definesystemconstant {float} \definesystemconstant {font} \definesystemconstant {forget} @@ -226,6 +233,7 @@ \definesystemconstant {hastitle} \definesystemconstant {head} \definesystemconstant {height} +\definesystemconstant {hfactor} \definesystemconstant {hw} \definesystemconstant {hyphenmin} \definesystemconstant {indeed} @@ -380,7 +388,8 @@ \definesystemconstant {Support} \definesystemconstant {sygreek} \definesystemconstant {symbol} -\definesystemconstant {system} % not yet interfaces messages +\definesystemconstant {system} +\definesystemconstant {style} \definesystemconstant {text} \definesystemconstant {tex} \definesystemconstant {tf} @@ -397,12 +406,14 @@ \definesystemconstant {ucgreek} \definesystemconstant {uncramped} \definesystemconstant {unexpanded} -\definesystemconstant {Unicode} +\definesystemconstant {unpack} \definesystemconstant {unknown} +\definesystemconstant {Unicode} \definesystemconstant {userdata} \definesystemconstant {userpage} \definesystemconstant {user} \definesystemconstant {vfrac} +\definesystemconstant {vfactor} \definesystemconstant {white} \definesystemconstant {width} \definesystemconstant {xml} diff --git a/tex/context/base/mkxl/node-bck.mkxl b/tex/context/base/mkxl/node-bck.mkxl index 3c2fa015c..357180710 100644 --- a/tex/context/base/mkxl/node-bck.mkxl +++ b/tex/context/base/mkxl/node-bck.mkxl @@ -76,7 +76,7 @@ \permanent\protected\def\backgroundline{\dontleavehmode\node_backgrounds_boxes_add\hbox} \def\node_backgrounds_boxes_add#1[#2]% - {\clf_enablebackgroundboxes + {\localcontrolled{\clf_enablebackgroundboxes}% permits assignment #1\backgroundcolorattr{#2}} \protect \endinput diff --git a/tex/context/base/mkxl/node-ini.lmt b/tex/context/base/mkxl/node-ini.lmt index 2b09485db..75a97408b 100644 --- a/tex/context/base/mkxl/node-ini.lmt +++ b/tex/context/base/mkxl/node-ini.lmt @@ -20,32 +20,16 @@ local sortedhash, sortedkeys, swapped = table.sortedhash, table.sortedkeys, tabl few helper functions. These functions are rather optimized.</p> --ldx]]-- -nodes = nodes or { } -local nodes = nodes -nodes.handlers = nodes.handlers or { } +nodes = nodes or { } +local nodes = nodes +nodes.handlers = nodes.handlers or { } -local mark = utilities.storage.mark -local allocate = utilities.storage.allocate -local formatcolumns = utilities.formatters.formatcolumns +local mark = utilities.storage.mark +local allocate = utilities.storage.allocate +local formatcolumns = utilities.formatters.formatcolumns -local getsubtypes = node.subtypes -local getvalues = node.values - -tex.magicconstants = { -- we use tex.constants for something else - running = -1073741824, -- null_flag - maxdimen = 1073741823, -- max_dimen - -- trueinch = 4736286, -- obsolete -} - -do - local c = status.getconstants() - local t = { } - for k, v in next, c do - t[gsub(k,"_","")] = v - end - - tex.magicconstants = table.setmetatableindex(t,c) -end +local getsubtypes = node.subtypes +local getvalues = node.values local listcodes = mark(getsubtypes("list")) local rulecodes = mark(getsubtypes("rule")) @@ -151,6 +135,7 @@ noadcodes.rel = noadcodes.rel or noadcodes.relation noadcodes.punct = noadcodes.punct or noadcodes.punctuation noadcodes.rad = noadcodes.rad or noadcodes.radical noadcodes.frac = noadcodes.frac or noadcodes.fraction +noadcodes.acc = noadcodes.acc or noadcodes.accent -- so for now: @@ -161,6 +146,7 @@ noadcodes.relation = noadcodes.relation or noadcodes.rel noadcodes.punctuation = noadcodes.punctuation or noadcodes.punct noadcodes.radical = noadcodes.radical or noadcodes.rad noadcodes.fraction = noadcodes.fraction or noadcodes.frac +noadcodes.accent = noadcodes.accent or noadcodes.acc local subtypes = allocate { glue = gluecodes, diff --git a/tex/context/base/mkxl/node-res.lmt b/tex/context/base/mkxl/node-res.lmt index 93dc65b7b..da4283e7f 100644 --- a/tex/context/base/mkxl/node-res.lmt +++ b/tex/context/base/mkxl/node-res.lmt @@ -181,12 +181,13 @@ local lefttoright_code = nodes.dirvalues.lefttoright local rule = register_nut(new_nut(rule_code)) -- setdirection(rule, lefttoright_code) local emptyrule = register_nut(new_nut(rule_code,rulecodes.empty)) -- setdirection(rule, lefttoright_code) +local strutrule = register_nut(new_nut(rule_code,rulecodes.strut)) -- setdirection(rule, lefttoright_code) local userrule = register_nut(new_nut(rule_code,rulecodes.user)) -- setdirection(rule, lefttoright_code) local outlinerule = register_nut(new_nut(rule_code,rulecodes.outline)) -- setdirection(rule, lefttoright_code) local imagerule = register_nut(new_nut(rule_code,rulecodes.image)) -- setdirection(rule, lefttoright_code) local boxrule = register_nut(new_nut(rule_code,rulecodes.box)) -- setdirection(rule, lefttoright_code) -local hlist = register_nut(new_nut(nodecodes.hlist)) setdirection(hlist,lefttoright_code) -local vlist = register_nut(new_nut(nodecodes.vlist)) setdirection(vlist,lefttoright_code) +local hlist = register_nut(new_nut(nodecodes.hlist)) setdirection(hlist,lefttoright_code) +local vlist = register_nut(new_nut(nodecodes.vlist)) setdirection(vlist,lefttoright_code) function nutpool.glyph(fnt,chr) local n = copy_nut(glyph) @@ -357,6 +358,14 @@ function nutpool.emptyrule(width,height,depth) -- w/h/d == nil will let them ada return n end +function nutpool.strutrule(width,height,depth) -- w/h/d == nil will let them adapt + local n = copy_nut(strutrule) + if width or height or depth then + setwhd(n,width,height,depth) + end + return n +end + function nutpool.userrule(width,height,depth) -- w/h/d == nil will let them adapt local n = copy_nut(userrule) if width or height or depth then diff --git a/tex/context/base/mkxl/norm-ctx.mkxl b/tex/context/base/mkxl/norm-ctx.mkxl index fb67c5f24..0ec925896 100644 --- a/tex/context/base/mkxl/norm-ctx.mkxl +++ b/tex/context/base/mkxl/norm-ctx.mkxl @@ -15,118 +15,8 @@ %D A few more might end up here (like the weird ones in syst-ini). -\let\normalreqno\normaleqno - -% more friendly in setups: - -\aliased\let\ordordspacing \Umathordordspacing -\aliased\let\ordopspacing \Umathordopspacing -\aliased\let\ordbinspacing \Umathordbinspacing -\aliased\let\ordrelspacing \Umathordrelspacing -\aliased\let\ordopenspacing \Umathordopenspacing -\aliased\let\ordclosespacing \Umathordclosespacing -\aliased\let\ordpunctspacing \Umathordpunctspacing -\aliased\let\ordinnerspacing \Umathordinnerspacing -\aliased\let\ordfracspacing \Umathordfracspacing -\aliased\let\ordradspacing \Umathordradspacing - -\aliased\let\opordspacing \Umathopordspacing -\aliased\let\opopspacing \Umathopopspacing -\aliased\let\opbinspacing \Umathopbinspacing -\aliased\let\oprelspacing \Umathoprelspacing -\aliased\let\opopenspacing \Umathopopenspacing -\aliased\let\opclosespacing \Umathopclosespacing -\aliased\let\oppunctspacing \Umathoppunctspacing -\aliased\let\opinnerspacing \Umathopinnerspacing -\aliased\let\opfracspacing \Umathopfracspacing -\aliased\let\opradspacing \Umathopradspacing - -\aliased\let\binordspacing \Umathbinordspacing -\aliased\let\binopspacing \Umathbinopspacing -\aliased\let\binbinspacing \Umathbinbinspacing -\aliased\let\binrelspacing \Umathbinrelspacing -\aliased\let\binopenspacing \Umathbinopenspacing -\aliased\let\binclosespacing \Umathbinclosespacing -\aliased\let\binpunctspacing \Umathbinpunctspacing -\aliased\let\bininnerspacing \Umathbininnerspacing -\aliased\let\binfracspacing \Umathbinfracspacing -\aliased\let\binradspacing \Umathbinradspacing - -\aliased\let\relordspacing \Umathrelordspacing -\aliased\let\relopspacing \Umathrelopspacing -\aliased\let\relbinspacing \Umathrelbinspacing -\aliased\let\relrelspacing \Umathrelrelspacing -\aliased\let\relopenspacing \Umathrelopenspacing -\aliased\let\relclosespacing \Umathrelclosespacing -\aliased\let\relpunctspacing \Umathrelpunctspacing -\aliased\let\relinnerspacing \Umathrelinnerspacing -\aliased\let\relfracspacing \Umathrelfracspacing -\aliased\let\relradspacing \Umathrelradspacing - -\aliased\let\openordspacing \Umathopenordspacing -\aliased\let\openopspacing \Umathopenopspacing -\aliased\let\openbinspacing \Umathopenbinspacing -\aliased\let\openrelspacing \Umathopenrelspacing -\aliased\let\openopenspacing \Umathopenopenspacing -\aliased\let\openclosespacing \Umathopenclosespacing -\aliased\let\openpunctspacing \Umathopenpunctspacing -\aliased\let\openinnerspacing \Umathopeninnerspacing -\aliased\let\openfracspacing \Umathopenfracspacing -\aliased\let\openradspacing \Umathopenradspacing - -\aliased\let\closeordspacing \Umathcloseordspacing -\aliased\let\closeopspacing \Umathcloseopspacing -\aliased\let\closebinspacing \Umathclosebinspacing -\aliased\let\closerelspacing \Umathcloserelspacing -\aliased\let\closeopenspacing \Umathcloseopenspacing -\aliased\let\closeclosespacing \Umathcloseclosespacing -\aliased\let\closepunctspacing \Umathclosepunctspacing -\aliased\let\closeinnerspacing \Umathcloseinnerspacing -\aliased\let\closefracspacing \Umathclosefracspacing -\aliased\let\closeradspacing \Umathcloseradspacing - -\aliased\let\punctordspacing \Umathpunctordspacing -\aliased\let\punctopspacing \Umathpunctopspacing -\aliased\let\punctbinspacing \Umathpunctbinspacing -\aliased\let\punctrelspacing \Umathpunctrelspacing -\aliased\let\punctopenspacing \Umathpunctopenspacing -\aliased\let\punctclosespacing \Umathpunctclosespacing -\aliased\let\punctpunctspacing \Umathpunctpunctspacing -\aliased\let\punctinnerspacing \Umathpunctinnerspacing -\aliased\let\punctfracspacing \Umathpunctfracspacing -\aliased\let\punctradspacing \Umathpunctradspacing - -\aliased\let\innerordspacing \Umathinnerordspacing -\aliased\let\inneropspacing \Umathinneropspacing -\aliased\let\innerbinspacing \Umathinnerbinspacing -\aliased\let\innerrelspacing \Umathinnerrelspacing -\aliased\let\inneropenspacing \Umathinneropenspacing -\aliased\let\innerclosespacing \Umathinnerclosespacing -\aliased\let\innerpunctspacing \Umathinnerpunctspacing -\aliased\let\innerinnerspacing \Umathinnerinnerspacing -\aliased\let\innerfracspacing \Umathinnerfracspacing -\aliased\let\innerradspacing \Umathinnerradspacing - -\aliased\let\fracordspacing \Umathfracordspacing -\aliased\let\fracopspacing \Umathfracopspacing -\aliased\let\fracbinspacing \Umathfracbinspacing -\aliased\let\fracrelspacing \Umathfracrelspacing -\aliased\let\fracopenspacing \Umathfracopenspacing -\aliased\let\fracclosespacing \Umathfracclosespacing -\aliased\let\fracpunctspacing \Umathfracpunctspacing -\aliased\let\fracinnerspacing \Umathfracinnerspacing -\aliased\let\fracfracspacing \Umathfracfracspacing -\aliased\let\fracradspacing \Umathfracradspacing - -\aliased\let\radordspacing \Umathradordspacing -\aliased\let\radopspacing \Umathradopspacing -\aliased\let\radbinspacing \Umathradbinspacing -\aliased\let\radrelspacing \Umathradrelspacing -\aliased\let\radopenspacing \Umathradopenspacing -\aliased\let\radclosespacing \Umathradclosespacing -\aliased\let\radpunctspacing \Umathradpunctspacing -\aliased\let\radinnerspacing \Umathradinnerspacing -\aliased\let\radfracspacing \Umathradfracspacing -\aliased\let\radradspacing \Umathradradspacing +\let\normalreqno \normaleqno +%let\mathtopaccent \normaloverline +%let\mathbottomaccent\normalunderline \protect \endinput diff --git a/tex/context/base/mkxl/pack-box.mkxl b/tex/context/base/mkxl/pack-box.mkxl index 9ed90a885..831ec1707 100644 --- a/tex/context/base/mkxl/pack-box.mkxl +++ b/tex/context/base/mkxl/pack-box.mkxl @@ -1118,13 +1118,13 @@ [\c!width=\overlaywidth,\c!height=\overlayheight] {\overlayimage{#1}}} -%D Here is an end December 2021 experimental feature: anchored boxes. This will move to -%D pack-box.mkxl +%D Here is an end December 2021 experimental feature: anchored boxes. \installcorenamespace{boxanchor} \installcorenamespace{boxanchorid} \installcorenamespace{boxanchorbox} \installcorenamespace{boxpreset} +\installcorenamespace{boxanchors} \installparameterhandler \??boxanchor {boxanchor} \installsetuphandler \??boxanchor {boxanchor} @@ -1221,16 +1221,16 @@ \expandafter\integerdef\csname\??boxpreset\v!left,\v!top \endcsname\leftheightlistanchorcode \expandafter\integerdef\csname\??boxpreset\v!left,\v!depth \endcsname\leftdepthlistanchorcode \expandafter\integerdef\csname\??boxpreset\v!left,\v!bottom \endcsname\leftdepthlistanchorcode -% + \expandafter\integerdef\csname\??boxpreset\v!right \endcsname\rightoriginlistanchorcode \expandafter\integerdef\csname\??boxpreset\v!right,\v!height \endcsname\rightheightlistanchorcode \expandafter\integerdef\csname\??boxpreset\v!right,\v!top \endcsname\rightheightlistanchorcode \expandafter\integerdef\csname\??boxpreset\v!right,\v!depth \endcsname\rightdepthlistanchorcode \expandafter\integerdef\csname\??boxpreset\v!right,\v!bottom \endcsname\rightdepthlistanchorcode -% \centeroriginlistanchorcode -% \centerheightlistanchorcode -% \centerdepthlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!line \endcsname\centeroriginlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!height \endcsname\centerheightlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!depth \endcsname\centerdepthlistanchorcode \expandafter\integerdef\csname\??boxpreset\v!middle \endcsname\halfwaytotallistanchorcode \expandafter\integerdef\csname\??boxpreset\v!middle,\v!height\endcsname\halfwayheightlistanchorcode @@ -1240,6 +1240,67 @@ \expandafter\integerdef\csname\??boxpreset\v!middle,\v!left \endcsname\halfwayleftlistanchorcode \expandafter\integerdef\csname\??boxpreset\v!middle,\v!right \endcsname\halfwayrightlistanchorcode +% Musical timestamp: 2022-02-07 while listening Hypneurotic from The Blurred Horizon (n times); +% Jim Matheos with Gavin Harrison; very hypnotic indeed. + +\permanent\def\boxanchorpresetcode#1% + {\ifcsname\??boxpreset#1\endcsname\lastnamedcs\else\halfwaytotallistanchorcode\fi} + +\newcount\registeredboxanchor + +\permanent\protected\def\registerboxanchor + {\global\advance\registeredboxanchor\minusone} + +\permanent\protected\def\defineboxanchor[#1]% + {\registerboxanchor + \expandafter\integerdef\csname\??boxanchors#1\endcsname\registeredboxanchor} + +\permanent\def\namedboxanchor#1% + {\normalexpanded{\ifcsname\??boxanchors#1\endcsname\lastnamedcs\orelse\ifchknum#1\or#1\else\zerocount\fi}} + +\installcorenamespace{boxanchorcontent} + +\installparameterhandler \??boxanchorcontent {boxanchorcontent} +\installsetuphandler \??boxanchorcontent {boxanchorcontent} + +\setupboxanchorcontent + [\c!yoffset=\zeropoint, + \c!xoffset=\zeropoint, + \c!width=\zeropoint, + \c!location=\v!height, + \c!corner=\v!depth] + +\permanent\tolerant\protected\def\setboxanchor[#1]#*[#2]#*% assumes \defineboxanchor[#1] + {\begingroup + \dowithnextbox + {\setupcurrentboxanchorcontent[#2]% + \scratchxoffset\boxanchorcontentparameter\c!xoffset + \scratchyoffset\boxanchorcontentparameter\c!yoffset + \scratchcounter\namedboxanchor{#1}% + \registeranchorbox + \scratchcounter + \plusone % order + \hbox + \s!anchors % check order of these: + \boxanchorpresetcode{\boxanchorcontentparameter\c!corner} + \boxanchorpresetcode{\boxanchorcontentparameter\c!location} + \ifzeropt\scratchxoffset\else \s!xoffset \scratchxoffset\fi + \ifzeropt\scratchyoffset\else \s!yoffset \scratchyoffset\fi + \s!target \scratchcounter + {\box\nextbox}% + \endgroup}} + +% to be used as: +% +% \scratchcounter\registeredboxanchor +% +% \registeranchorbox +% \scratchcounter +% \plusone +% \ruledhbox{...} +% +% \hbox source \scratchcounter + % \negatexlistsigncode % \negateylistsigncode % \negatelistsigncode diff --git a/tex/context/base/mkxl/pack-lyr.mkxl b/tex/context/base/mkxl/pack-lyr.mkxl index 3c0352bf3..3b7e2324d 100644 --- a/tex/context/base/mkxl/pack-lyr.mkxl +++ b/tex/context/base/mkxl/pack-lyr.mkxl @@ -661,7 +661,7 @@ \ifx\p_pack_layers_position\v!yes \edef\p_pack_layers_region{\layerparameter\c!region}% \ifempty\p_pack_layers_region\else - \anch_mark_tagged_box\nextbox\p_pack_layers_region % was \layeranchor + \anch_mark_tagged_box\nextbox\p_pack_layers_region\zerocount % was \layeranchor \fi \fi \box\nextbox diff --git a/tex/context/base/mkxl/pack-mat.mkxl b/tex/context/base/mkxl/pack-mat.mkxl new file mode 100644 index 000000000..c0aa1cc94 --- /dev/null +++ b/tex/context/base/mkxl/pack-mat.mkxl @@ -0,0 +1,84 @@ +%D \module +%D [ file=pack-rul, % was core-rul, +%D version=2022.02.23, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Ruled Math, +%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 Packaging Macros / Ruled Math} + +%D This is a by product of the math improvement activity by Mikael Sundqvist and +%D myself. More might end up here and more control might be added. + +\unprotect + +\newconditional \c_framed_math_framed + +\installtextracker + {framed.math} + {\settrue \c_framed_math_framed} + {\setfalse\c_framed_math_framed} + +\tolerant\protected\def\mathframed[#1]#:#2% + {\begingroup + \ifconditional\c_framed_math_framed + \defineboxanchor[temp]% + \fi + \setmathatomrule\mathbegincode\mathbincode\allmathstyles\mathbegincode\mathbincode + \normalexpanded + {\setbox\scratchbox\hpack + \ifconditional\c_framed_math_framed + \s!source \namedboxanchor{temp} + \fi + \s!ymove \Umathaxis\Ustyle\mathstyle + \bgroup + \framed + [\c!location=\v!middle,#1] + {\startimath + \Ustyle\mathstyle + #2% + \stopimath}% + \egroup}% + \scratchcounterone\lastleftclass + \scratchcountertwo\lastrightclass + % \writestatus{!!}{[\number\lastleftclass,\number\lastrightclass]}% + \mathatom + \s!class \mathexplicitcode + \ifnum\scratchcounterone<\zerocount\else\s!leftclass \scratchcounterone\fi + \ifnum\scratchcountertwo<\zerocount\else\s!rightclass\scratchcountertwo\fi + \bgroup + \ifconditional\c_framed_math_framed + \setboxanchor[temp][\c!corner={\v!left,\v!bottom},\c!location={\v!right,\v!height}] + \hpack{\smallinfofont \the\scratchcounterone}% + \setboxanchor[temp][\c!corner={\v!right,\v!bottom},\c!location={\v!left,\v!height}] + \hpack{\smallinfofont \the\scratchcountertwo}% + \fi + \box\scratchbox + \egroup + \endgroup} + +%D \starttyping +%D \enabletrackers[framed.math] +%D +%D \startTEXpage[offset=10pt,width=40dk] +%D \showmakeup[mathglue] +%D \def\MyTest#1% +%D {$ x #1 x $\quad +%D $ x \mathframed[offset=0pt]{#1} x $\quad +%D $\displaystyle x #1 x $\quad +%D $\displaystyle x \mathframed[offset=0pt]{#1} x $} +%D \MyTest{>}\blank +%D \MyTest{+}\blank +%D \MyTest{!}\blank +%D \MyTest{+\frac{1}{2}+}\blank +%D \MyTest{\frac{1}{2}}\blank +%D \stopTEXpage +%D \stoptyping + +\protect diff --git a/tex/context/base/mkxl/page-bck.mkxl b/tex/context/base/mkxl/page-bck.mkxl index e955325e5..5c9b96fd7 100644 --- a/tex/context/base/mkxl/page-bck.mkxl +++ b/tex/context/base/mkxl/page-bck.mkxl @@ -354,7 +354,7 @@ \def\page_backgrounds_set_box#1% #2% {\global\setbox#1\vpack {\dontcomplain - \page_layouts_swap_margins + \page_layouts_swap_margins\v!background \ifconditional\swapbackgroundmargins \doifelsemarginswap \donothing {\enforced\swapcsvalues\v!rightmargin\v!leftmargin @@ -362,9 +362,6 @@ \fi \calculatereducedvsizes \offinterlineskip - % \ifconditional#2\relax - % \page_layouts_swap_margins_indeed % hm, this one gets nilled in \page_layouts_swap_margin anyway - % \fi \ifdim\topheight>\zeropoint \kern\dimexpr-\topheight-\topdistance\relax \page_backgrounds_set_box_row\v!top\topheight diff --git a/tex/context/base/mkxl/page-box.mklx b/tex/context/base/mkxl/page-box.mklx index c962b831a..56cb73f7a 100644 --- a/tex/context/base/mkxl/page-box.mklx +++ b/tex/context/base/mkxl/page-box.mklx @@ -250,11 +250,22 @@ % nearly always some displacement so no speedup test needed +% \def\page_boxes_apply_offsets#1% +% {\setbox#1\vpack to \paperheight +% {\hsize\paperwidth +% \vkern\topspace +% \hkern\doifbothsides\backspace\backspace{\dimexpr\paperwidth-\backspace-\makeupwidth\relax}% +% \box#1}% +% \dp#1\zeropoint} + \def\page_boxes_apply_offsets#1% {\setbox#1\vpack to \paperheight {\hsize\paperwidth \vkern\topspace \hkern\doifbothsides\backspace\backspace{\dimexpr\paperwidth-\backspace-\makeupwidth\relax}% +% \hkern\doifbothsides\backspace\backspace\cutspace +% \page_layouts_swap_margins\v!page +% \hkern\backspace \box#1}% \dp#1\zeropoint} diff --git a/tex/context/base/mkxl/page-flt.mkxl b/tex/context/base/mkxl/page-flt.mkxl index a97cc7f0d..a360dc42f 100644 --- a/tex/context/base/mkxl/page-flt.mkxl +++ b/tex/context/base/mkxl/page-flt.mkxl @@ -55,7 +55,7 @@ \newconditional\c_page_floats_center_box \settrue\c_page_floats_center_box \newconditional\c_page_floats_center_box_local \newconditional\c_page_floats_center_box_global -\newconditional\c_page_floats_compress_flushed \settrue\c_page_floats_compress_flushed +\newconditional\c_page_floats_compress_flushed \settrue\c_page_floats_compress_flushed \newdimen \d_page_floats_compress_distance diff --git a/tex/context/base/mkxl/page-lay.mkxl b/tex/context/base/mkxl/page-lay.mkxl index 835a3ca4b..4527759b3 100644 --- a/tex/context/base/mkxl/page-lay.mkxl +++ b/tex/context/base/mkxl/page-lay.mkxl @@ -123,7 +123,7 @@ \doifnothing{\directlayoutparameter\c!state}{\letlayoutparameter\c!state\v!start}% \to \everydefinelayout -\newconditional \layouthaschanged \settrue\layouthaschanged % used in mp +\newcount\c_page_layouts_changed \appendtoks \ifcase\layoutsetupmode @@ -155,13 +155,9 @@ \page_layouts_synchronize \page_layouts_check_next \fi - \global\settrue\layouthaschanged + \global\c_page_layouts_changed\realpageno \to \everysetuplayout -\appendtoks - \global\setfalse\layouthaschanged -\to \everyaftershipout - \permanent\def\doifelselayoutdefined#1% {\ifcsname\namedlayouthash{#1}\c!state\endcsname % maybe a helper \expandafter\firstoftwoarguments @@ -218,12 +214,22 @@ \newtoks\everyswapmargins % watch the order ! +\newconditional\marginsareswapped + \appendtoks + \ifconditional\marginsareswapped + \setfalse\marginsareswapped + \else + \settrue\marginsareswapped + \fi + % \enforced\swapcsvalues\leftmargindistance\rightmargindistance \enforced\swapcsvalues\leftedgedistance \rightedgedistance \enforced\swapcsvalues\leftmarginwidth \rightmarginwidth \enforced\swapcsvalues\leftedgewidth \rightedgewidth % + \enforced\swapcsvalues\backspace \cutspace + % \enforced\swapcsvalues\leftmargintotal \rightmargintotal \enforced\swapcsvalues\leftedgetotal \rightedgetotal \enforced\swapcsvalues\leftsidetotal \rightsidetotal @@ -754,9 +760,9 @@ \ifx\p_direction\v!reverse \enforced\global\swapcsvalues\naturalleftedgedistance \naturalrightedgedistance \enforced\global\swapcsvalues\naturalleftmargindistance\naturalrightmargindistance - \enforced\global\swapcsvalues\leftedgedistance \rightedgedistance \enforced\global\swapcsvalues\leftmargindistance \rightmargindistance \enforced\global\swapcsvalues\leftmarginwidth \rightmarginwidth + \enforced\global\swapcsvalues\leftedgedistance \rightedgedistance \enforced\global\swapcsvalues\leftedgewidth \rightedgewidth \enforced\global\swapcsvalues\backspace \cutspace \expandafter\setsystemmode @@ -1256,13 +1262,16 @@ \aliased\let\doifmarginswapelse\doifelsemarginswap \protected\def\page_layouts_swap_margins % name will change, frozen? - {\doifelsemarginswap\relax\page_layouts_swap_margins_indeed} + {\doifelsemarginswap\gobbleoneargument\page_layouts_swap_margins_indeed} -\protected\def\page_layouts_swap_margins_indeed - {\let\page_layouts_swap_margins \relax % to prevent local swapping - \let\page_layouts_swap_margins_indeed\relax % to prevent local swapping +\protected\def\page_layouts_swap_margins_indeed#1% + {\let\page_layouts_swap_margins\gobbleoneargument % to prevent local swapping + %\writestatus\m!layouts{swapping margins for #1}% \the\everyswapmargins} +\permanent\protected\def\swapmargindimensions + {\page_layouts_swap_margins\v!page} + \permanent\def\rightorleftpageaction {\ifdoublesided \expandafter\page_layouts_right_or_left_page_action @@ -1353,6 +1362,15 @@ \glet\page_grids_add_to_one\gobbleoneargument \glet\page_grids_add_to_mix\gobbleoneargument +%D Play safe: + +\appendtoks + \ifnum\realpageno>\plusone + \page[\v!odd]% + \setuplayout + \fi +\to \everysetuppagenumbering + %D The default dimensions are quite old and will not change. The funny fractions %D were introduced when we went from fixed dimensions to relative ones. Since %D \CONTEXT\ is a dutch package, the dimensions are based on the metric system. The diff --git a/tex/context/base/mkxl/page-mbk.mklx b/tex/context/base/mkxl/page-mbk.mklx index 05b09c79e..9999fb8c7 100644 --- a/tex/context/base/mkxl/page-mbk.mklx +++ b/tex/context/base/mkxl/page-mbk.mklx @@ -69,6 +69,12 @@ \c!inbetween=\blank, \c!bottom=\vfill] +\definesystemconstant{marginblock} + +\resetboxesincache \s!marginblock \s!marginblock + +\setfalse\c_page_margin_blocks_enabled + \permanent\tolerant\protected\def\startmarginblock[#tag]% {\begingroup \edef\currentmarginblock{#tag}% @@ -77,60 +83,45 @@ \page_margin_blocks_start_block_nop} \permanent\protected\def\stopmarginblock - {\doifelse{\marginblockparameter\c!state}\v!start - \page_margin_blocks_stop_block_yes - \page_margin_blocks_stop_block_nop + {\page_margin_blocks_stop_block \endgroup} -\def\page_margin_blocks_start_block_yes % 2 maal \vbox ivm \unvbox elders - {\showmessage\m!layouts4\empty - \global\settrue\c_page_margin_blocks_present - \global\setbox\b_page_margin_blocks\vtop\bgroup\vbox\bgroup - \hsize\marginblockparameter\c!width - \ifvoid\b_page_margin_blocks\else - \unvbox\b_page_margin_blocks - \marginblockparameter\c!inbetween - \fi - \usealignparameter\marginblockparameter - \usemarginblockstyleandcolor\c!style\c!color - \begstrut - \ignorespaces} +\def\page_margin_blocks_start_block_yes + {%\showmessage\m!layouts4\empty + \global\settrue\c_page_margin_blocks_enabled + \dowithnextboxcs + \page_margin_blocks_start_block_save + \vbox\bgroup + \let\page_margin_blocks_stop_block\page_margin_blocks_stop_block_yes + \hsize\marginblockparameter\c!width + \usealignparameter\marginblockparameter + \usemarginblockstyleandcolor\c!style\c!color + \begstrut + \ignorespaces} \def\page_margin_blocks_stop_block_yes {\removeunwantedspaces \endstrut - \egroup \egroup} +\def\page_margin_blocks_start_block_save + {\putboxincache\s!marginblock{+}\nextbox} + \def\page_margin_blocks_start_block_nop - {\showmessage\m!layouts5\empty + {%\showmessage\m!layouts5\empty \marginblockparameter\c!before \bgroup + \let\page_margin_blocks_stop_block\page_margin_blocks_stop_block_nop \usemarginblockstyleandcolor\c!style\c!color} \def\page_margin_blocks_stop_block_nop {\egroup \marginblockparameter\c!after} -\def\page_margin_blocks_reshape - {\ifdim\ht\b_page_margin_blocks_prepared>\zeropoint - \beginofshapebox - \unvbox\b_page_margin_blocks_prepared - \endofshapebox - \reshapebox - {\box\shapebox}% - \setbox\b_page_margin_blocks_prepared\vbox to \textheight - {\marginblockparameter\c!top - \flushshapebox - \marginblockparameter\c!bottom}% - \fi} - \permanent\protected\def\checkmarginblocks - {\ifvoid\b_page_margin_blocks - \global\setfalse\c_page_margin_blocks_present - \else - \page_margin_blocks_check_indeed - \fi} + {\ifconditional\c_page_margin_blocks_enabled\ifcase\getboxcountfromcache\s!marginblock\else + \expandafter\page_margin_blocks_check_indeed + \fi\fi} \def\page_margin_blocks_check_indeed {\ifcsname\??marginblocklocation\marginblockparameter\c!location\endcsname @@ -138,39 +129,58 @@ \csname\??marginblocklocation\marginblockparameter\c!location\endcsname \else \global\setbox\b_page_margin_blocks\emptybox - \global\setfalse\c_page_margin_blocks_present \fi} \def\page_margin_blocks_prepare_box - {\setbox\b_page_margin_blocks_prepared\vbox - {\forgetall - \splittopskip\topskip - \ifvoid\b_page_margin_blocks\else - \ifdim\ht\b_page_margin_blocks>\textheight - \vsplit\b_page_margin_blocks to \textheight - \else - \unvbox\b_page_margin_blocks - \fi + {\begingroup + \scratchcounter\zerocount + \localcontrolledloop \plusone \getboxcountfromcache\s!marginblock \plusone + {\scratchcounter\currentloopiterator + \setbox\scratchbox\vbox\bgroup + \marginblockparameter\c!top + \localcontrolledloop \plusone \scratchcounter \plusone + {\ifcase\currentloopiterator\or + \marginblockparameter\c!before + \else + \marginblockparameter\c!inbetween + \fi + \setbox\scratchbox\emptyvbox + \ht\scratchbox\getboxhtfromcache\s!marginblock{\number\currentloopiterator}% + \dp\scratchbox\getboxdpfromcache\s!marginblock{\number\currentloopiterator}% + \box\scratchbox + \marginblockparameter\c!after}% + \marginblockparameter\c!bottom + \egroup + \ifdim\htdp\scratchbox>\textheight + \advance\scratchcounter\minusone + %\writestatus{quit}{\the\scratchcounter=>\the\htdp\scratchbox} + \quitloop + \else + %\writestatus{progress}{\the\htdp\scratchbox} \fi}% - \page_margin_blocks_reshape - \setbox\b_page_margin_blocks_prepared\vbox - {\marginblockparameter\c!before - \box\b_page_margin_blocks_prepared - \marginblockparameter\c!after}} + \ifcase\scratchcounter\else + \global\setbox\b_page_margin_blocks_prepared\vbox to \textheight\bgroup + \marginblockparameter\c!top + \localcontrolledloop \plusone \scratchcounter \plusone + {\ifcase\currentloopiterator\or + \marginblockparameter\c!before + \else + \marginblockparameter\c!inbetween + \fi + \getboxfromcache\s!marginblock{\number\currentloopiterator}\scratchbox + \box\scratchbox + \marginblockparameter\c!after}% + \marginblockparameter\c!bottom + \egroup + \pruneboxesincache\s!marginblock + \ifcase\getboxcountfromcache\s!marginblock\relax + \global\settrue\c_page_margin_blocks_enabled + \fi + \fi + \endgroup} % inner outer -\setvalue{\??marginblocklocation\v!left }{\page_margin_blocks_set_l_box} -\setvalue{\??marginblocklocation\v!right }{\page_margin_blocks_set_r_box} -\setvalue{\??marginblocklocation\v!inmargin}{\doifbothsidesoverruled - \page_margin_blocks_set_r_box - \page_margin_blocks_set_r_box - \page_margin_blocks_set_l_box} -\setvalue{\??marginblocklocation\v!middle }{\doifbothsidesoverruled - \page_margin_blocks_set_r_box - \page_margin_blocks_set_l_box - \page_margin_blocks_set_r_box} - \permanent\protected\def\page_margin_blocks_place_r_yes {\setbox\b_page_margin_blocks_prepared\hbox to \rightmarginwidth {\marginblockparameter\c!left @@ -196,6 +206,21 @@ \def\page_margin_blocks_set_r_box{\enforced\aliased\let\placerightmarginblock\page_margin_blocks_place_r_yes} \def\page_margin_blocks_set_l_box{\enforced\aliased\let\placeleftmarginblock \page_margin_blocks_place_l_yes} +\letcsname\??marginblocklocation\v!left \endcsname\page_margin_blocks_set_l_box +\letcsname\??marginblocklocation\v!right\endcsname\page_margin_blocks_set_r_box + +\defcsname\??marginblocklocation\v!inmargin\endcsname + {\doifbothsidesoverruled + \page_margin_blocks_set_r_box + \page_margin_blocks_set_r_box + \page_margin_blocks_set_l_box} + +\defcsname\??marginblocklocation\v!middle\endcsname + {\doifbothsidesoverruled + \page_margin_blocks_set_r_box + \page_margin_blocks_set_l_box + \page_margin_blocks_set_r_box} + % margin floats (keyword 'margin' in option list) \protected\def\page_margin_blocks_process_float @@ -204,40 +229,41 @@ \page_margin_blocks_process_float_nop} \def\page_margin_blocks_process_float_yes - {\global\setbox\b_page_margin_blocks\vbox - {\hsize\marginblockparameter\c!width - \unvcopy\b_page_margin_blocks - \ifvoid\b_page_margin_blocks\else - \expandafter\marginblockparameter\expandafter\c!inbetween - \fi - \box\floatbox - \filbreak}% - \ifdim\ht\b_page_margin_blocks>\textheight - % page_floats_report_saved % no saving done anyway - \else - \page_floats_report_total - \fi} + {\global\settrue\c_page_margin_blocks_enabled + \putboxincache\s!marginblock{+}\floatbox} \def\page_margin_blocks_process_float_nop {\handlefloatmethod\v!here} -\def\page_margin_blocks_float_before - {\ifconditional\c_page_margin_blocks_enabled - \doifinset\v!margin\floatlocation\endgraf - \fi} - -\def\page_margin_blocks_float_set_hsize - {\ifconditional\c_page_margin_blocks_enabled - \doifinset\v!margin\floatlocation{\hsize\rootmarginblockparameter\c!width}% - \fi} - \appendtoks - \ifvoid\b_page_margin_blocks \else + \ifcase\getboxcountfromcache\s!marginblock\else \writestatus\m!layouts{beware: there are left-over margin floats!}% \fi \to \everystoptext \permanent\protected\def\flushmarginblocks - {\page_otr_command_flush_margin_blocks} + {\ifconditional\c_page_margin_blocks_enabled + \page_otr_command_flush_margin_blocks + \fi} + +\permanent\tolerant\protected\def\flushallmarginblocks[#1]% + {\ifconditional\c_page_margin_blocks_enabled + \begingroup + \scratchcounterone\getboxcountfromcache\s!marginblock\relax + \ifcase\scratchcounterone\else + \scratchcountertwo\ifparameter#1\or\numexpr\scratchcounterone-#1+\plusone\relax\else\plusone\fi + \localcontrolledloop \scratchcountertwo \scratchcounterone \plusone + {\ifcase\currentloopiterator\or + \marginblockparameter\c!before + \else + \marginblockparameter\c!inbetween + \fi + \getboxfromcache\s!marginblock{\number\currentloopiterator}\scratchbox + \box\scratchbox + \marginblockparameter\c!after}% + \pruneboxesincache\s!marginblock + \fi + \endgroup + \fi} \protect \endinput diff --git a/tex/context/base/mkxl/page-one.mkxl b/tex/context/base/mkxl/page-one.mkxl index 61f9172ea..f900d561d 100644 --- a/tex/context/base/mkxl/page-one.mkxl +++ b/tex/context/base/mkxl/page-one.mkxl @@ -284,6 +284,7 @@ % baseline \unskip % new per 2019-06-18, otherwise weird bottom floats \vkern\dimexpr\maxdepth-\d_page_one_natural_depth\relax + % \srule depth \dimexpr\maxdepth-\d_page_one_natural_depth\relax \page_otr_command_flush_bottom_insertions \fi \fakepagenotes}% diff --git a/tex/context/base/mkxl/page-sid.mkxl b/tex/context/base/mkxl/page-sid.mkxl index 1ff587120..8959a0e3d 100644 --- a/tex/context/base/mkxl/page-sid.mkxl +++ b/tex/context/base/mkxl/page-sid.mkxl @@ -534,7 +534,7 @@ \egroup}} \def\page_sides_flush_floats_normal - {\ifdim\scratchdimen>\htdp\strutbox + {\ifdim\scratchdimen>\struthtdp \strut \else \m_pages_strut diff --git a/tex/context/base/mkxl/page-str.lmt b/tex/context/base/mkxl/page-str.lmt new file mode 100644 index 000000000..9c2562cc4 --- /dev/null +++ b/tex/context/base/mkxl/page-str.lmt @@ -0,0 +1,320 @@ +if not modules then modules = { } end modules ['page-str'] = { + version = 1.001, + comment = "companion to page-str.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- streams -> managers.streams + +-- work in progresss .. unfinished .. non-optimized + +local concat, insert, remove = table.concat, table.insert, table.remove + +local nodes, node = nodes, node + +local tasks = nodes.tasks + +local implement = interfaces.implement + +local nodecodes = nodes.nodecodes + +local nuts = nodes.nuts +local tonut = nodes.tonut +local slide_node_list = nuts.slide +local write_node = nuts.write +local flushnode = nuts.flush +local copy_node_list = nuts.copylist +local vpack_node_list = nuts.vpack +local new_strut = nuts.pool.strutrule + +----- getbox = nuts.getbox +local setlink = nuts.setlink +local getlist = nuts.getlist +local setlist = nuts.setlist +local getwhd = nuts.getwhd +local setwhd = nuts.setwhd +local setattrlist = nuts.setattrlist + +local settings_to_array = utilities.parsers.settings_to_array + +local enableaction = nodes.tasks.enableaction + +local texgetdimen = tex.getdimen + +local trace_collecting = false trackers.register("streams.collecting", function(v) trace_collecting = v end) +local trace_flushing = false trackers.register("streams.flushing", function(v) trace_flushing = v end) + +local report_streams = logs.reporter("streams") + +streams = streams or { } -- might move to the builders namespace +local streams = streams + +-- maybe store head and tail ... first we need usage + +local data = { } +local name = nil +local stack = { } + +function streams.enable(newname) + if newname == "default" then + name = nil + else + name = newname + end +end + +function streams.disable() + name = stack[#stack] +end + +function streams.start(newname) + insert(stack,name) + name = newname +end + +function streams.stop(newname) + name = remove(stack) +end + +function streams.collect(head,where) + if name and head and name ~= "default" then + local head = tonut(head) + local dana = data[name] + if not dana then + dana = { } + data[name] = dana + end + local last = dana[#dana] + if last then + local tail = slide_node_list(last) + setlink(tail,head) + elseif last == false then + dana[#dana] = head + else + dana[1] = head + end + if trace_collecting then + report_streams("appending snippet %a to slot %s",name,#dana) + end + return nil + else + return head + end +end + +function streams.push(thename) + if not thename or thename == "" then + thename = name + end + if thename and thename ~= "" then + local dana = data[thename] + if dana then + dana[#dana+1] = false + if trace_collecting then + report_streams("pushing snippet %a",thename) + end + end + end +end + +function streams.flush(name,copy) -- problem: we need to migrate afterwards + local dana = data[name] + if dana then + local dn = #dana + if dn == 0 then + -- nothing to flush + elseif copy then + if trace_flushing then + report_streams("flushing copies of %s slots of %a",dn,name) + end + for i=1,dn do + local di = dana[i] + if di then + write_node(copy_node_list(getlist(di))) -- list, will be option + end + end + if copy then + data[name] = nil + end + else + if trace_flushing then + report_streams("flushing %s slots of %a",dn,name) + end + for i=1,dn do + local di = dana[i] + if di then + write_node(getlist(di)) -- list, will be option + setlist(di) + flushnode(di) + end + end + end + end +end + +function streams.synchronize(list) -- this is an experiment ! + -- we don't optimize this as we want to trace in detail + list = settings_to_array(list) + local max = 0 + if trace_flushing then + report_streams("synchronizing list: % t",list) + end + for i=1,#list do + local dana = data[list[i]] + if dana then + local n = #dana + if n > max then + max = n + end + end + end + if trace_flushing then + report_streams("maximum number of slots: %s",max) + end + for m=1,max do + local height, depth = 0, 0 + for i=1,#list do + local name = list[i] + local dana = data[name] + if dana then + local slot = dana[m] + if slot then + local vbox = vpack_node_list(slot) + local wd, ht, dp = getwhd(vbox) + if ht > height then + height = ht + end + if dp > depth then + depth = dp + end + dana[m] = vbox + if trace_flushing then + report_streams("slot %s of %a is packed to height %p and depth %p",m,name,ht,dp) + end + end + end + end + if trace_flushing then + report_streams("slot %s has max height %p and max depth %p",m,height,depth) + end + local strutht = texgetdimen("globalbodyfontstrutheight") + local strutdp = texgetdimen("globalbodyfontstrutdepth") + local struthtdp = strutht + strutdp + for i=1,#list do + local name = list[i] + local dana = data[name] + if dana then + local vbox = dana[m] + if vbox then + local wd, ht, dp = getwhd(vbox) + local delta_height = height - ht + local delta_depth = depth - dp + if delta_height > 0 or delta_depth > 0 then + if false then + -- actually we need to add glue and repack + setwhd(vbox,false,height,depth) + if trace_flushing then + report_streams("slot %s of %a with delta (%p,%p) is compensated",m,i,delta_height,delta_depth) + end + else + -- this is not yet ok as we also need to keep an eye on vertical spacing + -- so we might need to do some splitting or whatever + local list = getlist(vbox) + local tail = list and slide_node_list(list) + local n = 0 + local delta = delta_height -- for tracing + while delta > 0 do + -- we need to add some interline penalties + local strut = new_strut(0,strutht,strutdp) + setattrlist(strut,vbox) + if tail then + -- todo: inject at a better place + setlink(tail,strut) + end + tail = strut + n = n + 1 + delta = delta - struthtdp + end + dana[m] = vpack_node_list(getlist(vbox)) + setlist(vbox) + flushnode(vbox) + if trace_flushing then + report_streams("slot %s:%s with delta (%p,%p) is compensated by %s lines",m,i,delta_height,delta_depth,n) + end + end + end + end + else + -- make dummy + end + end + end +end + +-- hm, nut or node + +tasks.appendaction("mvlbuilders", "normalizers", "streams.collect") + +tasks.disableaction("mvlbuilders", "streams.collect") + +function streams.initialize() + enableaction("mvlbuilders","streams.collect") + function streams.initialize() end +end + +-- todo: remove empty last { }'s +-- todo: better names, enable etc + +implement { + name = "initializestream", + actions = streams.initialize, + onlyonce = true, +} + +implement { + name = "enablestream", + actions = streams.enable, + arguments = "string" +} + +implement { + name = "disablestream", + actions = streams.disable +} + +implement { + name = "startstream", + actions = streams.start, + arguments = "string" +} + +implement { + name = "stopstream", + actions = streams.stop +} + +implement { + name = "flushstream", + actions = streams.flush, + arguments = "string" +} + +implement { + name = "flushstreamcopy", + actions = streams.flush, + arguments = { "string", true } +} + +implement { + name = "synchronizestream", + actions = streams.synchronize, + arguments = "string" +} + +implement { + name = "pushstream", + actions = streams.push, + arguments = "string" +} diff --git a/tex/context/base/mkxl/page-str.mkxl b/tex/context/base/mkxl/page-str.mkxl index d6e01ea59..067283ee0 100644 --- a/tex/context/base/mkxl/page-str.mkxl +++ b/tex/context/base/mkxl/page-str.mkxl @@ -27,7 +27,7 @@ %D %D Remark: marknotes are gone, at least for a while. -\registerctxluafile{page-str}{} +\registerctxluafile{page-str}{autosuffix} \unprotect diff --git a/tex/context/base/mkxl/page-txt.mklx b/tex/context/base/mkxl/page-txt.mklx index 4d80cfa76..a66dc0829 100644 --- a/tex/context/base/mkxl/page-txt.mklx +++ b/tex/context/base/mkxl/page-txt.mklx @@ -866,7 +866,7 @@ {\setbox\b_page_layouts_element\vpack {\dontcomplain \calculatereducedvsizes - \page_layouts_swap_margins + \page_layouts_swap_margins\v!text \offinterlineskip \vkern\dimexpr-\topheight-\topdistance\relax \the\toptextcontent @@ -896,12 +896,12 @@ {\offinterlineskip \calculatereducedvsizes \calculatehsizes - \page_layouts_swap_margins + \page_layouts_swap_margins\v!page \vkern\dimexpr\headerheight+\headerdistance+\textdistance\relax \dontleavehmode \hpack to \makeupwidth {\begingroup - \page_layouts_swap_margins + % \page_layouts_swap_margins\v!page \goleftonpage \ifdim\leftedgewidth>\zeropoint \the\leftedgetextcontent diff --git a/tex/context/base/mkxl/spac-hor.mkxl b/tex/context/base/mkxl/spac-hor.mkxl index c8ac4c74c..ee9001e62 100644 --- a/tex/context/base/mkxl/spac-hor.mkxl +++ b/tex/context/base/mkxl/spac-hor.mkxl @@ -23,6 +23,7 @@ \bitwiseflip \normalizelinemode \normalizelinenormalizecode \bitwiseflip \normalizelinemode \clipwidthnormalizecode \bitwiseflip \normalizelinemode \flattendiscretionariesnormalizecode +\bitwiseflip \normalizelinemode \flattenleadersnormalizecode % neglectable overhead %bitwiseflip \normalizelinemode \discardzerotabskipsnormalizecode \let\v_spac_indentation_current\empty % amount/keyword @@ -900,6 +901,8 @@ % \box\b_spac_indentations_a % \endgroup} +%D Struts are done differently now. +%D %D The only complication lays in \type{\strut}. In \PLAIN\ \TEX\ a \type{\strut} is %D defined as: %D diff --git a/tex/context/base/mkxl/spac-par.mkxl b/tex/context/base/mkxl/spac-par.mkxl index d382a6c8c..098595dfe 100644 --- a/tex/context/base/mkxl/spac-par.mkxl +++ b/tex/context/base/mkxl/spac-par.mkxl @@ -39,7 +39,7 @@ + \widowpenaltyfrozenparcode + \clubpenaltyfrozenparcode + \brokenpenaltyfrozenparcode - + \shapingpenaltiesfrozenparcode + + \shapingpenaltyfrozenparcode + \orphanpenaltyfrozenparcode \relax @@ -83,7 +83,7 @@ + \shapefrozenparcode % \parshape % \linefrozenparcode % \baselineskip \lineskip \lineskiplimit + \hyphenationfrozenparcode % \hyphenationmode - + \shapingpenaltiesfrozenparcode % \shapingpenaltiesmode + + \shapingpenaltyfrozenparcode % \shapingpenaltymode + \orphanpenaltyfrozenparcode \relax diff --git a/tex/context/base/mkxl/spac-ver.mkxl b/tex/context/base/mkxl/spac-ver.mkxl index 3f40d98cf..68f74c9ee 100644 --- a/tex/context/base/mkxl/spac-ver.mkxl +++ b/tex/context/base/mkxl/spac-ver.mkxl @@ -825,22 +825,20 @@ %D %D But we do things differently. -\newbox\strutbox +\newbox\b_strut_box +\newbox\b_strut_tmp -\setbox\strutbox\hpack{\vrule\s!height8.5pt\s!depth3.5pt\s!width\zeropoint} % just a start - -% \permanent\protected\def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} -% -% \protected\def\strut -% {\relax -% \ifmmode\copy\else\dontleavehmode\unhcopy\fi\strutbox} -% -% \aliased\let\normalstrut\strut +\permanent\protected\def\strutbox % not to be used but this is sort of an alias + {\beginlocalcontrol + \setbox\b_strut_tmp\hpack{\normalsrule\s!height\strutht\s!depth\strutdp}% just a start + \endlocalcontrol + \b_strut_tmp} %D The double \type {\hbox} construction enables us to backtrack boxes. -\overloaded\let\strutht\undefined \newdimen\strutht -\overloaded\let\strutdp\undefined \newdimen\strutdp +\overloaded\let\strutht \undefined \newdimen\strutht +\overloaded\let\strutdp \undefined \newdimen\strutdp +\overloaded\let\struthtdp\undefined \newdimen\struthtdp \permanent\protected\def\setstrut {\ifgridsnapping @@ -884,9 +882,9 @@ \dosetstrut} \permanent\protected\def\setcharstrut#1% - {\setbox\strutbox\hbox{#1}% no \hpack, in case we have smallcaps - \strutht\ht\strutbox - \strutdp\dp\strutbox + {\setbox\b_strut_box\hbox{#1}% no \hpack, in case we have smallcaps + \strutht\ht\b_strut_box + \strutdp\dp\b_strut_box \dosetstrut} \permanent\protected\def\settightstrut @@ -903,13 +901,17 @@ \permanent\protected\def\charhtstrut {\begingroup \setcharstrut{GJY}% - \vrule\s!width\zeropoint\s!depth\zeropoint\s!height\strutht + \normalsrule + \s!depth \zeropoint + \s!height\strutht \endgroup} \permanent\protected\def\chardpstrut {\begingroup \setcharstrut{gjy}% - \vrule\s!width\zeropoint\s!depth\strutdp\s!height\zeropoint + \normalsrule + \s!depth \strutdp + \s!height\zeropoint \endgroup} %D Because of all the callbacks in mkiv, we avoid unnecessary boxes ... maybe use an @@ -919,143 +921,82 @@ \permanent\protected\def\dosetstrut {\enforced\let\strut\normalstrut - \ifabsnum\dimexpr\strutht+\strutdp-\lineheight\relax<\plustwo + \ifabsnum\dimexpr\struthtdp-\lineheight\relax<\plustwo % compensate rounding error /- 1sp to avoid too many % 1sp baselineskips in for instance verbatim % \strutht\dimexpr\lineheight-\strutdp\relax % better: \strutdp\dimexpr\lineheight-\strutht\relax \struttotal\lineheight - \else - \struttotal\dimexpr\strutht+\strutdp\relax \fi + \struthtdp\dimexpr\strutht+\strutdp\relax \strutheight\strutht \strutdepth \strutdp - \ifdim\strutwidth=\zeropoint - \spac_struts_set_hide - \else - \spac_struts_set_vide - \fi} - -\def\spac_struts_set_hide - {\setbox\strutbox\hpack - {\vrule - \s!width \zeropoint - \s!height\strutht - \s!depth \strutdp}} + \struttotal \struthtdp} \newconstant\c_strut_visual_mode -\def\spac_struts_set_vide - {\setbox\strutbox\hpack % at some time this extra wrapping was needed - {\spac_struts_vide_hbox to \zeropoint - {\ifcase\c_strut_visual_mode - \spac_struts_black - \or - \spac_struts_color - \else - \spac_struts_black - \fi}}} - -\def\spac_struts_black - {\vrule - \s!width \strutwidth - \s!height\strutht - \s!depth \strutdp - \hss} - -\def\spac_struts_color - {\hss % new, will be option - \scratchwidth.1\struthtdp - \begingroup - \directcolor[f:b:t]% - \vrule - \s!width \scratchwidth - \s!height\strutht - \s!depth \strutdp - \kern-\scratchwidth - \vrule - \s!width \scratchwidth - \s!height\zeropoint - \s!depth \strutdp - \endgroup - \kern-.625\scratchwidth - \vrule - \s!width .25\scratchwidth - \s!height\strutht - \s!depth \strutdp - \hss} - -\let\spac_struts_vide_hbox\hbox % overloaded in trac-vis.mkiv - %D The dimen \type {\struttotal} holds the exact size of the strut; occasionally a %D one scaled point difference can show up with the lineheight. This is more %D efficient (less callbacks): -\newbox\b_spac_struts_empty \setbox\b_spac_struts_empty\emptyhbox - -\def\spac_struts_set_hide - {\setbox\strutbox\copy\b_spac_struts_empty - \ht\strutbox\strutht - \dp\strutbox\strutdp} - \permanent\protected\def\strut % still callbacks for \hbox{\strut} {\relax \dontleavehmode - \copy\strutbox} - -% \protected\def\strut % slightly faster -% {\relax -% \ifmmode\copy\else\dontleavehmode\unhcopy\fi\strutbox} + \normalsrule + \s!height\strutht + \s!depth \strutdp + \relax} \aliased\let\normalstrut\strut \permanent\protected\def\halfstrut {\relax \dontleavehmode - \begingroup - \setbox\scratchbox\copy\strutbox - \ht\scratchbox\dimexpr\strutht/\plustwo\relax - \dp\scratchbox\dimexpr\strutdp/\plustwo\relax - \box\scratchbox - \endgroup} + \normalsrule + \s!height.5\strutht + \s!depth .5\strutdp + \relax} \permanent\protected\def\quarterstrut {\relax \dontleavehmode - \begingroup - \setbox\scratchbox\copy\strutbox - \ht\scratchbox\dimexpr\strutht/\plusfour\relax - \dp\scratchbox\dimexpr\strutdp/\plusfour\relax - \box\scratchbox - \endgroup} + \normalsrule + \s!height.25\strutht + \s!depth .25\strutdp + \relax} \permanent\protected\def\depthstrut {\relax \dontleavehmode - \begingroup - \setbox\scratchbox\copy\strutbox - \ht\scratchbox\dimexpr\strutht-\struthtdp/\plustwo\relax % assumes that ht > lineheight/2 - \box\scratchbox - \endgroup} + \normalsrule + \s!height\dimexpr\strutht-\struthtdp/\plustwo\relax + \s!depth \strutdp + \relax} \permanent\protected\def\halflinestrut {\relax \dontleavehmode - \begingroup - \setbox\scratchbox\copy\strutbox - \ht\scratchbox\dimexpr\strutht-.5\strutht-.5\strutdp\relax - \box\scratchbox - \endgroup} + \normalsrule + \s!height\dimexpr\strutht-.5\struthtdp\relax + \s!depth \strutdp + \relax} \permanent\protected\def\noheightstrut {\relax \dontleavehmode - \begingroup - \setbox\scratchbox\copy\strutbox - \ht\scratchbox\zeropoint - \box\scratchbox - \endgroup} + \normalsrule + \s!height\zeropoint + \s!depth \strutdp + \relax} + +\permanent\protected\def\nodepthstrut + {\relax + \dontleavehmode + \normalsrule + \s!height\strutht + \s!depth \zeropoint + \relax} %D Sometimes a capstrut comes in handy %D @@ -1095,32 +1036,16 @@ \fi} \permanent\protected\def\showstruts % adapts .. is wrong - {\c_strut_visual_mode\zerocount - \setteststrut - \settestcrlf} - -\permanent\protected\def\showcolorstruts % adapts .. is wrong - {\c_strut_visual_mode\plusone - \setteststrut + {\showmakeup[strut]% \settestcrlf} -\permanent\protected\def\setteststrut - {\strutwidth.8\onepoint - \setstrut} - -\permanent\protected\def\dontshowstruts - {\unsetteststrut - \settestcrlf} - -\permanent\protected\def\unsetteststrut - {\strutwidth\zeropoint - \setstrut} +\aliased\let\showcolorstruts\showstruts \mutable\def\autostrutfactor{1.1} \permanent\protected\def\setautostrut {\begingroup - \setbox\scratchbox\copy\strutbox + \setbox\scratchbox\copy\b_strut_box \setstrut \ifdim\strutht>\autostrutfactor\ht\scratchbox \endgroup \setstrut @@ -1138,7 +1063,6 @@ {\the\everysetnostrut} \appendtoks - \setbox\strutbox\copy\nostrutbox \enforced\let\strut \empty \enforced\let\endstrut\empty \enforced\let\begstrut\empty @@ -1468,10 +1392,10 @@ %D To be checked: -\newbox\b_spac_struts_saved - -\permanent\protected\def\savestrut {\setbox\b_spac_struts_saved\copy\strutbox} -\permanent\protected\def\savedstrut{\copy \b_spac_struts_saved} +% \newbox\b_spac_struts_saved +% +% \permanent\protected\def\savestrut {\setbox\b_spac_struts_saved\copy\b_strut_box} +% \permanent\protected\def\savedstrut{\copy \b_spac_struts_saved} %D Good old blank redone: diff --git a/tex/context/base/mkxl/strc-flt.mklx b/tex/context/base/mkxl/strc-flt.mklx index 862aa7ff9..5eb18baac 100644 --- a/tex/context/base/mkxl/strc-flt.mklx +++ b/tex/context/base/mkxl/strc-flt.mklx @@ -1533,7 +1533,7 @@ \whitespace \blank[\rootfloatparameter\c!spacebefore]% \doifnotinset\v!tall\floatlocation - {\dp\floatbox\openstrutdepth}% dp\strutbox}% % toegevoegd + {\dp\floatbox\openstrutdepth}% \strutdp % toegevoegd \box\floatbox \dostoptagged \blank[\rootfloatparameter\c!spaceafter]% diff --git a/tex/context/base/mkxl/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl index 39c70fe87..edfe9d97f 100644 --- a/tex/context/base/mkxl/strc-mat.mkxl +++ b/tex/context/base/mkxl/strc-mat.mkxl @@ -874,8 +874,8 @@ % for the moment (when testing) we use a penalty 1 -\protected\def\strc_math_align_here{\ifmmode\penalty\plusone\fi}% -\protected\def\strc_math_break_here{\ifmmode\hfill\break \fi}% +\protected\def\strc_math_align_here{\ifmmode\boundary\plusone\fi}% +\protected\def\strc_math_break_here{\ifmmode\hfill\break\fi}% \ifdefined\alignhere \else \aliased\let\alignhere\relax \fi \ifdefined\breakhere \else \aliased\let\breakhere\relax \fi diff --git a/tex/context/base/mkxl/strc-ref.mklx b/tex/context/base/mkxl/strc-ref.mklx index d5e054962..61c1085f1 100644 --- a/tex/context/base/mkxl/strc-ref.mklx +++ b/tex/context/base/mkxl/strc-ref.mklx @@ -444,8 +444,8 @@ {\referenceprefix}% {#label}% {% - height \ht\strutbox - depth \dp\strutbox + height \strutht + depth \strutdp \extrareferencearguments }% \relax @@ -1483,8 +1483,8 @@ {\referenceprefix}% {#label}% {% - height \ht\strutbox - depth \dp\strutbox + height \strutht + depth \strutdp \extrareferencearguments }% \relax @@ -1535,8 +1535,8 @@ \iflocation \clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}% {\clf_injectcurrentreferencehtdp - \ht\strutbox - \dp\strutbox + \strutht + \strutdp \relax \setlocationattributes \setstrut % can be option @@ -1592,8 +1592,8 @@ \protected\def\strc_references_start_goto_yes {\clf_injectcurrentreferencehtdp - \ht\strutbox - \dp\strutbox + \strutht + \strutdp \relax \setlocationattributes \setstrut % can be option diff --git a/tex/context/base/mkxl/supp-box.lmt b/tex/context/base/mkxl/supp-box.lmt index 93b97b48e..ae4e32353 100644 --- a/tex/context/base/mkxl/supp-box.lmt +++ b/tex/context/base/mkxl/supp-box.lmt @@ -602,6 +602,20 @@ do setbox(box,b or nil) end + function boxes.prune(category) + -- this one assumes an indexed list + local c = cache[category] + local t = { } + local n = 0 + for i=1,#c do + local ci = c[i] + if ci then + n = n + 1 ; t[n] = ci + end + end + cache[category] = t + end + local function dimensions(category,name) name = tonumber(name) or name local b = cache[category][name] @@ -703,6 +717,14 @@ do } implement { + name = "pruneboxesincache", + public = true, + protected = true, + arguments = "string", + actions = boxes.prune, + } + + implement { name = "disposeboxesincache", public = true, protected = true, @@ -760,6 +782,18 @@ do } implement { + name = "getboxhtdpfromcache", + arguments = "2 strings", + public = true, + protected = true, + usage = "value", + actions = function(category,name) + local w, h, d = dimensions(category,name) + return dimension_value, h + d + end, + } + + implement { name = "putnextboxincache", public = true, protected = true, diff --git a/tex/context/base/mkxl/supp-box.mkxl b/tex/context/base/mkxl/supp-box.mkxl index b980107e4..fe96505a0 100644 --- a/tex/context/base/mkxl/supp-box.mkxl +++ b/tex/context/base/mkxl/supp-box.mkxl @@ -40,10 +40,10 @@ %D not, you're in trouble). These shortcuts can be used like a dimension, opposite %D to the core macros \type {\strutdepth} and alike, which are values. - \def\strutdp {\dp\strutbox} % overloaded in spac-ver - \def\strutht {\ht\strutbox} % overloaded in spac-ver + \def\strutdp {\dp\strutbox} % overloaded in spac-ver + \def\strutht {\ht\strutbox} % overloaded in spac-ver \permanent\protected\def\strutwd {\wd\strutbox} -\permanent\protected\def\struthtdp{\dimexpr\strutht+\strutdp\relax} + \def\struthtdp{\htdp\strutbox} % overloaded in spac-ver \permanent\protected\def\strutgap {\dimexpr\strutht-\strutdp\relax} %D \macros @@ -330,7 +330,7 @@ %D We also define plain's \type {\mathstrut}. -\permanent\protected\def\mathstrut{\vphantom(} % can be made faster by inlining +\permanent\protected\def\mathstrut{\Ustack{\vphantom(}} % can be made faster by inlining %D \macros %D {getboxheight} @@ -2027,7 +2027,7 @@ \permanent\protected\def\bbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_bbox_finish\hbox} \def\syst_boxes_tbox_finish - {\scratchheight\ht\strutbox + {\scratchheight\strutht \scratchdepth\dimexpr\htdp\nextbox-\scratchheight\relax \ht\nextbox\scratchheight \dp\nextbox\scratchdepth @@ -2036,7 +2036,7 @@ \egroup} \def\syst_boxes_bbox_finish - {\scratchdepth\dp\strutbox + {\scratchdepth\strutdp \scratchheight\dimexpr\htdp\nextbox-\scratchdepth\relax \dp\nextbox\scratchdepth \ht\nextbox\scratchheight @@ -2457,6 +2457,7 @@ % \getboxwdfromcache % {category} {name} % \getboxhtfromcache % {category} {name} % \getboxdpfromcache % {category} {name} +% \getboxhtdpfromcache % {category} {name} %D \macros %D {removedepth, obeydepth} @@ -2812,10 +2813,10 @@ \permanent\protected\def\linebox {\hpack\bgroup\dowithnextbox - {\scratchdimen\dimexpr\dimexpr\htdp\nextbox-\lineheight\relax/2+\dp\strutbox\relax + {\scratchdimen\dimexpr\dimexpr\htdp\nextbox-\lineheight\relax/2+\strutdp\relax \setbox\nextbox\hpack{\lower\scratchdimen\box\nextbox}% - \ht\nextbox\ht\strutbox - \dp\nextbox\dp\strutbox + \ht\nextbox\strutht + \dp\nextbox\strutdp \box\nextbox \egroup} \hbox} diff --git a/tex/context/base/mkxl/symb-ini.mkxl b/tex/context/base/mkxl/symb-ini.mkxl index ce489ee5a..e26892e4d 100644 --- a/tex/context/base/mkxl/symb-ini.mkxl +++ b/tex/context/base/mkxl/symb-ini.mkxl @@ -143,7 +143,7 @@ \csname\??symbol#1\endcsname\relax \endgroup} -\letvalue{\??symbol}\firstofoneargument +\letcsname\??symbol\endcsname\firstofoneargument \permanent\def\directsymbol#1#2% no \relax, there can be an argument, see lists {\begincsname\??symbol#1:#2\endcsname} diff --git a/tex/context/base/mkxl/syst-aux.mkxl b/tex/context/base/mkxl/syst-aux.mkxl index aceb52aac..ced19dcd2 100644 --- a/tex/context/base/mkxl/syst-aux.mkxl +++ b/tex/context/base/mkxl/syst-aux.mkxl @@ -4186,6 +4186,21 @@ %D {\groupedcommand{\raggedcenter\bf}{\par}} %D \stoptyping +%D For math we use this: + +\permanent\protected\def\mathgroupedcommandcs#1% + {\let\m_syst_helpers_handle_group_b#1% + \futureexpandis\bgroup\syst_helpers_handle_math_group_normal\syst_helpers_handle_math_group_nop} + +\protected\def\syst_helpers_handle_math_group_normal#1% + {\beginmathgroup + \m_syst_helpers_handle_group_b + #1% + \endmathgroup} + +\protected\def\syst_helpers_handle_math_group_nop + {\m_syst_helpers_handle_group_b} + % %D \macros % %D {checkdefined} % %D @@ -5903,7 +5918,7 @@ %D \setdimensionwithunit\scratchdimen{10cm}{cm} %D \setdimensionwithunit\scratchdimen{10cm}{} %D \freezedimensionwithunit\SomeWidth{\textwidth} -%D \freezedimensionwithunit\SomeDepth{\dp\strutbox} +%D \freezedimensionwithunit\SomeDepth{\strutdp} %D \stoptyping %D %D As an alternative for the next macro we can use a global assignment inside a box. diff --git a/tex/context/base/mkxl/syst-fnt.mkxl b/tex/context/base/mkxl/syst-fnt.mkxl index e6029d805..62239917f 100644 --- a/tex/context/base/mkxl/syst-fnt.mkxl +++ b/tex/context/base/mkxl/syst-fnt.mkxl @@ -23,13 +23,25 @@ \immutable\protected\def\fontemwidth {\scaledfontdimen\plussix } \immutable\protected\def\fontextraspace {\scaledfontdimen\plusseven} -\immutable\protected\def\slantperpoint {\scaledfontdimen\plusone \font} -\immutable\protected\def\interwordspace {\scaledfontdimen\plustwo \font} -\immutable\protected\def\interwordstretch {\scaledfontdimen\plusthree\font} -\immutable\protected\def\interwordshrink {\scaledfontdimen\plusfour \font} -\immutable\protected\def\exheight {\scaledfontdimen\plusfive \font} -\immutable\protected\def\emwidth {\scaledfontdimen\plussix \font} -\immutable\protected\def\extraspace {\scaledfontdimen\plusseven\font} +%immutable\protected\def\slantperpoint {\scaledfontdimen\plusone \font} +%immutable\protected\def\interwordspace {\scaledfontdimen\plustwo \font} +%immutable\protected\def\interwordstretch {\scaledfontdimen\plusthree\font} +%immutable\protected\def\interwordshrink {\scaledfontdimen\plusfour \font} +%immutable\protected\def\exheight {\scaledfontdimen\plusfive \font} +%immutable\protected\def\emwidth {\scaledfontdimen\plussix \font} +%immutable\protected\def\extraspace {\scaledfontdimen\plusseven\font} + +%D This saves a little bit of overhead but more important, it gives less tracing, +%D and for practical reasone we keep this indirectness because we syntax highlight +%D these pseudo constants different than primitives. + +\immutable\aliased\let\slantperpoint \scaledslantperpoint +\immutable\aliased\let\interwordspace \scaledinterwordspace +\immutable\aliased\let\interwordstretch \scaledinterwordstretch +\immutable\aliased\let\interwordshrink \scaledinterwordshrink +\immutable\aliased\let\exheight \scaledexheight +\immutable\aliased\let\emwidth \scaledemwidth +\immutable\aliased\let\extraspace \scaledextraspace \aliased\let\mathaxisheight\Umathaxis % takes style diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index 605a4c334..6f3ccd89f 100644 --- a/tex/context/base/mkxl/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -296,30 +296,44 @@ % 255 : page % 256 - : user defined -%D Later on, the \type {\c_syst_max_allocated_register} variable will be halfed so -%D that while local allocators will use the 22* range. So we have plenty of room -%D reserved for more private ones. +%D Later on, the \type {\c_syst_max_allocated_*} variables will be halfed so that +%D while local allocators will use the 23* range. So we have plenty of room reserved +%D for more private ones. + +\directlua {tex.magicconstants = status.getconstants()} % this will be reset later on \permanent\countdef\c_syst_min_allocated_register = 201 \c_syst_min_allocated_register = 256 % can change -\permanent\countdef\c_syst_max_allocated_register = 202 \c_syst_max_allocated_register = 65535 % is adapted later on + \permanent\countdef\c_syst_min_allocated_iohandle = 203 \c_syst_min_allocated_iohandle = 0 \permanent\countdef\c_syst_max_allocated_iohandle = 204 \c_syst_max_allocated_iohandle = 1023 -\permanent\countdef\c_syst_min_allocated_attribute = 205 \c_syst_min_allocated_attribute = 1024 % 0-1023 : private -\permanent\countdef\c_syst_min_allocated_mark = 206 \c_syst_min_allocated_mark = 16 % a few scratch ones -\permanent\countdef\c_syst_max_allocated_mark = 207 \c_syst_max_allocated_mark = 1024 % max 10K in luametatex anyway - -\permanent\countdef\c_syst_last_allocated_count = 211 \c_syst_last_allocated_count = \c_syst_min_allocated_register -\permanent\countdef\c_syst_last_allocated_dimen = 212 \c_syst_last_allocated_dimen = \c_syst_min_allocated_register -\permanent\countdef\c_syst_last_allocated_skip = 213 \c_syst_last_allocated_skip = \c_syst_min_allocated_register -\permanent\countdef\c_syst_last_allocated_muskip = 214 \c_syst_last_allocated_muskip = \c_syst_min_allocated_register -\permanent\countdef\c_syst_last_allocated_box = 215 \c_syst_last_allocated_box = \c_syst_min_allocated_register -\permanent\countdef\c_syst_last_allocated_toks = 216 \c_syst_last_allocated_toks = \c_syst_min_allocated_register -\permanent\countdef\c_syst_last_allocated_read = 217 \c_syst_last_allocated_read = \c_syst_min_allocated_iohandle -\permanent\countdef\c_syst_last_allocated_write = 218 \c_syst_last_allocated_write = \c_syst_min_allocated_iohandle -\permanent\countdef\c_syst_last_allocated_marks = 219 \c_syst_last_allocated_marks = \c_syst_min_allocated_mark - -\permanent\countdef\c_syst_min_counter_value = 253 \c_syst_min_counter_value = -"7FFFFFFF -\permanent\countdef\c_syst_max_counter_value = 254 \c_syst_max_counter_value = "7FFFFFFF + +\permanent\countdef\c_syst_min_allocated_mark = 205 \c_syst_min_allocated_mark = 16 % a few scratch ones +\permanent\countdef\c_syst_max_allocated_mark = 206 \c_syst_max_allocated_mark = 1024 % max 10K in luametatex anyway + +\permanent\countdef\c_syst_min_allocated_attribute = 207 \c_syst_min_allocated_attribute = 1024 % 0-1023 : private +\permanent\countdef\c_syst_max_allocated_attribute = 208 \c_syst_min_allocated_attribute = \directlua{tex.write(tex.magicconstants.max_attribute_register_index)} % 65535 % no allocator, managed differently + +\permanent\countdef\c_syst_max_allocated_count = 211 \c_syst_max_allocated_count = \directlua{tex.write(tex.magicconstants.max_int_register_index)} % 65535 % is adapted later on +\permanent\countdef\c_syst_max_allocated_dimen = 212 \c_syst_max_allocated_dimen = \directlua{tex.write(tex.magicconstants.max_dimen_register_index)} % idem +\permanent\countdef\c_syst_max_allocated_skip = 213 \c_syst_max_allocated_skip = \directlua{tex.write(tex.magicconstants.max_glue_register_index)} % idem +\permanent\countdef\c_syst_max_allocated_muskip = 214 \c_syst_max_allocated_muskip = \directlua{tex.write(tex.magicconstants.max_mu_glue_register_index)} % idem +\permanent\countdef\c_syst_max_allocated_box = 215 \c_syst_max_allocated_box = \directlua{tex.write(tex.magicconstants.max_box_register_index)} % idem +\permanent\countdef\c_syst_max_allocated_toks = 216 \c_syst_max_allocated_toks = \directlua{tex.write(tex.magicconstants.max_toks_register_index)} % idem +\permanent\countdef\c_syst_max_allocated_read = 217 \c_syst_max_allocated_read = \c_syst_max_allocated_iohandle +\permanent\countdef\c_syst_max_allocated_write = 218 \c_syst_max_allocated_write = \c_syst_max_allocated_iohandle + +\permanent\countdef\c_syst_last_allocated_count = 221 \c_syst_last_allocated_count = \c_syst_min_allocated_register +\permanent\countdef\c_syst_last_allocated_dimen = 222 \c_syst_last_allocated_dimen = \c_syst_min_allocated_register +\permanent\countdef\c_syst_last_allocated_skip = 223 \c_syst_last_allocated_skip = \c_syst_min_allocated_register +\permanent\countdef\c_syst_last_allocated_muskip = 224 \c_syst_last_allocated_muskip = \c_syst_min_allocated_register +\permanent\countdef\c_syst_last_allocated_box = 225 \c_syst_last_allocated_box = \c_syst_min_allocated_register +\permanent\countdef\c_syst_last_allocated_toks = 226 \c_syst_last_allocated_toks = \c_syst_min_allocated_register +\permanent\countdef\c_syst_last_allocated_read = 227 \c_syst_last_allocated_read = \c_syst_min_allocated_iohandle +\permanent\countdef\c_syst_last_allocated_write = 228 \c_syst_last_allocated_write = \c_syst_min_allocated_iohandle +\permanent\countdef\c_syst_last_allocated_marks = 229 \c_syst_last_allocated_marks = \c_syst_min_allocated_mark + +\permanent\countdef\c_syst_min_counter_value = 253 \c_syst_min_counter_value = -"7FFFFFFF +\permanent\countdef\c_syst_max_counter_value = 254 \c_syst_max_counter_value = "7FFFFFFF \immutable\integerdef\zerocount 0 \immutable\integerdef\plusone 1 @@ -339,15 +353,15 @@ %D The allocators share a common helper macro. Marks might be changed to work in lower %D regions and we always assumes allocation. -\permanent\protected\def\newcount {\syst_basics_allocate\c_syst_last_allocated_count \count \countdef \c_syst_max_allocated_register} -\permanent\protected\def\newdimen {\syst_basics_allocate\c_syst_last_allocated_dimen \dimen \dimendef \c_syst_max_allocated_register} -\permanent\protected\def\newskip {\syst_basics_allocate\c_syst_last_allocated_skip \skip \skipdef \c_syst_max_allocated_register} -\permanent\protected\def\newmuskip{\syst_basics_allocate\c_syst_last_allocated_muskip\muskip\muskipdef \c_syst_max_allocated_register} -\permanent\protected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \integerdef\c_syst_max_allocated_register} -\permanent\protected\def\newtoks {\syst_basics_allocate\c_syst_last_allocated_toks \toks \toksdef \c_syst_max_allocated_register} -\permanent\protected\def\newread {\syst_basics_allocate\c_syst_last_allocated_read \read \integerdef\c_syst_max_allocated_iohandle} -\permanent\protected\def\newwrite {\syst_basics_allocate\c_syst_last_allocated_write \write \integerdef\c_syst_max_allocated_iohandle} -\permanent\protected\def\newmarks {\syst_basics_allocate\c_syst_last_allocated_marks \marks \integerdef\c_syst_max_allocated_mark } +\permanent\protected\def\newcount {\syst_basics_allocate\c_syst_last_allocated_count \count \countdef \c_syst_max_allocated_count} +\permanent\protected\def\newdimen {\syst_basics_allocate\c_syst_last_allocated_dimen \dimen \dimendef \c_syst_max_allocated_dimen} +\permanent\protected\def\newskip {\syst_basics_allocate\c_syst_last_allocated_skip \skip \skipdef \c_syst_max_allocated_skip} +\permanent\protected\def\newmuskip{\syst_basics_allocate\c_syst_last_allocated_muskip\muskip\muskipdef \c_syst_max_allocated_muskip} +\permanent\protected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \integerdef\c_syst_max_allocated_box} +\permanent\protected\def\newtoks {\syst_basics_allocate\c_syst_last_allocated_toks \toks \toksdef \c_syst_max_allocated_toks} +\permanent\protected\def\newread {\syst_basics_allocate\c_syst_last_allocated_read \read \integerdef\c_syst_max_allocated_read} +\permanent\protected\def\newwrite {\syst_basics_allocate\c_syst_last_allocated_write \write \integerdef\c_syst_max_allocated_write} +\permanent\protected\def\newmarks {\syst_basics_allocate\c_syst_last_allocated_marks \marks \integerdef\c_syst_max_allocated_mark} \firstvalidlanguage \plusone % so zero is ignored in hyphenation, this might become the default @@ -424,9 +438,6 @@ %D Since the number of chars exceed 256 now, we can use \type {\chardef} instead of %D the more limited \type {\mathchardef}. -% \protected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \chardef\c_syst_max_allocated_register} -% \protected\def\newmarks{\syst_basics_allocate\c_syst_last_allocated_marks\marks\chardef\c_syst_max_allocated_register} - %D Attributes are something very \LUATEX. In \CONTEXT\ you are not supposed to use %D the attributes directly but always allocate then first. For instance attribute~0 %D is reserved for special purposes (this might change). Attributes in the range @@ -434,7 +445,7 @@ \immutable\integerdef\attributeunsetvalue\c_syst_min_counter_value % used to be \minusone -% \permanent\protected\def\newattribute{\syst_basics_allocate\c_syst_last_allocated_attribute\attribute\attributedef\c_syst_max_allocated_register} +% \permanent\protected\def\newattribute{\syst_basics_allocate\c_syst_last_allocated_attribute\attribute\attributedef\c_syst_max_allocated_attribute} % %D Not used by \CONTEXT\ but for instance \PICTEX\ needs it. It's a trick to force % %D strings instead of tokens that take more memory. @@ -739,14 +750,16 @@ % For now: -\permanent\protected\def\defUmathtopaccent #1#2#3#4{\global\immutable\protected\def#1{\Umathaccent "#2 "#3 "#4 }} -\permanent\protected\def\defUmathbotaccent #1#2#3#4{\global\immutable\protected\def#1{\Umathbotaccent "#2 "#3 "#4 }} -\permanent\protected\def\defUdelimiterover #1#2#3#4{\global\immutable\protected\def#1{\Udelimiterover "#2 "#3 }} -\permanent\protected\def\defUdelimiterunder #1#2#3#4{\global\immutable\protected\def#1{\Udelimiterunder "#2 "#3 }} -\permanent\protected\def\defUdelimiter #1#2#3#4{\global\immutable\protected\def#1{\Udelimiter "#2 "#3 "#4 }} -\permanent\protected\def\defUradical #1#2#3{\global\immutable\protected\def#1{\Uradical "#2 "#3 }} -\permanent\protected\def\defUroot #1#2#3{\global\immutable\protected\def#1{\Uroot "#2 "#3 }} -\permanent\protected\def\defUmathchar #1#2#3#4{\global\immutable\Umathchardef #1 "#2 "#3 "#4 } +\permanent\protected\def\defUmathfixedtopaccent#1#2#3#4{\global\immutable\protected\def#1{\Umathtopaccent \s!fixed "#2 "#3 "#4 }} +\permanent\protected\def\defUmathfixedbotaccent#1#2#3#4{\global\immutable\protected\def#1{\Umathbotaccent \s!fixed "#2 "#3 "#4 }} +\permanent\protected\def\defUmathtopaccent #1#2#3#4{\global\immutable\protected\def#1{\Umathtopaccent "#2 "#3 "#4 }} +\permanent\protected\def\defUmathbotaccent #1#2#3#4{\global\immutable\protected\def#1{\Umathbotaccent "#2 "#3 "#4 }} +\permanent\protected\def\defUdelimiterover #1#2#3#4{\global\immutable\protected\def#1{\Udelimiterover "#2 "#3 }} +\permanent\protected\def\defUdelimiterunder #1#2#3#4{\global\immutable\protected\def#1{\Udelimiterunder "#2 "#3 }} +\permanent\protected\def\defUdelimiter #1#2#3#4{\global\immutable\protected\def#1{\Udelimiter "#2 "#3 "#4 }} +\permanent\protected\def\defUradical #1#2#3{\global\immutable\protected\def#1{\Uradical "#2 "#3 }} +\permanent\protected\def\defUroot #1#2#3{\global\immutable\protected\def#1{\Uroot "#2 "#3 }} +\permanent\protected\def\defUmathchar #1#2#3#4{\global\immutable\Umathchardef #1 "#2 "#3 "#4 } %D For a while we keep the following, as systems like tikz need it. Best not use %D that one \CONTEXT. It will probably move to the tikz loader. @@ -1130,7 +1143,7 @@ \permanent\def\hidewidth % for alignment entries that can stick out {\hskip\hideskip} -\permanent\def\ialign % initialized \halign +\permanent\def\ialign % initialized \halign, to be used grouped! {\everycr\emptytoks \tabskip\zeroskip \halign} @@ -1308,29 +1321,28 @@ %D %D There is a little extra overhead in the overload protection but not that much. -\permanent\countdef\c_syst_local_count = 221 \c_syst_local_count = \c_syst_max_allocated_register -\permanent\countdef\c_syst_local_dimen = 222 \c_syst_local_dimen = \c_syst_local_count -\permanent\countdef\c_syst_local_skip = 223 \c_syst_local_skip = \c_syst_local_count -\permanent\countdef\c_syst_local_muskip = 224 \c_syst_local_muskip = \c_syst_local_count -\permanent\countdef\c_syst_local_box = 225 \c_syst_local_box = \c_syst_local_count -\permanent\countdef\c_syst_local_toks = 226 \c_syst_local_toks = \c_syst_local_count -\permanent\countdef\c_syst_local_read = 227 \c_syst_local_read = \c_syst_local_count -\permanent\countdef\c_syst_local_write = 228 \c_syst_local_write = \c_syst_local_count - -\c_syst_max_allocated_register \numexpr\c_syst_max_allocated_register:2\relax % floor +\permanent\countdef\c_syst_local_count = 231 \c_syst_local_count = \c_syst_max_allocated_count +\permanent\countdef\c_syst_local_dimen = 232 \c_syst_local_dimen = \c_syst_max_allocated_dimen +\permanent\countdef\c_syst_local_skip = 233 \c_syst_local_skip = \c_syst_max_allocated_skip +\permanent\countdef\c_syst_local_muskip = 234 \c_syst_local_muskip = \c_syst_max_allocated_muskip +\permanent\countdef\c_syst_local_box = 235 \c_syst_local_box = \c_syst_max_allocated_box +\permanent\countdef\c_syst_local_toks = 236 \c_syst_local_toks = \c_syst_max_allocated_toks +\permanent\countdef\c_syst_local_read = 237 \c_syst_local_read = \c_syst_max_allocated_read +\permanent\countdef\c_syst_local_write = 238 \c_syst_local_write = \c_syst_max_allocated_write + +\c_syst_max_allocated_count \numexpr\c_syst_max_allocated_count :2\relax % floor +\c_syst_max_allocated_dimen \numexpr\c_syst_max_allocated_dimen :2\relax % floor +\c_syst_max_allocated_skip \numexpr\c_syst_max_allocated_skip :2\relax % floor +\c_syst_max_allocated_muskip \numexpr\c_syst_max_allocated_muskip :2\relax % floor +\c_syst_max_allocated_toks \numexpr\c_syst_max_allocated_toks :2\relax % floor +\c_syst_max_allocated_box \numexpr\c_syst_max_allocated_box :2\relax % floor +\c_syst_max_allocated_read \numexpr\c_syst_max_allocated_read :2\relax % floor +\c_syst_max_allocated_write \numexpr\c_syst_max_allocated_write :2\relax % floor \permanent\protected\def\syst_local_overflow#1#2{\writestatus\m!system{no room for local #1 \string#2}\wait} -\permanent\protected\def\setnewlocaldimen#1% - {\ifnum\c_syst_local_dimen>\c_syst_max_allocated_register - \advance\c_syst_local_dimen\minusone\dimendef#1\c_syst_local_dimen - \else - \syst_local_overflow_dimen#1% - \fi - #1} - \permanent\protected\def\setnewlocalcount#1% - {\ifnum\c_syst_local_count>\c_syst_max_allocated_register + {\ifnum\c_syst_local_count>\c_syst_max_allocated_count \advance\c_syst_local_count\minusone \overloaded\frozen\countdef#1\c_syst_local_count \else @@ -1338,8 +1350,16 @@ \fi #1} +\permanent\protected\def\setnewlocaldimen#1% + {\ifnum\c_syst_local_dimen>\c_syst_max_allocated_dimen + \advance\c_syst_local_dimen\minusone\dimendef#1\c_syst_local_dimen + \else + \syst_local_overflow_dimen#1% + \fi + #1} + \permanent\protected\def\setnewlocalskip#1% - {\ifnum\c_syst_local_skip>\c_syst_max_allocated_register + {\ifnum\c_syst_local_skip>\c_syst_max_allocated_skip \advance\c_syst_local_skip\minusone \overloaded\frozen\skipdef#1\c_syst_local_skip \else @@ -1348,7 +1368,7 @@ #1} \permanent\protected\def\setnewlocalmuskip#1% - {\ifnum\c_syst_local_muskip>\c_syst_max_allocated_register + {\ifnum\c_syst_local_muskip>\c_syst_max_allocated_muskip \advance\c_syst_local_muskip\minusone \overloaded\frozen\muskipdef#1\c_syst_local_muskip \else @@ -1357,7 +1377,7 @@ #1} \permanent\protected\def\setnewlocaltoks#1% - {\ifnum\c_syst_local_toks>\c_syst_max_allocated_register + {\ifnum\c_syst_local_toks>\c_syst_max_allocated_toks \advance\c_syst_local_toks\minusone \overloaded\frozen\toksdef#1\c_syst_local_toks \else @@ -1366,7 +1386,7 @@ #1} \permanent\protected\def\setnewlocalbox#1% - {\ifnum\c_syst_local_box>\c_syst_max_allocated_register + {\ifnum\c_syst_local_box>\c_syst_max_allocated_box \advance\c_syst_local_box\minusone \overloaded\frozen\integerdef#1\c_syst_local_box \else @@ -1375,7 +1395,7 @@ \setbox#1} \permanent\protected\def\newlocalread#1% so no set - {\ifnum\c_syst_local_read>\c_syst_max_allocated_register + {\ifnum\c_syst_local_read>\c_syst_max_allocated_read \advance\c_syst_local_read\minusone \overloaded\frozen\integerdef#1\c_syst_local_read \else @@ -1383,7 +1403,7 @@ \fi} \permanent\protected\def\newlocalwrite#1% so no set - {\ifnum\c_syst_local_write>\c_syst_max_allocated_register + {\ifnum\c_syst_local_write>\c_syst_max_allocated_write \advance\c_syst_local_write\minusone \overloaded\frozen\integerdef#1\c_syst_local_write \else @@ -1435,4 +1455,8 @@ \tracingfullboxes\zerocount +%D We don't do this: + +% \setdefaultmathcodes % initializes traditional codes + \protect \endinput diff --git a/tex/context/base/mkxl/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt index c7d2fb2fc..f1bac2093 100644 --- a/tex/context/base/mkxl/toks-aux.lmt +++ b/tex/context/base/mkxl/toks-aux.lmt @@ -10,6 +10,24 @@ local max = math.max local formatters, gsub, char, gmatch = string.formatters, string.gsub, string.char, string.gmatch local concat = table.concat +do + + -- tex.magicconstants = { -- we use tex.constants for something else + -- running = -1073741824, -- null_flag + -- maxdimen = 1073741823, -- max_dimen + -- -- trueinch = 4736286, -- obsolete + -- } + + local c = status.getconstants() + local t = { } + for k, v in next, c do + t[gsub(k,"_","")] = v + end + + tex.magicconstants = table.setmetatableindex(t,c) + +end + -- todo : locals from scanners local function flags(t) @@ -165,8 +183,8 @@ tex.glyphoptioncodes = getthem(tex.getglyphoptionvalues, "glyphoptioncode") tex.groupcodes = getthem(tex.getgroupvalues, "groupcode") tex.hyphenationcodes = getthem(tex.gethyphenationvalues, "hyphenationcode") tex.mathcontrolcodes = getthem(tex.getmathcontrolvalues, "mathcontrolcode") -tex.mathflattencodes = getthem(tex.getmathflattenvalues, "mathflattencode") -tex.mathoptioncodes = getthem(tex.getmathoptionvalues, "") -- only at lua end +---.mathflattencodes = getthem(tex.getmathflattenvalues, "mathflattencode") +tex.noadoptioncodes = getthem(tex.getnoadoptionvalues, "") -- only at lua end tex.normalizecodes = getthem(tex.getnormalizevalues, "normalizecode") tex.automigrationcodes = getthem(tex.getautomigrationvalues, "automigrationcode") -- only at lua end tex.parcontextcodes = getthem(tex.getparcontextvalues, "parcontextcode") diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index e2c4133b4..255e26230 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -40,6 +40,7 @@ local setsubtype = nuts.setsubtype local setattr = nuts.setattr local setwidth = nuts.setwidth local setshift = nuts.setshift +local setoffsets = nuts.setoffsets local getid = nuts.getid local getfont = nuts.getfont @@ -410,7 +411,7 @@ local function sometext(str,layer,color,textcolor,lap,variant) info = hpack_nodes(info) local width = getwidth(info) if variant then - nuts.setoffsets(info,0,variant*exheight) + setoffsets(info,0,variant*exheight) end if lap then info = new_hlist(setlink(new_kern(-width),info)) @@ -835,7 +836,14 @@ local ruledbox do local info = setlink( this and copylist(this) or nil, (force_origin and emptyrule(wd,ht,dp)) -- we accept some overhead - or (dp == 0 and outlinerule and outlinerule(wd,ht,dp,linewidth)) + or dp == 0 and userrule { + width = wd, + height = ht, + line = linewidth, + type = "box", + baseline = false, + + } or userrule { width = wd, height = ht, @@ -843,6 +851,7 @@ local ruledbox do line = linewidth, type = "box", dashed = 3*size, + } ) -- @@ -972,6 +981,7 @@ end local ruledglue, ruledmathglue do local effectiveglue = nuts.effectiveglue + local iszeroglue = nuts.iszeroglue local gluecodes = nodes.gluecodes @@ -1002,6 +1012,7 @@ local ruledglue, ruledmathglue do local g_cache_is = caches["indentskip"] local g_cache_cs = caches["correctionskip"] local g_cache_gn = caches["gluename"] + local g_cache_gz = caches["gluezero"] local tags = { -- [userskip_code] = "US", @@ -1051,18 +1062,43 @@ local ruledglue, ruledmathglue do -- we sometimes pass previous as we can have issues in math (not watertight for all) - local f_amount = formatters["%s:%0.3f"] - local mathvalues = nodes.mathvalues + local f_amount = formatters["%s:%0.3f"] + local mathvalues = nodes.mathvalues + + mathvalues[-1] = "left" + mathvalues[-2] = "right" + + local morehack = setmetatableindex(function(t,k) + local v = mathematics.classnames[k] -- yet unknown +-- v = v and string.sub(v,1,4) or string.formatters["x%02x"](k) + v = v and string.sub(v,1,3) or string.formatters["x%02x"](k) + t[k] = v + return v + end) - local function gluename(name,layer,color) - local info = g_cache_gn[name] + local temphack = setmetatableindex(function(t,k) + local v = mathvalues[k] + if v then + v = gsub(v,"spacing","") -- old + else + v = k - 256 + v = morehack[v//64] ..morehack[v%64] + end + t[k] = v + return v + end) + + local function gluename(current,layer,color) + local name = getfont(current) + local zero = iszeroglue(current) + local info = zero and g_cache_gz[name] or g_cache_gn[name] if not info then - local text = hpack_string((gsub(mathvalues[name],"spacing","")),usedfont) - local rule = new_rule(emwidth/fraction,2*exheight,2.75*exheight) + local text = hpack_string(temphack[name],usedfont) + local rule = new_rule(emwidth/fraction,2*exheight,(zero and 4.25 or 2.75)*exheight) local list = getlist(text) setlisttransparency(list,color) settransparency(rule,color) - setshift(text,2*exheight) + setshift(text,(zero and 3.5 or 2)*exheight) info = new_hlist(setlink(rule,text)) setattr(info,a_layer,layer) g_cache_gn[name] = info @@ -1071,7 +1107,7 @@ local ruledglue, ruledmathglue do end ruledmathglue = function(head,current) - return insertnodebefore(head,current,gluename(getfont(current),l_glue,"trace:m")) + return insertnodebefore(head,current,gluename(current,l_glue,"trace:m")) end ruledglue = function(head,current,vertical,parent) @@ -1182,6 +1218,23 @@ local ruledkern do end +local ruledstrut do + + local strut_size = 65536 / 2 + local strut_code = nodes.rulecodes.strut + + ruledstrut = function(head,current) + if getsubtype(current) == strut_code and getwidth(current) == 0 then + -- maybe force gray + setwidth(current,strut_size) + setattr(current,a_layer,l_strut) + head, current = insertnodeafter(head,current,new_kern(-strut_size)) + end + return head, getnext(current) + end + +end + local ruleditalic do local i_cache = caches["italic"] @@ -1340,6 +1393,7 @@ do local par_code = nodecodes.par local mark_code = nodecodes.mark local insert_code = nodecodes.insert + local rule_code = nodecodes.rule local kerncodes = nodes.kerncodes local fontkern_code = kerncodes.fontkern @@ -1481,9 +1535,10 @@ do elseif a == unsetvalue then goto list end - if trace_strut then - setattr(current,a_layer,l_strut) - elseif id == glyph_code then + -- if trace_strut then + -- setattr(current,a_layer,l_strut) + -- else + if id == glyph_code then if trace_glyph then head, current = ruledglyph(head,current,previous) end @@ -1515,6 +1570,10 @@ do end elseif id == hlist_code or id == vlist_code then goto list + elseif id == rule_code then + if trace_strut then + head, current = ruledstrut(head,current) + end elseif id == whatsit_code then if trace_whatsit then head, current = ruledwhatsit(head,current) @@ -1766,7 +1825,7 @@ do actions = { setvisual, context } } - implement { + implement { name = "setvisuallayer", arguments = "string", actions = visualizers.setlayer diff --git a/tex/context/base/mkxl/type-imp-bengali.mkxl b/tex/context/base/mkxl/type-imp-bengali.mkxl new file mode 100644 index 000000000..84a0b6402 --- /dev/null +++ b/tex/context/base/mkxl/type-imp-bengali.mkxl @@ -0,0 +1,73 @@ +%D \module +%D [ file=type-imp-bengali, +%D version=2022.02.02, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Bengali, +%D author=śrīrāma (Sreeram), +%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. + +\starttypescriptcollection[bengali] + + \doifunknownfontfeature {bengali-bold-30} {\definefontfeature[bengali-bold-30][boldened-30]} + + % Symbolic names for fonts: + + \starttypescript [\s!serif] [murty-bangla] + \definefontsynonym [MurtyBengali-Regular] [\s!name:murtybanglaregular] [\s!features=bengali-two] + \definefontsynonym [MurtyBengali-Bold] [\s!name:murtybanglaregular] [\s!features={bengali-two,bengali-bold-30}] + \stoptypescript + + \starttypescript [\s!sans] [baloo-da, baloo-da-extrabold] + \definefontsynonym [BalooDa2-Regular] [\s!name:balooda2regular] [\s!features=bengali-two] + \definefontsynonym [BalooDa2-Medium] [\s!name:balooda2medium] [\s!features=bengali-two] + \definefontsynonym [BalooDa2-Semibold] [\s!name:balooda2semibold] [\s!features=bengali-two] + \definefontsynonym [BalooDa2-Bold] [\s!name:balooda2bold] [\s!features=bengali-two] + \definefontsynonym [BalooDa2-Extrabold] [\s!name:balooda2extrabold] [\s!features=bengali-two] + \stoptypescript + + % Grouping of styles: + + \starttypescript [\s!sans] [baloo-da] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooDa2-Regular] + \definefontsynonym [\s!SansSlanted] [BalooDa2-Medium] + \definefontsynonym [\s!SansBold] [BalooDa2-Bold] + \definefontsynonym [\s!SansBoldSlanted] [BalooDa2-Semibold] + \stoptypescript + + \starttypescript [\s!sans] [baloo-da-extrabold] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooDa2-Medium] + \definefontsynonym [\s!SansSlanted] [BalooDa2-Semibold] + \definefontsynonym [\s!SansBold] [BalooDa2-Extrabold] + \definefontsynonym [\s!SansBoldSlanted] [BalooDa2-Bold] + \stoptypescript + + \starttypescript [\s!serif] [murty-bangla] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Serif] [MurtyBengali-Regular] + \definefontsynonym [\s!SerifBold] [MurtyBengali-Bold] + \stoptypescript + + % Typefaces: + + \starttypescript [baloo-da, baloo-da-extrabold] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default] [\s!rscale=1.1] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [murty-bangla] + \definetypeface [murty-bangla] [\s!rm] [\s!serif] [murty-bangla] [\s!default] [\s!rscale=1.1] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/base/mkxl/type-imp-devanagari.mkxl b/tex/context/base/mkxl/type-imp-devanagari.mkxl new file mode 100644 index 000000000..4fb082094 --- /dev/null +++ b/tex/context/base/mkxl/type-imp-devanagari.mkxl @@ -0,0 +1,244 @@ +%D \module +%D [ file=type-imp-devanagari, +%D version=2022.02.02, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Devanagari, +%D author=śrīrāma (Sreeram), +%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 collection uses rscaling so that the fonts can be used alongside. + +\starttypescriptcollection[devanagari] + + \definefontfeature + [shobhikafeatures] + [devanagari-two] + [goodies=shobhika.lfg, + indic={movematra=auto,conjuncts=quit}, + sanitizer=dev2rkrf] + + \definefontfeature + [baloofeatures] + [shobhikafeatures] + + \definefontfeature + [amitafeatures] + [devanagari-two] + [goodies=shobhika.lfg, + sanitizer=dev2rkrf] + + \definefontfeature + [jainifeatures] + [shobhikafeatures] + [\s!ss01=yes,ss05=yes] + + \definefontfeature + [adishilafeatures] + [devanagari-one] + [indic={movematra=auto,conjuncts=quit}] + + % Symbolic names for fonts: + + \starttypescript [\s!serif] [adishila] + \definefontsynonym [Adishila-Regular] [\s!name:adishilaregular] [\s!features=adishilafeatures] + \definefontsynonym [Adishila-Bold] [\s!name:adishilabold] [\s!features=adishilafeatures] + \definefontsynonym [Adishila-Italic] [\s!name:adishilaitalic] [\s!features=adishilafeatures] + \definefontsynonym [Adishila-BoldItalic] [\s!name:adishilabolditalic] [\s!features=adishilafeatures] + \stoptypescript + + \starttypescript [\s!serif] [adishila-semibold] + \definefontsynonym [AdishilaSemibold-Regular] [\s!name:adishilasemiboldregular] [\s!features=adishilafeatures] + \definefontsynonym [AdishilaSemibold-Italic] [\s!name:adishilasemibolditalic] [\s!features=adishilafeatures] + \stoptypescript + + \starttypescript [\s!serif] [adishila-heavy] + \definefontsynonym [AdishilaHeavy-Regular] [\s!name:adishilaheavyregular] [\s!features=adishilafeatures] + \definefontsynonym [AdishilaHeavy-Italic] [\s!name:adishilaheavyitalic] [\s!features=adishilafeatures] + \stoptypescript + + \starttypescript [\s!serif] [adishila-dev] + \definefontsynonym [AdishilaDev-Regular] [\s!name:adishiladevregular] [\s!features=adishilafeatures] + \definefontsynonym [AdishilaDev-Bold] [\s!name:adishiladevbold] [\s!features=adishilafeatures] + \stoptypescript + + \starttypescript [\s!serif] [adishila-dev-guru] + \definefontsynonym [AdishilaDev-Guru] [\s!name:adishiladevguru] [\s!features=adishilafeatures] + \stoptypescript + + \starttypescript [\s!serif] [adishila-san] + \definefontsynonym [AdishilaSan-Regular] [\s!name:adishilasanregular] [\s!features=adishilafeatures] + \definefontsynonym [AdishilaSan-Bold] [\s!name:adishilasanbold] [\s!features=adishilafeatures] + \definefontsynonym [AdishilaSan-Italic] [\s!name:adishilasanitalic] [\s!features=adishilafeatures] + \definefontsynonym [AdishilaSan-BoldItalic] [\s!name:adishilasanbolditalic] [\s!features=adishilafeatures] + \stoptypescript + + \starttypescript [\s!serif] [adishila-san-letterpress] + \definefontsynonym [AdishilaSanLetterpress-Regular] [\s!name:adishilasanletterpressregular] [\s!features=adishilafeatures] + \definefontsynonym [AdishilaSanLetterpress-Bold] [\s!name:adishilasanletterpressbold] [\s!features=adishilafeatures] + \definefontsynonym [AdishilaSanLetterpress-Italic] [\s!name:adishilasanletterpressitalic] [\s!features=adishilafeatures] + \definefontsynonym [AdishilaSanLetterpress-BoldItalic] [\s!name:adishilasanletterpressbolditalic] [\s!features=adishilafeatures] + \stoptypescript + + \starttypescript [\s!serif] [shobhika] + \definefontsynonym [Shobhika-Regular] [\s!name:shobhikaregular] [\s!features=shobhikafeatures] + \definefontsynonym [Shobhika-Bold] [\s!name:shobhikabold] [\s!features=shobhikafeatures] + \stoptypescript + + \starttypescript [\s!sans] [baloo,baloo-extrabold] + \definefontsynonym [Baloo2-Regular] [\s!name:baloo2regular] [\s!features=baloofeatures] + \definefontsynonym [Baloo2-Medium] [\s!name:baloo2medium] [\s!features=baloofeatures] + \definefontsynonym [Baloo2-Semibold] [\s!name:baloo2semibold] [\s!features=baloofeatures] + \definefontsynonym [Baloo2-Bold] [\s!name:baloo2bold] [\s!features=baloofeatures] + \definefontsynonym [Baloo2-Extrabold] [\s!name:baloo2extrabold] [\s!features=baloofeatures] + \stoptypescript + + \starttypescript [\s!serif] [jaini] + \definefontsynonym [Jaini-Regular] [\s!name:jainiregular] [\s!features=jainifeatures] + \stoptypescript + + \starttypescript [\s!serif] [jaini-purva] + \definefontsynonym [JainiPurva-Regular] [\s!name:jainipurvaregular] [\s!features=jainifeatures] + \stoptypescript + + \starttypescript [\s!serif] [amita] + \definefontsynonym [Amita-Regular] [\s!name:amitaregular] [\s!features=amitafeatures] + \definefontsynonym [Amita-Bold] [\s!name:amitabold] [\s!features=amitafeatures] + \stoptypescript + + % Grouping of styles: + + \starttypescript [\s!serif] [adishila] [\s!name] + \definefontsynonym [\s!Serif] [Adishila-Regular] + \definefontsynonym [\s!SerifBold] [Adishila-Bold] + \definefontsynonym [\s!SerifItalic] [Adishila-Italic] + \definefontsynonym [\s!SerifBoldItalic] [Adishila-BoldItalic] + \stoptypescript + + \starttypescript [\s!serif] [adishila-semibold] [\s!name] + \definefontsynonym [\s!Serif] [AdishilaSemibold-Regular] + \definefontsynonym [\s!SerifItalic] [AdishilaSemibold-Italic] + \stoptypescript + + \starttypescript [\s!serif] [adishila-heavy] [\s!name] + \definefontsynonym [\s!Serif] [AdishilaHeavy-Regular] + \definefontsynonym [\s!SerifItalic] [AdishilaHeavy-Italic] + \stoptypescript + + \starttypescript [\s!serif] [adishila-dev] [\s!name] + \definefontsynonym [\s!Serif] [AdishilaDev-Regular] + \definefontsynonym [\s!SerifBold] [AdishilaDev-Bold] + \stoptypescript + + \starttypescript [\s!serif] [adishila-dev-guru] [\s!name] + \definefontsynonym [\s!Serif] [AdishilaDev-Guru] + \stoptypescript + + \starttypescript [\s!serif] [adishila-san] [\s!name] + \definefontsynonym [\s!Serif] [AdishilaSan-Regular] + \definefontsynonym [\s!SerifBold] [AdishilaSan-Bold] + \definefontsynonym [\s!SerifItalic] [AdishilaSan-Italic] + \definefontsynonym [\s!SerifBoldItalic] [AdishilaSan-BoldItalic] + \stoptypescript + + \starttypescript [\s!serif] [adishila-san-letterpress] [\s!name] + \definefontsynonym [\s!Serif] [AdishilaSanLetterpress-Regular] + \definefontsynonym [\s!SerifBold] [AdishilaSanLetterpress-Bold] + \definefontsynonym [\s!SerifItalic] [AdishilaSanLetterpress-Italic] + \definefontsynonym [\s!SerifBoldItalic] [AdishilaSanLetterpress-BoldItalic] + \stoptypescript + + \starttypescript [\s!serif] [shobhika] [\s!name] + \definefontsynonym [\s!Serif] [Shobhika-Regular] + \definefontsynonym [\s!SerifBold] [Shobhika-Bold] + \stoptypescript + + \starttypescript [\s!sans] [baloo] [\s!name] + \definefontsynonym [\s!Sans] [Baloo2-Regular] + \definefontsynonym [\s!SansBold] [Baloo2-Bold] + \definefontsynonym [\s!SansItalic] [Baloo2-Medium] + \definefontsynonym [\s!SansBoldItalic] [Baloo2-Semibold] + \stoptypescript + + \starttypescript [\s!sans] [baloo-extrabold] [\s!name] + \definefontsynonym [\s!Sans] [Baloo2-Medium] + \definefontsynonym [\s!SansItalic] [Baloo2-Semibold] + \definefontsynonym [\s!SansBoldItalic] [Baloo2-Bold] + \definefontsynonym [\s!SansBold] [Baloo2-Extrabold] + \stoptypescript + + \starttypescript [\s!serif] [jaini] [\s!name] + \definefontsynonym [\s!Serif] [Jaini-Regular] + \stoptypescript + + \starttypescript [\s!serif] [jaini-purva] [\s!name] + \definefontsynonym [\s!Serif] [JainiPurva-Regular] + \stoptypescript + + \starttypescript [\s!serif] [amita] [\s!name] + \definefontsynonym [\s!Serif] [Amita-Regular] + \definefontsynonym [\s!SerifBold] [Amita-Bold] + \stoptypescript + + % Typefaces: + + \starttypescript [adishila] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default] [\s!rscale=1.42] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + \starttypescript [adishila-semibold,adishila-heavy] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default] [\s!rscale=1.46] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [adishila-dev] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default] [\s!rscale=1.65] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [adishila-dev-guru,adishila-san,adishila-san-letterpress] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default] [\s!rscale=1.62] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [shobhika] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [baloo,baloo-extrabold] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [jaini,jaini-purva] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default] [\s!rscale=1.5] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [amita] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default] [\s!rscale=1.2] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/base/mkxl/type-imp-gujarati.mkxl b/tex/context/base/mkxl/type-imp-gujarati.mkxl new file mode 100644 index 000000000..d7f3f7072 --- /dev/null +++ b/tex/context/base/mkxl/type-imp-gujarati.mkxl @@ -0,0 +1,77 @@ +%D \module +%D [ file=type-imp-gujarati, +%D version=2022.02.02, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Gujarati, +%D author=śrīrāma (Sreeram), +%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. + +\starttypescriptcollection[gujarati] + + \definefontfeature + [baloobhaifeatures] + [gujarati-two] + [goodies=bhai.lfg, + indic={movematra=auto,conjuncts=quit}, + sanitizer=gjr2rkrf] + + % Symbolic names for fonts: + \starttypescript [\s!serif] [noto-serif-gujarati] + \definefontsynonym [NotoSerifGujarati-Regular] [\s!name:notoserifgujaratiregular] [\s!features=baloobhaifeatures] + \definefontsynonym [NotoSerifGujarati-Bold] [\s!name:notoserifgujaratibold] [\s!features=baloobhaifeatures] + \stoptypescript + + \starttypescript [\s!sans] [baloo-bhai, baloo-bhai-extrabold] + \definefontsynonym [BalooBhai2-Regular] [\s!name:baloobhai2regular] [\s!features=baloobhaifeatures] + \definefontsynonym [BalooBhai2-Medium] [\s!name:baloobhai2medium] [\s!features=baloobhaifeatures] + \definefontsynonym [BalooBhai2-Semibold] [\s!name:baloobhai2semibold] [\s!features=baloobhaifeatures] + \definefontsynonym [BalooBhai2-Bold] [\s!name:baloobhai2bold] [\s!features=baloobhaifeatures] + \definefontsynonym [BalooBhai2-Extrabold] [\s!name:baloobhai2extrabold] [\s!features=baloobhaifeatures] + \stoptypescript + + % Grouping of styles: + + \starttypescript [\s!serif] [noto-serif-gujarati] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Serif] [NotoSerifGujarati-Regular] + \definefontsynonym [\s!SerifBold] [NotoSerifGujarati-Bold] + \stoptypescript + + \starttypescript [\s!sans] [baloo-bhai] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooBhai2-Regular] + \definefontsynonym [\s!SansSlanted] [BalooBhai2-Medium] + \definefontsynonym [\s!SansBold] [BalooBhai2-Bold] + \definefontsynonym [\s!SansBoldSlanted] [BalooBhai2-Semibold] + \stoptypescript + + \starttypescript [\s!sans] [baloo-bhai-extrabold] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooBhai2-Medium] + \definefontsynonym [\s!SansSlanted] [BalooBhai2-Semibold] + \definefontsynonym [\s!SansBold] [BalooBhai2-Extrabold] + \definefontsynonym [\s!SansBoldSlanted] [BalooBhai2-Bold] + \stoptypescript + + % Typefaces: + + \starttypescript [baloo-bhai, baloo-bhai-extrabold] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default] [\s!rscale=1.1] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [noto-serif-gujarati] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default] [\s!rscale=1.1] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/base/mkxl/type-imp-indic.mkxl b/tex/context/base/mkxl/type-imp-indic.mkxl new file mode 100644 index 000000000..aeda08337 --- /dev/null +++ b/tex/context/base/mkxl/type-imp-indic.mkxl @@ -0,0 +1,800 @@ +%D \module +%D [ file=type-imp-indic, +%D version=2022.02.02, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=A Collection of Indic Fonts, +%D author=Sreeram & Hans, +%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 file is a compation to the other indic typescript that evolved out +%D of a series of experiments with fonts and extensive research by Sreeram +%D with respect to them either or not supporting level one and level two +%D features. When there are issues, just ask on the mailing list. + +\definefilesynonym [type-imp-adishila.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-adishila-semibold.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-adishila-heavy.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-adishila-dev.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-adishila-dev-guru.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-adishila-san.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-adishila-san-letterpress.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-shobhika.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-baloo-extrabold.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-baloo.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-jaini.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-jaini-purva.mkxl] [type-imp-devanagari.mkxl] +\definefilesynonym [type-imp-amita.mkxl] [type-imp-devanagari.mkxl] + +\definefilesynonym [type-imp-rit-rachana.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-panmana.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-ezhuthu.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-karumbi.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-chilanka.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-anjali-oldlipi.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-dyuthi.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-tn-joy.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-tn-joy-extrabold.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-gayathri.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-gayathri-thin.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-manjari.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-manjari-thin.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-baloo-chettan.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-baloo-chettan-extrabold.mkxl] [type-imp-malayalam.mkxl] +\definefilesynonym [type-imp-rit-sundar.mkxl] [type-imp-malayalam.mkxl] + +\definefilesynonym [type-imp-baloo-tammudu.mkxl] [type-imp-telugu.mkxl] +\definefilesynonym [type-imp-baloo-tammudu-extrabold.mkxl] [type-imp-telugu.mkxl] +\definefilesynonym [type-imp-murty-telugu.mkxl] [type-imp-telugu.mkxl] + +\definefilesynonym [type-imp-murty-kannada.mkxl] [type-imp-kannada.mkxl] + +\definefilesynonym [type-imp-baloo-thambi.mkxl] [type-imp-tamil.mkxl] +\definefilesynonym [type-imp-baloo-thambi-extrabold.mkxl] [type-imp-tamil.mkxl] + +\definefilesynonym [type-imp-baloo-bhai.mkxl] [type-imp-gujarati.mkxl] +\definefilesynonym [type-imp-baloo-bhai-extrabold.mkxl] [type-imp-gujarati.mkxl] +\definefilesynonym [type-imp-noto-serif-gujarati.mkxl] [type-imp-gujarati.mkxl] + +\definefilesynonym [type-imp-baloo-da.mkxl] [type-imp-bengali.mkxl] +\definefilesynonym [type-imp-baloo-da-extrabold.mkxl] [type-imp-bengali.mkxl] +\definefilesynonym [type-imp-murty-bangla.mkxl] [type-imp-bengali.mkxl] + +\continueifinputfile{type-imp-indic.mkxl} + +% \usetypescriptfile[type-imp-indic] + +\usemodule[article-basics] + +\setupbodyfont + [pagella] + +\setuphead + [title] + [alternative=middle, + hidenumber=yes, + after={\blank[halfline]}, + before={\blank[line]}, + page=no, + style=\bfb] + +\definedescription + [fs] + [alternative=left, + title=yes, + width=3cm, + distance=0cm, + before=, + after=, + headstyle={\switchtobodyfont[pagella]}] + +\usetransliteration + [indic] + +\definetransliteration + [devatoiast] + [color=blue, + vector={deva to iast}, + before=] + +\definetransliteration + [devatomlym] + [vector={deva to mlym}] + +\definetransliteration + [devatotlgu] + [vector={deva to tlgu}] + +\definetransliteration + [devatoknda] + [vector={deva to knda}] + +\definetransliteration + [devatogujr] + [vector={deva to gujr}] + +\definetransliteration + [devatobngl] + [vector={deva to bngl}] + +\definebuffer[words] +\definebuffer[iastbuffer] + +\language[sa] + +\starttext + +\startbuffer[words] +दंष्ट्रा श्रेयस्करी त्रेता विक्रेता तच्छ्री अङ्कित शृङ्गार क्व्य शार्ङ्ग निरृति +क्रतुवित्त बर्हिस् प्रेप्सित अङ्घ्रि पङ्क्ति कर्त्तव्य कर्तव्य श्लाघ्यम् +अवप्लुतम् युङ्क्ष्वा क्षेत्रज्ञ अग्निमीळे चँद्र हर्त्रे श्री आर्द्रं +\stopbuffer + +\startbuffer +\getbuffer[words] +\stopbuffer + + +% \startbuffer[iastbuffer] +% \startdevatoiast[before=\blank,after=\blank] +% \getbuffer +% \stopdevatoiast +% \stopbuffer +% +% \getbuffer[iastbuffer] + +% +% +% Devanagari +% +% +\starttitle[title={Adishila}] + \start + \switchtobodyfont[adishila] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Italic} + {\it\getbuffer} + \stopfs + \startfs{Bold Italic} + {\bi\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Adishila Semibold}] + \start + \switchtobodyfont[adishila-semibold] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Italic} + {\it\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Adishila Heavy}] + \start + \switchtobodyfont[adishila-heavy] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Italic} + {\it\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Adishila Dev}] + \start + \switchtobodyfont[adishila-dev] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Adishila Dev}] + \start + \switchtobodyfont[adishila-dev-guru] + \startfs{Guru} + \getbuffer + \stopfs + \stop +\stoptitle + +\starttitle[title={Adishila San}] + \start + \switchtobodyfont[adishila-san] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Italic} + {\it\getbuffer} + \stopfs + \startfs{Bold Italic} + {\bi\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Adishila San Letterpress}] + \start + \switchtobodyfont[adishila-san-letterpress] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Italic} + {\it\getbuffer} + \stopfs + \startfs{Bold Italic} + {\bi\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Shobhika}] + \start + \switchtobodyfont[shobhika] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Baloo 2 Extra Bold}] + \start + \switchtobodyfont[baloo-extrabold] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Italic} + {\it\getbuffer} + \stopfs + \startfs{Bold Italic} + {\bi\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Baloo 2}] + \start + \switchtobodyfont[baloo] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Italic} + {\it\getbuffer} + \stopfs + \startfs{Bold Italic} + {\bi\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Jaini}] + \start + \switchtobodyfont[jaini] + \startfs{Regular} + \getbuffer + \stopfs + \stop +\stoptitle + +\starttitle[title={Jaini Purva}] + \start + \switchtobodyfont[jaini-purva] + \startfs{Regular} + \getbuffer + \stopfs + \stop +\stoptitle + +\starttitle[title={Amita}] + \start + \switchtobodyfont[amita] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle +% +% +% Malayalam +% +% +\startbuffer +\startdevatomlym +\getbuffer[words] +\stopdevatomlym +\stopbuffer + +\starttitle[title={RIT Rachana}] + \start + \switchtobodyfont[rit-rachana] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Italic} + {\it\getbuffer} + \stopfs + \startfs{Bold Italic} + {\bi\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Panmana}] + \start + \switchtobodyfont[panmana] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Ezhuthu}] + \start + \switchtobodyfont[ezhuthu] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Slanted} + {\sl\getbuffer} + \stopfs + \startfs{Bold Slanted} + {\bs\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Karumbi}] + \start + \switchtobodyfont[karumbi] + \startfs{Regular} + \getbuffer + \stopfs + \stop +\stoptitle + +\starttitle[title={Chilanka}] + \start + \switchtobodyfont[chilanka] + \startfs{Regular} + \getbuffer + \stopfs + \stop +\stoptitle + +\starttitle[title={Anjali Old Lipi}] + \start + \switchtobodyfont[anjali-oldlipi] + \startfs{Regular} + \getbuffer + \stopfs + \stop +\stoptitle + +\starttitle[title={Dyuthi}] + \start + \switchtobodyfont[dyuthi] + \startfs{Regular} + \getbuffer + \stopfs + \stop +\stoptitle + +\starttitle[title={TN Joy}] + \start + \switchtobodyfont[tn-joy] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={TN Joy Extrabold}] + \start + \switchtobodyfont[tn-joy-extrabold] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Gayathri}] + \start + \switchtobodyfont[gayathri] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\sl\getbuffer} + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Gayathri Thin}] + \start + \switchtobodyfont[gayathri-thin] + \startfs{Thin (R)} + \getbuffer + \stopfs + \startfs{Bold*} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Manjari}] + \start + \switchtobodyfont[manjari] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Manjari Thin}] + \start + \switchtobodyfont[manjari-thin] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Baloo Chettan 2}] + \start + \switchtobodyfont[baloo-chettan] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Medium \type{\sl}} + {\sl\getbuffer} + \stopfs + \startfs{Semibold \type{\bs}} + {\bs\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Baloo Chettan 2 Extrabold}] + \start + \switchtobodyfont[baloo-chettan-extrabold] + \startfs{Medium \type{\tf}} + \getbuffer + \stopfs + \startfs{Extrabold \type{\bf}} + {\bf\getbuffer} + \stopfs + \startfs{Semibold \type{\sl}} + {\sl\getbuffer} + \stopfs + \startfs{Bold \type{\bs}} + {\bs\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={RIT Sundar}] + \start + \switchtobodyfont[rit-sundar] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle +% +% +% Telugu +% +% +\startbuffer +\startdevatotlgu +\getbuffer[words] +\stopdevatotlgu +\stopbuffer + +\starttitle[title={Baloo Tammudu 2}] + \start + \switchtobodyfont[baloo-tammudu] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Slanted} + {\sl\getbuffer} + \stopfs + \startfs{Bold Slanted} + {\bs\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Baloo Tammudu 2 Extrabold}] + \start + \switchtobodyfont[baloo-tammudu-extrabold] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \startfs{Italic} + {\sl\getbuffer} + \stopfs + \startfs{Bold Italic} + {\bs\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Murty Telugu}] + \start + \switchtobodyfont[murty-telugu] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Regular} + {\sl\getbuffer} + \stopfs + \startfs{Regular} + {\bf\getbuffer} + \stopfs + \startfs{Regular} + {\bs\getbuffer} + \stopfs + \stop +\stoptitle +% +% +% Kannada +% +% +\startbuffer +\startdevatoknda +\getbuffer[words] +\stopdevatoknda +\stopbuffer + +\starttitle[title={Murty Kannada}] + \start + \switchtobodyfont[murty-kannada] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Regular} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle +% +% +% Tamil +% +% +\start +\language[ta] +\startbuffer +சிற்றமபலம் புயல் காற்று முன்னர் அதே எதெ அதை ஔவையார் +தொடர்கதை கிழால்லி அழைப்பு வாயிலாக இயற்கை நுழைவாயில் +இளமை காஞ்சி கச்சி இல்க்கியம் ஸ்ரீ +\stopbuffer + +\starttitle[title={Baloo Thambi 2}] + \start + \switchtobodyfont[baloo-thambi] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{ஂMedium \type{\sl}} + {\sl\getbuffer} + \stopfs + \startfs{Semibold \type{\bs}} + {\bs\getbuffer} + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Baloo Thambi 2 Extrabold}] + \start + \switchtobodyfont[baloo-thambi-extrabold] + \startfs{Medium} + \getbuffer + \stopfs + \startfs{Semibold \type{\sl}} + {\sl\getbuffer} + \stopfs + \startfs{Bold \type{\bs}} + {\bs\getbuffer} + \stopfs + \startfs{Extrabold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle +\stop +% +% +% Gujarati +% +% +\startbuffer +\startdevatogujr +\getbuffer[words] +\stopdevatogujr +\stopbuffer + +\starttitle[title={Baloo Bhai 2}] + \start + \switchtobodyfont[baloo-bhai] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{ஂMedium \type{\sl}} + {\sl\getbuffer} + \stopfs + \startfs{Semibold \type{\bs}} + {\bs\getbuffer} + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Baloo Bhai 2 Extrabold}] + \start + \switchtobodyfont[baloo-bhai-extrabold] + \startfs{Medium} + \getbuffer + \stopfs + \startfs{Semibold \type{\sl}} + {\sl\getbuffer} + \stopfs + \startfs{Bold \type{\bs}} + {\bs\getbuffer} + \stopfs + \startfs{Extrabold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Noto Serif Gujarati}] + \start + \switchtobodyfont[noto-serif-gujarati] + \startfs{Medium} + \getbuffer + \stopfs + \startfs{Extrabold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle +% +% +% Bengali +% +% +\startbuffer +\startdevatobngl +\getbuffer[words] +\stopdevatobngl +\stopbuffer + +\starttitle[title={Baloo Da 2}] + \start + \switchtobodyfont[baloo-da] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Medium \type{\sl}} + {\sl\getbuffer} + \stopfs + \startfs{Semibold \type{\bs}} + {\bs\getbuffer} + \stopfs + \startfs{Bold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Baloo Da 2 Extrabold}] + \start + \switchtobodyfont[baloo-da-extrabold] + \startfs{Medium} + \getbuffer + \stopfs + \startfs{Semibold \type{\sl}} + {\sl\getbuffer} + \stopfs + \startfs{Bold \type{\bs}} + {\bs\getbuffer} + \stopfs + \startfs{Extrabold} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\starttitle[title={Murty Bengali}] + \start + \switchtobodyfont[murty-bangla] + \startfs{Regular} + \getbuffer + \stopfs + \startfs{Regular} + {\bf\getbuffer} + \stopfs + \stop +\stoptitle + +\stoptext diff --git a/tex/context/base/mkxl/type-imp-kannada.mkxl b/tex/context/base/mkxl/type-imp-kannada.mkxl new file mode 100644 index 000000000..4838075b2 --- /dev/null +++ b/tex/context/base/mkxl/type-imp-kannada.mkxl @@ -0,0 +1,73 @@ +%D \module +%D [ file=type-imp-kannada, +%D version=2022.01.27, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Dekannada, +%D author=śrīrāma (Sreeram), +%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. + +\starttypescriptcollection[kannada] + + \doifunknownfontfeature {kannada-bold-30} {\definefontfeature[kannada-bold-30][boldened-30]} + + % Symbolic names for fonts: + + \starttypescript [\s!serif] [murty-kannada] + \definefontsynonym [MurtyKannada-Regular] [\s!name:murtykannadaregular] [\s!features=kannada-two] + \definefontsynonym [MurtyKannada-Bold] [\s!name:murtykannadaregular] [\s!features={kannada-two,kannada-bold-30}] + \stoptypescript + + \starttypescript [\s!sans] [baloo-tamma, baloo-tamma-extrabold] + \definefontsynonym [BalooTamma2-Regular] [\s!name:balootamma2regular] [\s!features=kannada-two] + \definefontsynonym [BalooTamma2-Medium] [\s!name:balootamma2medium] [\s!features=kannada-two] + \definefontsynonym [BalooTamma2-Semibold] [\s!name:balootamma2semibold] [\s!features=kannada-two] + \definefontsynonym [BalooTamma2-Bold] [\s!name:balootamma2bold] [\s!features=kannada-two] + \definefontsynonym [BalooTamma2-Extrabold] [\s!name:balootamma2extrabold] [\s!features=kannada-two] + \stoptypescript + + % Grouping of styles: + + \starttypescript [\s!sans] [baloo-tamma] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooTamma2-Regular] + \definefontsynonym [\s!SansSlanted] [BalooTamma2-Medium] + \definefontsynonym [\s!SansBold] [BalooTamma2-Bold] + \definefontsynonym [\s!SansBoldSlanted] [BalooTamma2-Semibold] + \stoptypescript + + \starttypescript [\s!sans] [baloo-tamma-extrabold] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooTamma2-Medium] + \definefontsynonym [\s!SansSlanted] [BalooTamma2-Semibold] + \definefontsynonym [\s!SansBold] [BalooTamma2-Extrabold] + \definefontsynonym [\s!SansBoldSlanted] [BalooTamma2-Bold] + \stoptypescript + + \starttypescript [\s!serif] [murty-kannada] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Serif] [MurtyKannada-Regular] + \definefontsynonym [\s!SerifBold] [MurtyKannada-Bold] + \stoptypescript + + % Typefaces: + + \starttypescript [baloo-tamma, baloo-tamma-extrabold] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [murty-kannada] + \definetypeface [murty-kannada] [\s!rm] [\s!serif] [murty-kannada] [\s!default] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/base/mkxl/type-imp-malayalam.mkxl b/tex/context/base/mkxl/type-imp-malayalam.mkxl new file mode 100644 index 000000000..67a35d472 --- /dev/null +++ b/tex/context/base/mkxl/type-imp-malayalam.mkxl @@ -0,0 +1,224 @@ +%D \module +%D [ file=type-imp-malayam, +%D version=2022.01.27, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Demalayalam, +%D author=śrīrāma (Sreeram), +%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 collection uses rscaling so that the fonts can be used alongside. + +\starttypescriptcollection[malayalam] + + \doifunknownfontfeature {malayalam-bold-30} {\definefontfeature[malayalam-bold-30][boldened-30]} + + % Symbolic names for fonts: + + \starttypescript [\s!serif] [rit-rachana] + \definefontsynonym [RITRachana-Regular] [\s!name:ritrachanaregular] [\s!features=malayalam-two] + \definefontsynonym [RITRachana-Bold] [\s!name:ritrachanabold] [\s!features=malayalam-two] + \definefontsynonym [RITRachana-Italic] [\s!name:ritrachanaitalic] [\s!features=malayalam-two] + \definefontsynonym [RITRachana-BoldItalic] [\s!name:ritrachanabolditalic] [\s!features=malayalam-two] + \stoptypescript + + \starttypescript [\s!serif] [panmana] + \definefontsynonym [Panmana-Regular] [\s!name:panmanaregular] [\s!features=malayalam-two] + \definefontsynonym [Panmana-Bold] [\s!name:panmanaregular] [\s!features={malayalam-two,malayalam-bold-30}] + \stoptypescript + + \starttypescript [\s!serif] [rit-sundar] + \definefontsynonym [RITSundar-Regular] [\s!name:ritsundarbold] [\s!features=malayalam-two] + \definefontsynonym [RITSundar-Bold] [\s!name:ritsundarbold] [\s!features={malayalam-two,malayalam-bold-30}] + \stoptypescript + + \starttypescript [\s!sans] [tn-joy, tn-joy-extrabold] + \definefontsynonym [TNJoy-Regular] [\s!name:tnjoyregular] [\s!features=malayalam-two] + \definefontsynonym [TNJoy-Bold] [\s!name:tnjoybold] [\s!features=malayalam-two] + \definefontsynonym [TNJoy-Extrabold] [\s!name:tnjoyextrabold] [\s!features=malayalam-two] + \stoptypescript + + \starttypescript [\s!sans] [ezhuthu] + \definefontsynonym [Ezhuthu-Regular] [\s!name:ezhuthuregular] [\s!features=malayalam-two] + \definefontsynonym [Ezhuthu-Bold] [\s!name:ezhuthuregular] [\s!features={malayalam-two,malayalam-bold-30}] + \stoptypescript + + \starttypescript [\s!sans] [baloo-chettan,baloo-chettan-extrabold] + \definefontsynonym [BalooChettan2-Regular] [\s!name:baloochettan2regular] [\s!features=malayalam-two] + \definefontsynonym [BalooChettan2-Medium] [\s!name:baloochettan2medium] [\s!features=malayalam-two] + \definefontsynonym [BalooChettan2-Semibold] [\s!name:baloochettan2semibold] [\s!features=malayalam-two] + \definefontsynonym [BalooChettan2-Bold] [\s!name:baloochettan2bold] [\s!features=malayalam-two] + \definefontsynonym [BalooChettan2-Extrabold] [\s!name:baloochettan2extrabold] [\s!features=malayalam-two] + \stoptypescript + + \starttypescript [\s!sans] [gayathri, gayathri-thin] + \definefontsynonym [Gayathri-Regular] [\s!name:gayathriregular] [\s!features=malayalam-two] + \definefontsynonym [Gayathri-Bold] [\s!name:gayathribold] [\s!features=malayalam-two] + \definefontsynonym [Gayathri-Thin] [\s!name:gayathrithin] [\s!features=malayalam-two] + \stoptypescript + + \starttypescript [\s!sans] [manjari,manjari-thin] + \definefontsynonym [Manjari-Regular] [\s!name:manjariregular] [\s!features=malayalam-two] + \definefontsynonym [Manjari-Bold] [\s!name:manjaribold] [\s!features=malayalam-two] + \definefontsynonym [Manjari-Thin] [\s!name:manjarithin] [\s!features=malayalam-two] + \stoptypescript + + \starttypescript [\s!sans] [karumbi] + \definefontsynonym [Karumbi-Regular] [\s!name:karumbiregular] [\s!features=malayalam-two] + \stoptypescript + + \starttypescript [\s!sans] [chilanka] + \definefontsynonym [Chilanka-Regular] [\s!name:chilankaregular] [\s!features=malayalam-two] + \stoptypescript + + \starttypescript [\s!sans] [anjali-oldlipi] + \definefontsynonym [Anjali-Oldlipi-Regular] [\s!name:anjalioldlipiregular] [\s!features=malayalam-two] + \stoptypescript + + \starttypescript [\s!sans] [dyuthi] + \definefontsynonym [Dyuthi-Regular] [\s!name:dyuthiregular] [\s!features=malayalam-two] + \stoptypescript + + % Grouping of styles: + + \starttypescript [\s!serif] [rit-rachana] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Serif] [RITRachana-Regular] + \definefontsynonym [\s!SerifBold] [RITRachana-Bold] + \definefontsynonym [\s!SerifItalic] [RITRachana-Italic] + \definefontsynonym [\s!SerifBoldItalic] [RITRachana-BoldItalic] + \stoptypescript + + \starttypescript [\s!serif] [panmana] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Serif] [Panmana-Regular] + \definefontsynonym [\s!SerifBold] [Panmana-Bold] + \stoptypescript + + \starttypescript [\s!serif] [rit-sundar] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Serif] [RITSundar-Regular] + \definefontsynonym [\s!SerifBold] [RITSundar-Bold] + \stoptypescript + + \starttypescript [\s!sans] [tn-joy] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [TNJoy-Regular] + \definefontsynonym [\s!SansBold] [TNJoy-Bold] + \stoptypescript + + \starttypescript [\s!sans] [tn-joy-extrabold] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [TNJoy-Bold] + \definefontsynonym [\s!SansBold] [TNJoy-Extrabold] + \stoptypescript + + \starttypescript [\s!sans] [ezhuthu] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [Ezhuthu-Regular] + \definefontsynonym [\s!SansBold] [Ezhuthu-Bold] + \stoptypescript + + \starttypescript [\s!sans] [karumbi] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [Karumbi-Regular] + \definefontsynonym [\s!SansBold] [Karumbi-Bold] + \stoptypescript + + \starttypescript [\s!sans] [chilanka] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [Chilanka-Regular] + \stoptypescript + + \starttypescript [\s!sans] [anjali-oldlipi] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [Anjali-Oldlipi-Regular] + \stoptypescript + + \starttypescript [\s!sans] [dyuthi] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [Dyuthi-Regular] + \stoptypescript + + \starttypescript [\s!sans] [gayathri] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [Gayathri-Regular] + \definefontsynonym [\s!SansBold] [Gayathri-Bold] + \stoptypescript + + \starttypescript [\s!sans] [gayathri-thin] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [Gayathri-Thin] + \definefontsynonym [\s!SansBold] [Gayathri-Regular] + \stoptypescript + + \starttypescript [\s!sans] [manjari] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans ] [Manjari-Regular] + \definefontsynonym [\s!SansBold] [Manjari-Bold] + \stoptypescript + + \starttypescript [\s!sans] [manjari-thin] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [Manjari-Thin] + \definefontsynonym [\s!SansBold] [Manjari-Regular] + \stoptypescript + + \starttypescript [\s!sans] [baloo-chettan] [\s!name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [BalooChettan2-Regular] + \definefontsynonym [\s!SansBold] [BalooChettan2-Bold] + \definefontsynonym [\s!SansSlanted] [BalooChettan2-Medium] + \definefontsynonym [\s!SansBoldSlanted] [BalooChettan2-Semibold] + \stoptypescript + + \starttypescript [\s!sans] [baloo-chettan-extrabold] [name] + \setups[\s!font:\s!fallback:\s!sans] + \definefontsynonym [\s!Sans] [BalooChettan2-Medium] + \definefontsynonym [\s!SansSlanted] [BalooChettan2-Semibold] + \definefontsynonym [\s!SansBoldSlanted] [BalooChettan2-Bold] + \definefontsynonym [\s!SansBold] [BalooChettan2-Extrabold] + \stoptypescript + + % Typefaces: + + \starttypescript [rit-rachana,rit-sundar,panmana] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default] [\s!rscale=1.25] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [ezhuthu,karumbi,tn-joy,tn-joy-extrabold] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default] [\s!rscale=1.25] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [chilanka,anjali-oldlipi] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [dyuthi,gayathri,gayathri-thin,manjari,manjari-thin] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default] [\s!rscale=1.1] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [baloo-chettan,baloo-chettan-extrabold] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [baloo-chettan] [\s!default] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/base/mkxl/type-imp-tamil.mkxl b/tex/context/base/mkxl/type-imp-tamil.mkxl new file mode 100644 index 000000000..90516365e --- /dev/null +++ b/tex/context/base/mkxl/type-imp-tamil.mkxl @@ -0,0 +1,53 @@ +%D \module +%D [ file=type-imp-tamil, +%D version=2022.02.02, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Tamil, +%D author=śrīrāma (Sreeram), +%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. + +\starttypescriptcollection[tamil] + + % Symbolic names for fonts: + + \starttypescript [\s!sans] [baloo-thambi, baloo-thambi-extrabold] + \definefontsynonym [BalooThambi2-Regular] [\s!name:baloothambi2regular] [\s!features=tamil-two] + \definefontsynonym [BalooThambi2-Medium] [\s!name:baloothambi2medium] [\s!features=tamil-two] + \definefontsynonym [BalooThambi2-Semibold] [\s!name:baloothambi2semibold] [\s!features=tamil-two] + \definefontsynonym [BalooThambi2-Bold] [\s!name:baloothambi2bold] [\s!features=tamil-two] + \definefontsynonym [BalooThambi2-Extrabold] [\s!name:baloothambi2extrabold] [\s!features=tamil-two] + \stoptypescript + + % Grouping of styles: + + \starttypescript [\s!sans] [baloo-thambi] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooThambi2-Regular] + \definefontsynonym [\s!SansSlanted] [BalooThambi2-Medium] + \definefontsynonym [\s!SansBold] [BalooThambi2-Bold] + \definefontsynonym [\s!SansBoldSlanted] [BalooThambi2-Semibold] + \stoptypescript + + \starttypescript [\s!sans] [baloo-thambi-extrabold] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooThambi2-Medium] + \definefontsynonym [\s!SansSlanted] [BalooThambi2-Semibold] + \definefontsynonym [\s!SansBold] [BalooThambi2-Extrabold] + \definefontsynonym [\s!SansBoldSlanted] [BalooThambi2-Bold] + \stoptypescript + + % Typefaces: + + \starttypescript [baloo-thambi, baloo-thambi-extrabold] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/base/mkxl/type-imp-telugu.mkxl b/tex/context/base/mkxl/type-imp-telugu.mkxl new file mode 100644 index 000000000..33d07664c --- /dev/null +++ b/tex/context/base/mkxl/type-imp-telugu.mkxl @@ -0,0 +1,74 @@ +%D \module +%D [ file=type-imp-telugu, +%D version=2022.01.27, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Telugu, +%D author=śrīrāma (Sreeram), +%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. + +\starttypescriptcollection[telugu] + + \doifunknownfontfeature {telugu-bold-30} {\definefontfeature[telugu-bold-30][boldened-30]} + \doifunknownfontfeature {telugu-slant} {\definefontfeature[telugu-slant][slant=0.25]} + + % Symbolic names for fonts: + + \starttypescript [\s!serif] [murty-telugu] + \definefontsynonym [MurtyTelugu-Regular] [\s!name:murtyteluguregular] [\s!features=telugu-two] + \definefontsynonym [MurtyTelugu-Bold] [\s!name:murtyteluguregular] [\s!features={telugu-two,telugu-bold-30}] + \stoptypescript + + \starttypescript [\s!sans] [baloo-tammudu, baloo-tammudu-extrabold] + \definefontsynonym [BalooTammudu2-Regular] [\s!name:balootammudu2regular] [\s!features=telugu-two] + \definefontsynonym [BalooTammudu2-Medium] [\s!name:balootammudu2medium] [\s!features=telugu-two] + \definefontsynonym [BalooTammudu2-Semibold] [\s!name:balootammudu2semibold] [\s!features=telugu-two] + \definefontsynonym [BalooTammudu2-Bold] [\s!name:balootammudu2bold] [\s!features=telugu-two] + \definefontsynonym [BalooTammudu2-Extrabold] [\s!name:balootammudu2extrabold] [\s!features=telugu-two] + \stoptypescript + + % Grouping of styles: + + \starttypescript [\s!sans] [baloo-tammudu] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooTammudu2-Regular] + \definefontsynonym [\s!SansSlanted] [BalooTammudu2-Medium] + \definefontsynonym [\s!SansBold] [BalooTammudu2-Bold] + \definefontsynonym [\s!SansBoldSlanted] [BalooTammudu2-Semibold] + \stoptypescript + + \starttypescript [\s!sans] [baloo-tammudu-extrabold] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Sans] [BalooTammudu2-Medium] + \definefontsynonym [\s!SansSlanted] [BalooTammudu2-Semibold] + \definefontsynonym [\s!SansBold] [BalooTammudu2-Extrabold] + \definefontsynonym [\s!SansBoldSlanted] [BalooTammudu2-Bold] + \stoptypescript + + \starttypescript [\s!serif] [murty-telugu] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Serif] [MurtyTelugu-Regular] + \definefontsynonym [\s!SerifBold] [MurtyTelugu-Bold] + \stoptypescript + + % Typefaces: + + \starttypescript [baloo-tammudu, baloo-tammudu-extrabold] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + + \starttypescript [murty-telugu] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [murty-telugu] [\s!default] + \definetypeface [\typescriptone] [\s!ss] [\s!sans] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [dejavu] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/base/mkxl/typo-mar.lmt b/tex/context/base/mkxl/typo-mar.lmt index b590c9ecf..87eafb062 100644 --- a/tex/context/base/mkxl/typo-mar.lmt +++ b/tex/context/base/mkxl/typo-mar.lmt @@ -82,8 +82,6 @@ local setwidth = nuts.setwidth local getheight = nuts.getheight local setattrlist = nuts.setattrlist - -local getbox = nuts.getbox local takebox = nuts.takebox local setprop = nuts.setprop @@ -105,6 +103,7 @@ local new_usernode = nodepool.usernode local latelua = nodepool.latelua local texgetdimen = tex.getdimen + local texgetcount = tex.getcount local texget = tex.get @@ -270,8 +269,8 @@ function margins.save(t) if t.number then local leftmargindistance = texgetdimen("naturalleftmargindistance") local rightmargindistance = texgetdimen("naturalrightmargindistance") - local strutbox = getbox("strutbox") - local _, strutht, strutdp = getwhd(strutbox) + local strutht = texgetdimen("strutht") + local strutdp = texgetdimen("strutdp") -- better make a new table and make t entry in t t.box = content t.n = nofsaved diff --git a/tex/context/base/mkxl/typo-mar.mkxl b/tex/context/base/mkxl/typo-mar.mkxl index 4862ee671..242797a5d 100644 --- a/tex/context/base/mkxl/typo-mar.mkxl +++ b/tex/context/base/mkxl/typo-mar.mkxl @@ -174,7 +174,7 @@ \docheckpagestate\s!margintext\nofmargintexts %\doifelserightpagestate\s!margintext\nofmargintexts\relax\relax \realpageno\realpagestateno - \page_layouts_swap_margins} + \page_layouts_swap_margins\v!margin} \permanent\protected\def\margindata {\iftrialtypesetting |