diff options
Diffstat (limited to 'tex')
29 files changed, 496 insertions, 201 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 86bc7834d..c52d4b787 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@  %C therefore copyrighted by \PRAGMA. See mreadme.pdf for  %C details. -\newcontextversion{2021.11.05 15:54} +\newcontextversion{2021.11.11 19:18}  %D This file is loaded at runtime, thereby providing an  %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 78d89a9a5..ea17f2dc5 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@  %D your styles an modules.  \edef\contextformat {\jobname} -\edef\contextversion{2021.11.05 15:54} +\edef\contextversion{2021.11.11 19:18}  %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii index 25a2968fc..25ba4962e 100644 --- a/tex/context/base/mkii/mult-it.mkii +++ b/tex/context/base/mkii/mult-it.mkii @@ -315,6 +315,7 @@  \setinterfacevariable{lefthanging}{lefthanging}  \setinterfacevariable{leftmargin}{marginesinistro}  \setinterfacevariable{leftpage}{paginasinistra} +\setinterfacevariable{lefttext}{testosinistro}  \setinterfacevariable{lefttoright}{lefttoright}  \setinterfacevariable{legend}{legenda}  \setinterfacevariable{less}{less} @@ -476,6 +477,7 @@  \setinterfacevariable{righthanging}{righthanging}  \setinterfacevariable{rightmargin}{marginedestro}  \setinterfacevariable{rightpage}{paginadestra} +\setinterfacevariable{righttext}{testodestro}  \setinterfacevariable{righttoleft}{righttoleft}  \setinterfacevariable{roman}{roman}  \setinterfacevariable{romannumerals}{numeriromani} diff --git a/tex/context/base/mkiv/buff-ini.lua b/tex/context/base/mkiv/buff-ini.lua index 6c844342a..9af76f72e 100644 --- a/tex/context/base/mkiv/buff-ini.lua +++ b/tex/context/base/mkiv/buff-ini.lua @@ -688,7 +688,7 @@ local runner = sandbox.registerrunner {      name     = "run buffer",      program  = "context",      method   = "execute", -    template = (jit and "--jit " or "") .. "--purgeall %?path: --path=%path% ?% %filename%", +    template = (jit and "--jit --engine=luajittex" or "--engine=luatex") .. " --purgeall %?path: --path=%path% ?% %filename%",      reporter = report_typeset,      checkers = {          filename = "readable", diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 3c7eca483..ce96e7c81 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@  % \normalend % uncomment this to get the real base runtime -\newcontextversion{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/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 3b3d9368f..c2178e2b1 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@  %D {YYYY.MM.DD HH:MM} format.  \edef\contextformat {\jobname} -\edef\contextversion{2021.11.05 15:54} +\edef\contextversion{2021.11.11 19:18}  %D Kind of special: diff --git a/tex/context/base/mkiv/font-oup.lua b/tex/context/base/mkiv/font-oup.lua index 4c3d562c2..3bd2fe482 100644 --- a/tex/context/base/mkiv/font-oup.lua +++ b/tex/context/base/mkiv/font-oup.lua @@ -3027,7 +3027,7 @@ function readers.expand(data)      -- about 15% on arabtype .. then moving the a test also saves a bit (even when      -- often a is not set at all so that one is a bit debatable -    local function expandlookups(sequences) +    local function expandlookups(sequences,whatever)          if sequences then              -- we also need to do sublookups              for i=1,#sequences do @@ -3103,6 +3103,9 @@ function readers.expand(data)                                          if lookups then                                              for k, v in next, lookups do -- actually this one is indexed                                                  local lookup = sublookups[v] +if not lookup and whatever then +    lookup = whatever[v] +end                                                  if lookup then                                                      lookups[k] = lookup                                                      if not subtype then @@ -3183,5 +3186,5 @@ function readers.expand(data)      end      expandlookups(sequences) -    expandlookups(sublookups) +    expandlookups(sublookups,sequences)  end diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index 125434d9a..307cf3c68 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -103,9 +103,9 @@ return {          --          "overrulemathcontrolcode", "underrulemathcontrolcode", "radicalrulemathcontrolcode",  "fractionrulemathcontrolcode",          "accentskewhalfmathcontrolcode", "accentskewapplymathcontrolcode", "accentitalickernmathcontrolcode", -        "delimiteritalickernmathcontrolcode", "orditalickernmathcontrolcode", "charitalicwidthmathcontrolcode", +        "delimiteritalickernmathcontrolcode", "noorditalickernmathcontrolcode", "charitalicwidthmathcontrolcode",          "charitalicnoreboxmathcontrolcode", "boxednoitalickernmathcontrolcode", "nostaircasekernmathcontrolcode", -        "textitalickernmathcontrolcode", +        "textitalickernmathcontrolcode", "noscriptitalickernmathcontrolcode",          --          "noligaturingglyphoptioncode", "nokerningglyphoptioncode", "noexpansionglyphoptioncode", "noprotrusionglyphoptioncode",          "noleftkerningglyphoptioncode", "noleftligaturingglyphoptioncode", "norightkerningglyphoptioncode", "norightligaturingglyphoptioncode", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 6bab9c707..28cb886a3 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 64c280124..19c31285c 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf 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 diff --git a/tex/context/fonts/mkiv/ebgaramond.lfg b/tex/context/fonts/mkiv/ebgaramond.lfg index 73f3e6b70..862e4e85d 100644 --- a/tex/context/fonts/mkiv/ebgaramond.lfg +++ b/tex/context/fonts/mkiv/ebgaramond.lfg @@ -1,35 +1,35 @@  return { -    name = "eb garamond", +    name = "ebgaramond",      version = "1.00", -    comment = "Goodies that complement eb garamond.", +    comment = "Goodies that complement ebgaramond.",      author = "Hans Hagen",      copyright = "ConTeXt development team",      mathematics = { -        tweaks = { -            aftercopying = { -                function(target,original,...) -                    local crap = { -                        [0x1D453] = { .20, 1.20 }, -                        [0x1D454] = { .15, 1.15 }, -                    } -                    local characters = target.characters -                    local function adapt(k,v) -                        local character = characters[k] -                        local width     = character.width -                        character.width = v[2]*width -                     -- character.commands = { { "offset", v[1]*width, 0, k } } -                        character.xoffset = v[1]*width -                        local smaller = original.characters[k].smaller -                        if smaller and smaller ~= k then -                            adapt(smaller,v) -                        end -                    end -                    for k, v in next, crap do -                        adapt(k,v) -                    end -                end, -            }, -        }, +--         tweaks = { +--             aftercopying = { +--                 function(target,original,...) +--                     local crap = { +--                         [0x1D453] = { .20, 1.20 }, +--                         [0x1D454] = { .15, 1.15 }, +--                     } +--                     local characters = target.characters +--                     local function adapt(k,v) +--                         local character = characters[k] +--                         local width     = character.width +--                         character.width = v[2]*width +--                      -- character.commands = { { "offset", v[1]*width, 0, k } } +--                         character.xoffset = v[1]*width +--                         local smaller = original.characters[k].smaller +--                         if smaller and smaller ~= k then +--                             adapt(smaller,v) +--                         end +--                     end +--                     for k, v in next, crap do +--                         adapt(k,v) +--                     end +--                 end, +--             }, +--         },          alternates = {              partial        = { feature = 'ss02', value = 1, comment = "Curved partial" }, diff --git a/tex/context/fonts/mkiv/pagella-math.lfg b/tex/context/fonts/mkiv/pagella-math.lfg index 262196f70..e2ed0eb43 100644 --- a/tex/context/fonts/mkiv/pagella-math.lfg +++ b/tex/context/fonts/mkiv/pagella-math.lfg @@ -1,9 +1,7 @@ -local kern_V   = { bottomright = { { kern = -200 } } } -local kern_W   = { bottomright = { { kern = -100 } } } ------ kern_f   = { bottomright = { { kern = -100 } } } --- local offset_f = { xoffset = "llx" } - --- Beware of updates in ssty slots! +local dimensions = { +    [0x1D453] = { .40, 1.60, .5 }, -- offset width italic +--     [0x1D453] = { .0, 2, 0 }, -- offset width italic +}  return {      name = "pagella-math", @@ -12,28 +10,56 @@ return {      author = "Hans Hagen",      copyright = "ConTeXt development team",      mathematics = { -        dimensions = { -            default = { -             -- [0x1D453]     = { xoffset = 162, width = 278 + 162 },-- 𝑓 -             -- [0x1D453]     = offset_f, -- 𝑓 -             -- ["1:0x1D453"] = offset_f, -- needed for compact -             -- ["2:0x1D453"] = offset_f, -- needed for compact ---                 ["*:0x1D453"] = offset_f, -- 𝑓 +        tweaks = { +            aftercopying = { +                { "version",    "Version 1.632" }, +             -- { "action",     function(target,original) mathematics.tweaks.fixdimensions(target, original, fixes) }, +             -- { "action",     mathematics.tweaks.fixdimensions, fixes }, +                { "dimensions", dimensions },              },          }, -        kerns = { -         -- [0x1D449]     = kern_V, -- 𝑉 -         -- ["1:0x1D449"] = kern_V, -- needed for compact -         -- ["2:0x1D449"] = kern_V, -- needed for compact -         -- [0x1D44A]     = kern_W, -- 𝑊 -         -- ["1:0x1D44A"] = kern_W, -- needed for compact -         -- ["2:0x1D44A"] = kern_W, -- needed for compact ---             ["*:0x1D453"] = kern_f, -            ["*:0x1D449"] = kern_V, -- 𝑉 -            ["*:0x1D44A"] = kern_W, -- 𝑊 -        },          alternates = {              dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" },          },      },  } + +-- local kern_V   = { bottomright = { { kern = -200 } } } +-- local kern_W   = { bottomright = { { kern = -100 } } } +-- ----- kern_f   = { bottomright = { { kern = -100 } } } +-- -- local offset_f = { xoffset = "llx" } +-- +-- -- Beware of updates in ssty slots! +-- +-- return { +--     name = "pagella-math", +--     version = "1.00", +--     comment = "Goodies that complement pagella.", +--     author = "Hans Hagen", +--     copyright = "ConTeXt development team", +--     mathematics = { +--         dimensions = { +--             default = { +--              -- [0x1D453]     = { xoffset = 162, width = 278 + 162 },-- 𝑓 +--              -- [0x1D453]     = offset_f, -- 𝑓 +--              -- ["1:0x1D453"] = offset_f, -- needed for compact +--              -- ["2:0x1D453"] = offset_f, -- needed for compact +-- --                 ["*:0x1D453"] = offset_f, -- 𝑓 +--             }, +--         }, +--         kerns = { +--          -- [0x1D449]     = kern_V, -- 𝑉 +--          -- ["1:0x1D449"] = kern_V, -- needed for compact +--          -- ["2:0x1D449"] = kern_V, -- needed for compact +--          -- [0x1D44A]     = kern_W, -- 𝑊 +--          -- ["1:0x1D44A"] = kern_W, -- needed for compact +--          -- ["2:0x1D44A"] = kern_W, -- needed for compact +-- --             ["*:0x1D453"] = kern_f, +--             ["*:0x1D449"] = kern_V, -- 𝑉 +--             ["*:0x1D44A"] = kern_W, -- 𝑊 +--         }, +--         alternates = { +--             dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, +--         }, +--     }, +-- } diff --git a/tex/context/interface/mkii/keys-it.xml b/tex/context/interface/mkii/keys-it.xml index 1cd5a3dcf..041a4265a 100644 --- a/tex/context/interface/mkii/keys-it.xml +++ b/tex/context/interface/mkii/keys-it.xml @@ -318,6 +318,7 @@  		<cd:variable name='lefthanging' value='lefthanging'/>  		<cd:variable name='leftmargin' value='marginesinistro'/>  		<cd:variable name='leftpage' value='paginasinistra'/> +		<cd:variable name='lefttext' value='testosinistro'/>  		<cd:variable name='lefttoright' value='lefttoright'/>  		<cd:variable name='legend' value='legenda'/>  		<cd:variable name='less' value='less'/> @@ -479,6 +480,7 @@  		<cd:variable name='righthanging' value='righthanging'/>  		<cd:variable name='rightmargin' value='marginedestro'/>  		<cd:variable name='rightpage' value='paginadestra'/> +		<cd:variable name='righttext' value='testodestro'/>  		<cd:variable name='righttoleft' value='righttoleft'/>  		<cd:variable name='roman' value='roman'/>  		<cd:variable name='romannumerals' value='numeriromani'/> diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 61089b31d..2a8f5349f 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@  -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua  -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date  : 2021-11-05 15:54 +-- merge date  : 2021-11-11 19:18  do -- begin closure to overcome local limits and interference @@ -26465,7 +26465,7 @@ function readers.expand(data)     end    end   end - local function expandlookups(sequences) + local function expandlookups(sequences,whatever)    if sequences then     for i=1,#sequences do      local sequence=sequences[i] @@ -26538,6 +26538,9 @@ function readers.expand(data)            if lookups then             for k,v in next,lookups do               local lookup=sublookups[v] +if not lookup and whatever then + lookup=whatever[v] +end              if lookup then               lookups[k]=lookup               if not subtype then @@ -26596,7 +26599,7 @@ function readers.expand(data)    end   end   expandlookups(sequences) - expandlookups(sublookups) + expandlookups(sublookups,sequences)  end  end -- closure  | 
