diff options
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r-- | tex/context/base/mkxl/buff-ini.lmt | 78 | ||||
-rw-r--r-- | tex/context/base/mkxl/buff-ini.mkxl | 34 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-new.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/context.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/driv-shp.lmt | 22 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-con.lmt | 36 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-imp-math.lmt | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-ini.mklx | 18 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-ots.lmt | 57 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-pre.mkxl | 3 | ||||
-rw-r--r-- | tex/context/base/mkxl/lpdf-lmt.lmt | 185 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-act.lmt | 79 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-aux.mkxl | 12 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-vis.lmt | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-adj.mkxl | 3 |
15 files changed, 397 insertions, 138 deletions
diff --git a/tex/context/base/mkxl/buff-ini.lmt b/tex/context/base/mkxl/buff-ini.lmt index 0b54f81ac..2cde7c72b 100644 --- a/tex/context/base/mkxl/buff-ini.lmt +++ b/tex/context/base/mkxl/buff-ini.lmt @@ -678,7 +678,7 @@ implement { if doundent or (autoundent and doundent == nil) then data = undent(data) end - buffers.assign(name,data,catcodes) + assign(name,data,catcodes) context[finish]() end } @@ -954,3 +954,79 @@ implement { actions = buffers.samplefile, arguments = "string" } + +-- A somewhat strange place (for now) so the *.log definitions might move someplace +-- else (if useful at all). + +-- Handy for the math test suite that Mikael Sundqvist and I are making where we +-- need to track box content as well as some low level math tracing features, so +-- we can pipe to buffers (via a temporary file). + +do + + local insert, remove = table.insert, table.remove + local setlogfile = texio.setlogfile + local openfile = io.open + + local stack = { } + local files = { } + + local function resetlogfile(name) + files[name] = false + end + + local function pushlogfile(name) + local f = openfile(name,files[name] and "ab" or "wb") + insert(stack,f) + files[name] = true + setlogfile(f) + end + + local function poplogfile() + remove(stack) + setlogfile(stack[#stack]) + end + + logs.pushlogfile = pushlogfile + logs.poplogfile = poplogfile + logs.resetlogfile = resetlogfile + + implement { + name = "resetlogfile", + arguments = "argument", + public = true, + protected = true, + actions = resetlogfile, + } + + implement { + name = "pushlogfile", + arguments = "argument", + public = true, + protected = true, + actions = pushlogfile, + } + + implement { + name = "poplogfile", + public = true, + protected = true, + actions = poplogfile, + } + + -- In the end we went for a somewhat hidden low level one (see low level math tests + -- for usage): + + local showbox = tex.showbox + + implement { + name = "showboxinbuffer", + public = true, + protected = true, + arguments = { "argument", "integer", "integer" }, + actions = function(buffer, box, detail) + assign(buffer or "",showbox(box, detail)) + end, + } + +end diff --git a/tex/context/base/mkxl/buff-ini.mkxl b/tex/context/base/mkxl/buff-ini.mkxl index ed16bd6e3..530058f46 100644 --- a/tex/context/base/mkxl/buff-ini.mkxl +++ b/tex/context/base/mkxl/buff-ini.mkxl @@ -283,4 +283,38 @@ \permanent\def\getbufferdata[#1]{\buff_get_stored_indeed{#1}} +% low level helper (for math manual): + +% \showboxinbuffer{temp}<boxnumber><detail> % defined in lua, detail cf \shownodedetails 0|1|2 + +%D \starttyping +%D \setbox\scratchbox\hbox{$fff$} +%D \showboxinbuffer{temp}\scratchbox\plusone +%D \typebuffer[temp][option=TEX] +%D \stoptyping +%D +%D More extensive multistep cases can do this: +%D +%D \starttyping +%D \pushlogfile{oeps-1.txt} +%D \setbox0\hbox{A}\showbox0 +%D \pushlogfile{oeps-2.txt} +%D \setbox0\hbox{B}\showbox0 +%D \poplogfile +%D \setbox0\hbox{C}\showbox0 +%D \poplogfile +%D +%D % \resetlogfile{oeps-1.txt} +%D \pushlogfile{oeps-1.txt} +%D \setbox0\hbox{A}\showbox0 +%D \pushlogfile{oeps-2.txt} +%D \setbox0\hbox{B}\showbox0 +%D \poplogfile +%D \setbox0\hbox{C}\showbox0 +%D \poplogfile +%D \stoptyping +%D +%D But in the end that was overkill and we don't really need a stepwise verbatim +%D because we need to add comments in between anyway. + \protect \endinput diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 9c3cde2c5..722ac0f09 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{2021.11.05 15:54} +\newcontextversion{2021.11.11 19:18} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index c009461ed..8d42981fc 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{2021.11.05 15:54} +\immutable\edef\contextversion{2021.11.11 19:18} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt index f24a4090f..ace259954 100644 --- a/tex/context/base/mkxl/driv-shp.lmt +++ b/tex/context/base/mkxl/driv-shp.lmt @@ -459,6 +459,8 @@ local flush_character do end end + -- hm, never seen outside here + pos_h = saved_h pos_v = saved_v pos_r = saved_r @@ -473,7 +475,7 @@ local flush_character do if font ~= lastfont then lastfont = font fontcharacters = characters[font] - updatefontstate(font) + updatefontstate(font) -- can move to lpdf-lmt, cleaner end local data = fontcharacters[char] @@ -517,6 +519,7 @@ local flush_character do sx = 1 sy = 1 end +-- print(width, height, depth, factor, sx, sy) if pos_r == righttoleft_code then pos_h = pos_h - width -- here ? end @@ -525,14 +528,14 @@ local flush_character do else -- kind of messy that we do orientation here and offsets elsewhere .. this might change local orientation = data.orientation -- 0 (none), 1, 2, 3 or 4 (none) - local x = data.xoffset - local y = data.yoffset - if x then - pos_h = pos_h + x * sx - end - if y then - pos_v = pos_v + y * sy - end +-- local x = data.xoffset +-- local y = data.yoffset +-- if x then +-- pos_h = pos_h + x * sx +-- end +-- if y then +-- pos_v = pos_v + y * sy +-- end if orientation and (orientation == 1 or orientation == 3) then -- we can get weird charactersbox tracing here pushorientation(orientation,pos_h,pos_v) @@ -541,6 +544,7 @@ local flush_character do else flushcharacter(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor,sx,sy) -- ,naturalwidth,width) end + -- we use the real width so we have to go back again end return width, height, depth end diff --git a/tex/context/base/mkxl/font-con.lmt b/tex/context/base/mkxl/font-con.lmt index cee94f6d2..d1a15e92c 100644 --- a/tex/context/base/mkxl/font-con.lmt +++ b/tex/context/base/mkxl/font-con.lmt @@ -486,12 +486,14 @@ function constructors.scale(tfmdata,specification) if hasmath then constructors.assignmathparameters(target,tfmdata) -- does scaling and whatever is needed - properties.hasmath = true - target.nomath = false + properties.hasmath = true -- to be sure + target.nomath = false -- hm target.MathConstants = target.mathparameters - properties.compactmath = true - target.compactmath = true + local compactmath = properties.compactmath + + targetproperties.compactmath = compactmath + target.compactmath = compactmath local textscale = parameters.textscale -- or 1000 local scriptscale = parameters.scriptscale -- or 700 @@ -744,6 +746,10 @@ function constructors.scale(tfmdata,specification) if ft then chr.options = ft end + local sm = character.smaller + if sm then + chr.smaller = sm + end elseif autoitalicamount then -- itlc feature local vi = description.italic if not vi then @@ -795,14 +801,20 @@ function constructors.scale(tfmdata,specification) if vc then chr.commands = scalecommands(vc,hdelta,vdelta) end - local vx = characters.xoffset - if vx then - chr.vx = vx*hdelta - end - local vy = characters.yoffset - if vy then - chr.vy = vy*hdelta - end + -- we assume that these are done in a manipulator afterwards + -- as it makes no sense otherwise + -- local vx = character.xoffset + -- if vx then + -- chr.xoffset = vx*hdelta + -- end + -- local vy = character.yoffset + -- if vy then + -- chr.yoffset = vy*vdelta + -- end + -- local va = character.advance + -- if va then + -- chr.advance = va*vdelta + -- end targetcharacters[unicode] = chr end -- diff --git a/tex/context/base/mkxl/font-imp-math.lmt b/tex/context/base/mkxl/font-imp-math.lmt index 677bff91a..68dddf33d 100644 --- a/tex/context/base/mkxl/font-imp-math.lmt +++ b/tex/context/base/mkxl/font-imp-math.lmt @@ -161,9 +161,11 @@ local function initialize(tfmdata,value) local mathconstants = rawresources.mathconstants if mathconstants then local parameters = tfmdata.parameters + local properties = tfmdata.properties parameters.textscale = 1000 parameters.scriptscale = mathconstants.ScriptPercentScaleDown * 10 parameters.scriptscriptscale = mathconstants.ScriptScriptPercentScaleDown * 10 + properties.compactmath = true end end end diff --git a/tex/context/base/mkxl/font-ini.mklx b/tex/context/base/mkxl/font-ini.mklx index b43f43dfb..85e253e17 100644 --- a/tex/context/base/mkxl/font-ini.mklx +++ b/tex/context/base/mkxl/font-ini.mklx @@ -777,24 +777,6 @@ \fi \font_helpers_update_font_parameters \font_helpers_update_font_class_parameters - %\writestatus{fonts}{low level define: #csname/\somefontfile/\number\d_font_scaled_font_size/\fontface/\number\d_font_scaled_text_face}% -% \clf_definefont_two -% \ifempty\fontclass\s!false\else\s!true\fi -% {#csname}% -% {\somefontfile}% -% \d_font_scaled_font_size -% \c_font_feature_inheritance_mode -% {\m_font_class_features}% -% {\m_font_features}% -% {\m_font_class_fallbacks}% -% {\m_font_fallbacks}% -% \fontface -% \d_font_scaled_text_face -% {\m_font_class_goodies}% -% {\m_font_goodies}% -% {\m_font_class_designsize}% -% {\m_font_designsize}% -% \scaledfontmode \clf_definefont_two \ifempty\fontclass\s!false\else\s!true\fi {#csname}% diff --git a/tex/context/base/mkxl/font-ots.lmt b/tex/context/base/mkxl/font-ots.lmt index 4d4c09495..eda63cee5 100644 --- a/tex/context/base/mkxl/font-ots.lmt +++ b/tex/context/base/mkxl/font-ots.lmt @@ -2055,19 +2055,23 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck) local chainlookup = chainlookups[1] for j=1,#chainlookup do local chainstep = chainlookup[j] - local chainkind = chainstep.type - local chainproc = chainprocs[chainkind] - if chainproc then - local ok - -- HH: chainindex 1 added here (for KAI to check too), there are weird ligatures e.g. - -- char + mark -> char where mark has to disappear - -- head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash,1) - head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash) - if ok then - done = true + if chainstep then + local chainkind = chainstep.type + local chainproc = chainprocs[chainkind] + if chainproc then + local ok + -- HH: chainindex 1 added here (for KAI to check too), there are weird ligatures e.g. + -- char + mark -> char where mark has to disappear + -- head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash,1) + head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash) + if ok then + done = true + end + else + logprocess("%s: %s is not yet supported (1)",cref(dataset,sequence),chainkind) end else - logprocess("%s: %s is not yet supported (1)",cref(dataset,sequence),chainkind) + logprocess("%s: has an issue (1)",cref(dataset,sequence)) end end @@ -2109,23 +2113,28 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck) if chainlookup then for j=1,#chainlookup do local chainstep = chainlookup[j] - local chainkind = chainstep.type - local chainproc = chainprocs[chainkind] - if chainproc then - local ok, n - head, start, ok, n = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash,i) - -- messy since last can be changed ! - if ok then - done = true - if n and n > 1 and i + n > nofchainlookups then - -- this is a safeguard, we just ignore the rest of the lookups - i = size -- prevents an advance - break + if chainstep then + local chainkind = chainstep.type + local chainproc = chainprocs[chainkind] + if chainproc then + local ok, n + head, start, ok, n = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash,i) + -- messy since last can be changed ! + if ok then + done = true + if n and n > 1 and i + n > nofchainlookups then + -- this is a safeguard, we just ignore the rest of the lookups + i = size -- prevents an advance + break + end end + else + -- actually an error + logprocess("%s: %s is not yet supported (2)",cref(dataset,sequence),chainkind) end else -- actually an error - logprocess("%s: %s is not yet supported (2)",cref(dataset,sequence),chainkind) + logprocess("%s: has an issue (2)",cref(dataset,sequence)) end end else diff --git a/tex/context/base/mkxl/font-pre.mkxl b/tex/context/base/mkxl/font-pre.mkxl index 27b1f6fdf..ffad757a9 100644 --- a/tex/context/base/mkxl/font-pre.mkxl +++ b/tex/context/base/mkxl/font-pre.mkxl @@ -419,9 +419,6 @@ \mathnolimitsmode\plusone % font driven (only opentype) \fi -\mathitalicsmode\plusone % 1 : add to simple noad -%mathitalicsmode\plusthree % 2 : add italic kerns for diagnostics - % \adaptfontfeature[*math*][mathnolimitsmode=1000] % only subscript \definefontfeature diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 81df491c2..463cc8352 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -117,7 +117,7 @@ local flushers = { } -- used variables local pdf_h, pdf_v -local need_tm, need_tf, cur_tmrx, cur_factor, cur_f, cur_e +local need_tm, need_tf, need_font, cur_tmrx, cur_factor, cur_f, cur_e local need_width, need_mode, done_width, done_mode local mode local f_pdf_cur, f_pdf, fs_cur, fs, f_cur, f_x_scale, f_y_scale @@ -147,6 +147,7 @@ local function reset_variables(specification) tmef = 1.0 need_tm = false need_tf = false + need_font = true need_width = 0 need_mode = 0 done_width = false @@ -272,6 +273,7 @@ local function begin_text() saved_text_pos_v = pdf_v b = b + 1 ; buffer[b] = "BT" need_tf = true + need_font = true need_width = 0 need_mode = 0 mode = "text" @@ -458,9 +460,10 @@ do -- as fontparameters already has checked / set it we can also have a variable -- for it so - local naturalwidth = nil - local hshift = false - local vshift = false + local characterwidth = nil + -- local descriptionwidth = nil + local hshift = false + local vshift = false -- The width array uses the original dimensions! This is different from e.g. -- luatex where we have more widths arrays and these reflect the cheated @@ -468,55 +471,27 @@ do -- when changing this, check math: compact-001.tex (rule width) --- local naturalwidths = setmetatableindex(function(t,font) --- local d = descriptions[font] --- local c = characters[font] --- local f = parameters[font].hfactor or parameters[font].factor --- local v = setmetatableindex(function(t,char) --- local w --- local e = c and c[char] --- if e then --- w = e.width or 0 --- end --- if not w then --- e = d and d[char] --- if e then --- w = e.width --- if w then --- w = w * f --- end --- end --- end --- if not w then --- w = 0 --- end --- t[char] = w --- return w --- end) --- t[font] = v --- return v --- end) - - -- we need to use descriptions ... otherwise we get wrong dimensions when we use - -- characters[n].xoffset or virtual stuff - - local naturalwidths = setmetatableindex(function(t,font) + local characterwidths = setmetatableindex(function(t,font) local d = descriptions[font] local c = characters[font] local f = parameters[font].hfactor or parameters[font].factor local v = setmetatableindex(function(t,char) local w - local e = d and d[char] + local e = c and c[char] if e then - w = e.width - if w then - w = w * f + w = e.width or 0 + local a = e.advance + if a then + w = a end end if not w then - e = c and c[char] + e = d and d[char] if e then - w = e.width or 0 + w = e.width + if w then + w = w * f + end end end if not w then @@ -529,7 +504,50 @@ do return v end) - local function setup_fontparameters(font,factor,f,e,sx,sy) + -- we need to use descriptions ... otherwise we get wrong dimensions when we use + -- characters[n].xoffset or virtual stuff + + -- local descriptionwidths = setmetatableindex(function(t,font) + -- local d = descriptions[font] + -- local c = characters[font] + -- local f = parameters[font].hfactor or parameters[font].factor + -- local v = setmetatableindex(function(t,char) + -- local w + -- local e = d and d[char] + -- if e then + -- w = e.width + -- if w then + -- w = w * f + -- end + -- end + -- if not w then + -- e = c and c[char] + -- if e then + -- w = e.width or 0 + -- end + -- end + -- if not w then + -- w = 0 + -- end + -- t[char] = w + -- return w + -- end) + -- t[font] = v + -- return v + -- end) + + -- it's about time to get rid of the pdftex based model but i'll wait with that till after + -- the first release so that we have some test period ... when we go compact even less + + -- the descriptions are used for the width array + + local collapse = true + + experiments.register("backend.pdf.collapsefonts",function(v) + collapse = v + end) + + local function setup_fontparameters(where,font,factor,f,e,sx,sy) local slant = fontparameters.slantfactor or 0 local extend = fontparameters.extendfactor or 1 local squeeze = fontparameters.squeezefactor or 1 @@ -551,15 +569,30 @@ do cur_e = e tj_delta = 0 cw = 0 - f_x_scale = 1.0 - f_y_scale = 1.0 - fs = fontparameters.size * bpfactor - if f then - fs = fs * f - end - -- kind of special: - if format == "opentype" or format == "type1" then - fs = fs * 1000 / fontparameters.units -- can we avoid this ? + -- + fs = fontparameters.size * bpfactor + if collapse then + local sc = fs / 10 + if f then + sc = sc * f + end + -- kind of special: + if format == "opentype" or format == "type1" then + sc = sc * 1000 / fontparameters.units -- can we avoid this ? + end + -- + fs = 10 + -- + tmrx = tmrx * sc + tmry = tmry * sc + else + if f then + fs = fs * f + end + -- kind of special: + if format == "opentype" or format == "type1" then + fs = fs * 1000 / fontparameters.units -- can we avoid this ? + end end -- f_x_scale = sx @@ -571,7 +604,8 @@ do tmry = tmry * f_y_scale end -- - naturalwidth = naturalwidths[font] + characterwidth = characterwidths[font] + -- descriptionwidth = descriptionwidths[font] -- hshift = fontparameters.hshift vshift = fontparameters.vshift @@ -586,6 +620,9 @@ do local width_factor = 72.27 / 72000.0 + local last_fs + local last_fpdf + local function set_font() -- if need_width and need_width ~= 0 then if need_width ~= 0 then @@ -603,7 +640,13 @@ do b = b + 1 ; buffer[b] = s_mode done_mode = false end - b = b + 1 ; buffer[b] = f_font(f_pdf,fs) + -- no need when the same + if need_font or last_fs ~= fs or last_pdf ~= f_pdf then + b = b + 1 ; buffer[b] = f_font(f_pdf,fs) + last_fs = fs + last_pdf = f_pdf + need_font = false + end f_pdf_cur = f_pdf fs_cur = fs need_tf = false @@ -653,24 +696,42 @@ do flushers.character = function(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor,sx,sy) -- ,naturalwidth,width) if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur or mode == "page" then +-- if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur then +-- print("f",1) pdf_goto_textmode() - setup_fontparameters(font,factor,f,e,sx,sy) + setup_fontparameters(1,font,factor,f,e,sx,sy) -- too often due to page + set_font() +-- elseif mode == "page" then +-- print("f",4) +-- pdf_goto_textmode() set_font() elseif cur_f ~= f then -- when ok move up (maybe no longer needed) +-- print("f",2) pdf_goto_textmode() - setup_fontparameters(font,factor,f,e,sx,sy) + setup_fontparameters(2,font,factor,f,e,sx,sy) set_font() -- elseif cur_tmrx ~= tmrx or cur_factor ~= factor or cur_f ~= f or cur_e ~= e then elseif cur_tmrx ~= tmrx or cur_factor ~= factor or cur_e ~= e then - setup_fontparameters(font,factor,f,e,sx,sy) +-- print("f",3) + setup_fontparameters(3,font,factor,f,e,sx,sy) need_tm = true end + + local x = data.xoffset + local y = data.yoffset + if x then + pos_h = pos_h + x * tmef * f_x_scale + end + if y then + pos_v = pos_v + y * f_y_scale + end + local move = calc_pdfpos(pos_h,pos_v) if trace_threshold then report_fonts( "before: font %i, char %C, factor %i, naturalwidth %p, move %l, tm %l, hpos %p, delta %p, threshold %p, cw %p", - font,char,factor,naturalwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw + font,char,factor,characterwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw ) end @@ -693,7 +754,6 @@ do if hshift then pos_h = pos_h + hshift end if vshift then pos_v = pos_v - vshift end - if need_tm then pdf_goto_textmode() set_textmatrix(pos_h,pos_v) @@ -715,14 +775,15 @@ do if trace_threshold then report_fonts( "after : font %i, char %C, factor %i, naturalwidth %p, move %l, tm %l, hpos %p, delta %p, threshold %p, cw %p", - font,char,factor,naturalwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw + font,char,factor,characterwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw ) end if mode == "chararray" then begin_charmode() end - cw = cw + naturalwidth[char] * tmef * f_x_scale + + cw = cw + characterwidth[char] * tmef * f_x_scale local slot = pdfcharacters[data.index or char] -- registers usage diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt index 3df8c1700..56730f2eb 100644 --- a/tex/context/base/mkxl/math-act.lmt +++ b/tex/context/base/mkxl/math-act.lmt @@ -181,6 +181,69 @@ function mathematics.overloadparameters(target,original) end end +-- a couple of predefined tweaks: + +local mathtweaks = { } +mathematics.tweaks = mathtweaks + +local function adapt(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 + end + local smaller = originalcharacters[k].smaller + if compact and smaller and smaller ~= k then + adapt(targetcharacters,originalcharacters,smaller,v,compact,n+1) + end + else + report_math("no character %U",k) + end +end + +function mathtweaks.dimensions(target,original,list) + local targetcharacters = target.characters + local originalcharacters = original.characters + local compact = target.parameters.textscale and true or false + for k, v in next, list do + adapt(targetcharacters,originalcharacters,k,v,compact,1) + end +end + +function mathtweaks.action(target,original,action,...) + if type(action) == "function" then + action(target,original,...) + end +end + + +local reported = { } + +function mathtweaks.version(target,original,expected) + local metadata = original.shared.rawdata.metadata + if metadata then + local version = metadata.version + if version then + local fontname = metadata.fontname + -- version = tonumber(string.match(version,"%d+.%d+")) + if not reported[fontname] and version ~= expected then + report_math("tweaking %a, version %a found, version %a expected",fontname,version,expected) + reported[fontname] = true + end + end + end +end + local function applytweaks(when,target,original) local goodies = original.goodies if goodies then @@ -195,10 +258,19 @@ local function applytweaks(when,target,original) 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 tweak = tweaks[i] local tvalue = type(tweak) if tvalue == "function" then + -- old tweak(target,original) + elseif tvalue == "table" then + local command = tweak[1] + if type(command) == "string" then + local action = mathtweaks[command] + if action then + action(target,original,table.unpack(tweak,2)) + end + end end end end @@ -233,11 +305,6 @@ sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweakaft -- -- sequencers.appendaction("aftercopyingcharacters", "system","mathematics.overloaddimensions") --- a couple of predefined tweaks: - -local tweaks = { } -mathematics.tweaks = tweaks - -- helpers local setmetatableindex = table.setmetatableindex diff --git a/tex/context/base/mkxl/syst-aux.mkxl b/tex/context/base/mkxl/syst-aux.mkxl index 278926582..2f7acdca0 100644 --- a/tex/context/base/mkxl/syst-aux.mkxl +++ b/tex/context/base/mkxl/syst-aux.mkxl @@ -1788,6 +1788,18 @@ \permanent\protected\def\getcommacommandsize[#1]% {\normalexpanded{\getcommalistsize[#1]}} +\permanent\def\getcommalistcount[#1]% + {\beginlocalcontrol + \getcommalistsize[#1]% + \endlocalcontrol + \the\commalistcounter} + +\permanent\def\getcommacommandcount[#1]% + {\beginlocalcontrol + \getcommacommandsize[#1]% + \endlocalcontrol + \the\commalistcounter} + %D Filters: % \def\syst_helpers_gobble_comma_list#0\ignorearguments{} diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index 6f59d0e7f..aa599485c 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -1566,7 +1566,7 @@ do if trace_mathkern then head, current = mathkern(head,current) elseif trace_kern then - head, current = ruledmarginkern(head,current,subtype) + head, current = ruledmathkern(head,current,subtype) end else if trace_kern then diff --git a/tex/context/base/mkxl/typo-adj.mkxl b/tex/context/base/mkxl/typo-adj.mkxl index 9a85b3009..5c129f07e 100644 --- a/tex/context/base/mkxl/typo-adj.mkxl +++ b/tex/context/base/mkxl/typo-adj.mkxl @@ -21,6 +21,9 @@ % \definesystemattribute[adjuster][public] +% Musical timestamp: the announcement of the new Porcupine Tree album: Closure / +% Continuation and the related upcoming tour. They're back! + \unprotect %D \starttyping |