diff options
Diffstat (limited to 'tex')
49 files changed, 311 insertions, 177 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index b632a2017..9c85b9f26 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{2019.12.17 16:16} +\newcontextversion{2019.12.24 19:44}  %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 fcc668f18..b971a9461 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{2019.12.17 16:16} +\edef\contextversion{2019.12.24 19:44}  %D For those who want to use this: diff --git a/tex/context/base/mkiv/anch-pos.lua b/tex/context/base/mkiv/anch-pos.lua index f1ec59d8b..2788c9d1a 100644 --- a/tex/context/base/mkiv/anch-pos.lua +++ b/tex/context/base/mkiv/anch-pos.lua @@ -24,10 +24,9 @@ more efficient.</p>  -- we need virtual table accessors as well as have tag/id accessors ... we don't  -- save much here (at least not now) -local tostring, next, rawget, rawset, setmetatable, tonumber = tostring, next, rawget, rawset, setmetatable, tonumber +local tostring, next, setmetatable, tonumber = tostring, next, setmetatable, tonumber  local sort = table.sort  local format, gmatch = string.format, string.gmatch -local rawget = rawget  local lpegmatch = lpeg.match  local insert, remove = table.insert, table.remove  local allocate = utilities.storage.allocate diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index a54f4dc49..ac206ab26 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{2019.12.17 16:16} +\newcontextversion{2019.12.24 19:44}  %D This file is loaded at runtime, thereby providing an excellent place for  %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index a2a62cc8a..49337bfee 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@  %D {YYYY.MM.DD HH:MM} format.  \edef\contextformat {\jobname} -\edef\contextversion{2019.12.17 16:16} +\edef\contextversion{2019.12.24 19:44}  \edef\contextkind   {beta}  %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index 6f7388f59..331dfdfab 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@  %D {YYYY.MM.DD HH:MM} format.  \edef\contextformat {\jobname} -\edef\contextversion{2019.12.17 16:16} +\edef\contextversion{2019.12.24 19:44}  \edef\contextkind   {beta}  %D Kind of special: diff --git a/tex/context/base/mkiv/driv-shp.lua b/tex/context/base/mkiv/driv-shp.lua index 7340fe523..cc8b6bdbe 100644 --- a/tex/context/base/mkiv/driv-shp.lua +++ b/tex/context/base/mkiv/driv-shp.lua @@ -543,7 +543,6 @@ local hlist_out, vlist_out  do          local ref_v = pos_v          local ref_r = pos_r                pos_r = getdirection(this_box) -          local boxwidth,                boxheight,                boxdepth   = getwhd(this_box) @@ -774,7 +773,7 @@ local hlist_out, vlist_out  do                      end                      local total = height + depth                      if total > 0 then -                        local xoffset, yoffset, left, right = getoffsets(current) +                        local xoffset, yoffset, left, right = getoffsets(current) -- top bottom                          if left ~= 0 then                              pos_v  = pos_v + left                              total  = total - left @@ -842,6 +841,7 @@ local hlist_out, vlist_out  do                      cur_h = 0                      cur_v = 0                      pos_r = dir +                    goto synced                  end              elseif id == whatsit_code then                  if subtype == literalwhatsit_code then @@ -866,11 +866,11 @@ local hlist_out, vlist_out  do                  end              elseif id == marginkern_code then                  cur_h = cur_h + getkern(current) ---             elseif id == localpar_code and start_of_par(current) then ---                 local pardir = getdirection(current) or lefttoright_code ---                 if pardir == righttoleft_code then ---                 end ---             end +         -- elseif id == localpar_code and start_of_par(current) then +         --     local pardir = getdirection(current) or lefttoright_code +         --     if pardir == righttoleft_code then +         --     end +         -- end              end              -- There is no gain in skipping over this when we have zero progression              -- and such. @@ -880,7 +880,7 @@ local hlist_out, vlist_out  do                  pos_h = ref_h + cur_h              end              pos_v = ref_v - cur_v -            -- synced +            ::synced::          end          pos_h = ref_h          pos_v = ref_v @@ -1083,14 +1083,13 @@ local hlist_out, vlist_out  do                          local xoffset, yoffset, left, right = getoffsets(current)                          if left ~= 0 then                              width = width - left -                            cur_h = cur_h + left +                            xoffset = left                          end                          if right ~= 0 then                              width = width - right                          end                          if pos_r == righttoleft_code then -                            cur_h   = cur_h - width -                            xoffset = - xoffset +                            xoffset = - xoffset - width                          end                          flushrule(current,pos_h + xoffset,pos_v - total - yoffset,pos_r,width,total,subtype)                      end @@ -1124,7 +1123,7 @@ local hlist_out, vlist_out  do                  pos_h = ref_h + cur_h              end              pos_v = ref_v - cur_v -            -- synced +            ::synced::          end          pos_h = ref_h          pos_v = ref_v diff --git a/tex/context/base/mkiv/font-cff.lua b/tex/context/base/mkiv/font-cff.lua index 77b1c1888..5f79ba7a3 100644 --- a/tex/context/base/mkiv/font-cff.lua +++ b/tex/context/base/mkiv/font-cff.lua @@ -1351,6 +1351,8 @@ do      -- These are probably used for special cases i.e. call out to the      -- postscript interpreter (p 61 of the spec as well as chapter 8). +    -- +    -- This needs checking (I have to ask Taco next time we meet.)      local popped = 3      local hints  = 3 @@ -1367,7 +1369,15 @@ do              else                  popped = 3              end -            top = top - (stack[top-1] + 2) +            local t = stack[top-1] +            if t then +                top = top - (t + 2) +                if top < 0 then +                    top = 0 +                end +            else +                top = 0 +            end          else              top = 0          end diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua index 535b46610..cbb81cdb7 100644 --- a/tex/context/base/mkiv/font-ctx.lua +++ b/tex/context/base/mkiv/font-ctx.lua @@ -2310,7 +2310,7 @@ if environment.initex then      statistics.register("font processing", function()          local l = { }          for what, handler in table.sortedpairs(handlers) do -            local features = handler.features +            local features = handler and handler.features              if features then                  l[#l+1] = format("[%s (base initializers: %s) (base processors: %s) (base manipulators: %s) (node initializers: %s) (node processors: %s) (node manipulators: %s)]",                      what, diff --git a/tex/context/base/mkiv/font-enc.lua b/tex/context/base/mkiv/font-enc.lua index f448685a6..608539c59 100644 --- a/tex/context/base/mkiv/font-enc.lua +++ b/tex/context/base/mkiv/font-enc.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['font-enc'] = {  -- this module is obsolete -local next = next +local next, rawget = next, rawget  local match, gmatch, gsub = string.match, string.gmatch, string.gsub  local setmetatableindex = table.setmetatableindex diff --git a/tex/context/base/mkiv/font-lib.mkvi b/tex/context/base/mkiv/font-lib.mkvi index c9050f61b..7d4fbb71c 100644 --- a/tex/context/base/mkiv/font-lib.mkvi +++ b/tex/context/base/mkiv/font-lib.mkvi @@ -49,12 +49,16 @@  \registerctxluafile{font-otc}{}  \registerctxluafile{font-oth}{}  \registerctxluafile{font-osd}{} -% \doifelsefileexists{font-osm.lua}{\registerctxluafile{font-osm}{}}{} +%registerctxluafile{font-osm}{}  \ifcase\contextlmtxmode -    \registerctxluafile{font-ocl}{} +    \ifnum\luatexversion>111 +        \registerctxluafile{font-ocm}{} % mkiv new +    \else +        \registerctxluafile{font-ocl}{} % generic (will become luatex-fonts-ocl) +    \fi  \else -    \registerctxluafile{font-ogr}{} +    \registerctxluafile{font-ogr}{} % lmtx  \fi  % we use otf code for type one @@ -153,5 +157,21 @@             \def\cleanfontname          #1{\clf_cleanfontname{#1}}  \unexpanded\def\setfontofid            #1{\clf_setfontofid\numexpr#1\relax} +% this is an ugly hack needed for postponed inclusion stuff ... don't try +% to understand this ... these are kind of old mkiv solutions + +\unexpanded\def\typethreefont#1{\setfontid#1\relax} +\unexpanded\def\typethreechar#1{\char#1\hskip-\fontcharwd\font#1\relax} +\unexpanded\def\typethreelast#1{\char#1\relax} +\unexpanded\def\typethreecode#1{\pdfliteral direct {#1}} + +\newtoks\typethreetoks +\let    \typethreemacro\empty + +\typethreetoks {% +    \setbox\zerocount\hpack{\typethreemacro}% +    \setbox\zerocount\hpack{\raise\dp\zerocount\box\zerocount}% +} +  \protect \endinput diff --git a/tex/context/base/mkiv/font-ocl.lua b/tex/context/base/mkiv/font-ocl.lua index be62ea434..77e1538f9 100644 --- a/tex/context/base/mkiv/font-ocl.lua +++ b/tex/context/base/mkiv/font-ocl.lua @@ -363,7 +363,6 @@ local function pdftovirtual(tfmdata,pdfshapes,kind) -- kind = png|svg      local actuale       = { "pdf", "page", e } -- saves tables      --      local vfimage = lpdf and lpdf.vfimage or function(wd,ht,dp,data,name) -        -- needed for generic (if used there at all)          local name = storepdfdata(data)          return { "image", { filename = name, width = wd, height = ht, depth = dp } }      end diff --git a/tex/context/base/mkiv/font-ogr.lua b/tex/context/base/mkiv/font-ogr.lua index b408fc5d6..b45728c6c 100644 --- a/tex/context/base/mkiv/font-ogr.lua +++ b/tex/context/base/mkiv/font-ogr.lua @@ -40,6 +40,8 @@ otf.pngenabled    = true  -- todo: maybe collapse indices so that we have less files (harder to debug)  -- todo: manage (read: assign) font id's in lua so we know in advance +-- what here and what in backend ... +  do      -- This is a prelude to something better but I'm still experimenting. @@ -64,8 +66,8 @@ do          local d_tfmdata          = setmetatableindex({ },t_tfmdata)          local d_properties       = setmetatableindex({ },t_properties)          d_tfmdata.properties     = d_properties -        local d_characters       = setmetatableindex({ },t_characters) -        local d_descriptions     = setmetatableindex({ },t_descriptions) +        local d_characters       = { } -- setmetatableindex({ },t_characters)   -- hm, index vs unicode +        local d_descriptions     = { } -- setmetatableindex({ },t_descriptions) -- hm, index vs unicode          d_tfmdata.characters     = d_characters          d_tfmdata.descriptions   = d_descriptions          d_properties.instance    = - droppedin -- will become an extra element in the hash @@ -108,12 +110,12 @@ do                              -- todo: prepend                              v.commands = { { "slot", slot, idx } }                              -- hack to prevent that type 3 also gets 'use' flags .. todo -                            local c = { commands = false, index = idx, dropin = tfmdata } -                            local d = { index = idx, dropin = tfmdata } +                            local c = { commands = false, index = idx, dropin = tfmdrop } +                            local d = { } -- { index = idx, dropin = tfmdrop }                              setmetatableindex(c,v)                              setmetatableindex(d,description)                              dropchars[idx] = c -                            dropdescs[idx] = d +                            dropdescs[idx] = d -- not needed                          end                      end                  end @@ -149,12 +151,12 @@ do                          -- todo: prepend                          v.commands = { { "slot", slot, idx } }                          -- hack to prevent that type 3 also gets 'use' flags .. todo -                        local c = { commands = false, index = idx, dropin = tfmdata } -                        local d = { index = idx, dropin = tfmdata } +                        local c = { commands = false, index = idx, dropin = tfmdrop } +                        local d = { } -- index = idx, dropin = tfmdrop }                          setmetatableindex(c,v)                          setmetatableindex(d,description)                          dropchars[idx] = c -                        dropdescs[idx] = d +                        dropdescs[idx] = d -- not needed                      end                  end              end @@ -454,6 +456,8 @@ local initializeoverlay  do                  local idx  = 255                  local slot = 0                  -- +                -- todo: delay +                --                  for k, v in next, characters do                      local index = v.index                      if index then @@ -480,11 +484,11 @@ local initializeoverlay  do                                  v.commands = { u, { "slot", slot, idx } }                                  -- hack to prevent that type 3 also gets 'use' flags .. todo                                  local c = { commands = false, index = idx, dropin = tfmdata } -                                local d = { index = idx, dropin = tfmdata } +                                local d = { } -- index = idx, dropin = tfmdrop                                  setmetatableindex(c,v)                                  setmetatableindex(d,description)                                  dropchars[idx] = c -                                dropdescs[idx] = d +                                dropdescs[idx] = d -- not needed                              end                          end                      end @@ -535,6 +539,7 @@ local initializesvg  do                      local svgfile   = containers.read(otf.svgcache,hash)                      local svgshapes = svgfile and svgfile.svgshapes                      pdfshapes = svgshapes and metapost.svgshapestopdf(svgshapes,pdftarget,report_svg,tfmdata.parameters.units) or { } +                    -- look at ocl: we should store scale and x and y                      containers.write(otf.pdfcache, pdfhash, {                          pdfshapes = pdfshapes,                          timestamp = timestamp, diff --git a/tex/context/base/mkiv/font-onr.lua b/tex/context/base/mkiv/font-onr.lua index 188aaf644..fc6bead58 100644 --- a/tex/context/base/mkiv/font-onr.lua +++ b/tex/context/base/mkiv/font-onr.lua @@ -21,7 +21,7 @@ add features.</p>  local fonts, logs, trackers, resolvers = fonts, logs, trackers, resolvers -local next, type, tonumber, rawget, rawset = next, type, tonumber, rawget, rawset +local next, type, tonumber, rawset = next, type, tonumber, rawset  local match, lower, gsub, strip, find = string.match, string.lower, string.gsub, string.strip, string.find  local char, byte, sub = string.char, string.byte, string.sub  local abs = math.abs diff --git a/tex/context/base/mkiv/font-oto.lua b/tex/context/base/mkiv/font-oto.lua index 4d112ac31..6f5f2fb41 100644 --- a/tex/context/base/mkiv/font-oto.lua +++ b/tex/context/base/mkiv/font-oto.lua @@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['font-oto'] = { -- original tex  local concat, unpack = table.concat, table.unpack  local insert, remove = table.insert, table.remove  local format, gmatch, gsub, find, match, lower, strip = string.format, string.gmatch, string.gsub, string.find, string.match, string.lower, string.strip -local type, next, tonumber, tostring, rawget = type, next, tonumber, tostring, rawget +local type, next, tonumber, tostring = type, next, tonumber, tostring  local trace_baseinit         = false  trackers.register("otf.baseinit",     function(v) trace_baseinit     = v end)  local trace_singles          = false  trackers.register("otf.singles",      function(v) trace_singles      = v end) diff --git a/tex/context/base/mkiv/font-otr.lua b/tex/context/base/mkiv/font-otr.lua index 4fe0a6a97..e72605320 100644 --- a/tex/context/base/mkiv/font-otr.lua +++ b/tex/context/base/mkiv/font-otr.lua @@ -65,7 +65,7 @@ if not modules then modules = { } end modules ['font-otr'] = {  --     require("char-ini")  -- end -local next, type, tonumber = next, type, tonumber +local next, type, tonumber, rawget = next, type, tonumber, rawget  local byte, lower, char, gsub = string.byte, string.lower, string.char, string.gsub  local fullstrip = string.fullstrip  local floor, round = math.floor, math.round diff --git a/tex/context/base/mkiv/font-prv.lua b/tex/context/base/mkiv/font-prv.lua index 57c93fd27..c3323ca74 100644 --- a/tex/context/base/mkiv/font-prv.lua +++ b/tex/context/base/mkiv/font-prv.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['font-prv'] = {      license   = "see context related readme files"  } -local type = type +local type, rawget = type, rawget  local formatters = string.formatters  local fonts             = fonts diff --git a/tex/context/base/mkiv/grph-chk.lua b/tex/context/base/mkiv/grph-chk.lua index d16106234..ed78b856c 100644 --- a/tex/context/base/mkiv/grph-chk.lua +++ b/tex/context/base/mkiv/grph-chk.lua @@ -13,6 +13,9 @@ local bpfactor          = number.dimenfactors.bp  local report            = logs.reporter("graphics")  local report_inclusion  = logs.reporter("graphics","inclusion")  local report_bitmap     = logs.reporter("graphics","bitmap") +local report_pdf        = logs.reporter("graphics","pdf") + +local trace_pdf         = false  trackers.register("graphics.pdf", function(v) trace_pdf = v end)  local checkers          = figures.checkers  local genericchecker    = checkers.generic @@ -28,7 +31,6 @@ local placeholder       = graphics.bitmaps.placeholder  -- but opens up some possibilities (like merging fonts) that I will look into some  -- day. -  function checkers.pdf(data)      local request = data.request      local used    = data.used @@ -39,11 +41,23 @@ function checkers.pdf(data)          local querypdf = image.query          local copypage = image.copy          local pdfdoc   = nil +        local filename = nil          request.scanimage = function(t) -            pdfdoc = openpdf(t.filename,request.userpassword,request.ownerpassword)              if pdfdoc then -                -- -                pdfdoc.nofcopiedpages = 0 +                if trace_pdf then +                    report_pdf("scan image %a",filename) +                end +                if not filename then +                    filename = pdfdoc.filename +                end +            else +                filename = t.filename +                if trace_pdf then +                    report_pdf("open and scan image %a",filename) +                end +                pdfdoc = openpdf(filename,request.userpassword,request.ownerpassword) +            end +            if pdfdoc then                  --                  local info = querypdf(pdfdoc,request.page,request.size)                  if info then @@ -63,19 +77,19 @@ function checkers.pdf(data)                          rotation = 0                      end                      return { -                        filename    = filename, -                     -- page        = 1, -                        pages       = pdfdoc.nofpages, -                        width       = width, -                        height      = height, -                        depth       = 0, -                        colordepth  = 0, -                        xres        = 0, -                        yres        = 0, -                        xsize       = width, -                        ysize       = height, -                        rotation    = rotation, -                        pdfdoc      = pdfdoc, +                        filename   = filename, +                     -- page       = 1, +                        pages      = pdfdoc.nofpages, +                        width      = width, +                        height     = height, +                        depth      = 0, +                        colordepth = 0, +                        xres       = 0, +                        yres       = 0, +                        xsize      = width, +                        ysize      = height, +                        rotation   = rotation, +                        pdfdoc     = pdfdoc,                      }                  end              end @@ -85,9 +99,21 @@ function checkers.pdf(data)                  pdfdoc = t.pdfdoc              end              if pdfdoc then -                local result = copypage(pdfdoc,request.page,nil,request.compact,request.width,request.height,request.attr) -                pdfdoc.nofcopiedpages = pdfdoc.nofcopiedpages + 1 -                if pdfdoc.nofcopiedpages >= pdfdoc.nofpages then +                local page   = request.page +                local copied = pdfdoc.nofcopied or 0 +                if not pdfdoc.copied[page] then +                    pdfdoc.copied[page] = true +                    copied = copied + 1 +                end +                pdfdoc.nofcopied = copied +                if trace_pdf then +                    report_pdf("copy page %i from image %a, %i pages copied",page,filename,copied) +                end +                local result = copypage(pdfdoc,page,nil,request.compact,request.width,request.height,request.attr) +                if pdfdoc.nofcopied >= pdfdoc.nofpages then +                    if trace_pdf then +                        report_pdf("closing image %a, %i pages copied",filename,copied) +                    end                      closepdf(pdfdoc)                      pdfdoc = nil                      t.pdfdoc = nil diff --git a/tex/context/base/mkiv/l-os.lua b/tex/context/base/mkiv/l-os.lua index aa04e254d..8394d19e7 100644 --- a/tex/context/base/mkiv/l-os.lua +++ b/tex/context/base/mkiv/l-os.lua @@ -30,7 +30,7 @@ local date, time = os.date, os.time  local find, format, gsub, upper, gmatch = string.find, string.format, string.gsub, string.upper, string.gmatch  local concat = table.concat  local random, ceil, randomseed = math.random, math.ceil, math.randomseed -local rawget, rawset, type, getmetatable, setmetatable, tonumber, tostring = rawget, rawset, type, getmetatable, setmetatable, tonumber, tostring +local type, setmetatable, tonumber, tostring = type, setmetatable, tonumber, tostring  -- This check needs to happen real early on. Todo: we can pick it up from the commandline  -- if we pass --binpath= (which is useful anyway) diff --git a/tex/context/base/mkiv/l-table.lua b/tex/context/base/mkiv/l-table.lua index e82820386..98b377bdc 100644 --- a/tex/context/base/mkiv/l-table.lua +++ b/tex/context/base/mkiv/l-table.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['l-table'] = {      license   = "see context related readme files"  } -local type, next, tostring, tonumber, select = type, next, tostring, tonumber, select +local type, next, tostring, tonumber, select, rawget = type, next, tostring, tonumber, select, rawget  local table, string = table, string  local concat, sort = table.concat, table.sort  local format, lower, dump = string.format, string.lower, string.dump diff --git a/tex/context/base/mkiv/lang-hyp.lua b/tex/context/base/mkiv/lang-hyp.lua index 92b400d4f..93457c7a2 100644 --- a/tex/context/base/mkiv/lang-hyp.lua +++ b/tex/context/base/mkiv/lang-hyp.lua @@ -74,7 +74,7 @@ if not modules then modules = { } end modules ['lang-hyp'] = {  -- ins       : when hyphenationbounds 2 or 3  -- adjust    : when hyphenationbounds 2 or 3 -local type, rawset, tonumber, next = type, rawset, tonumber, next +local type, rawget, rawset, tonumber, next = type, rawget, rawset, tonumber, next  local P, R, S, Cg, Cf, Ct, Cc, C, Carg, Cs = lpeg.P, lpeg.R, lpeg.S, lpeg.Cg, lpeg.Cf, lpeg.Ct, lpeg.Cc, lpeg.C, lpeg.Carg, lpeg.Cs  local lpegmatch = lpeg.match diff --git a/tex/context/base/mkiv/lpdf-emb.lua b/tex/context/base/mkiv/lpdf-emb.lua index c24a9173c..c1ebf6873 100644 --- a/tex/context/base/mkiv/lpdf-emb.lua +++ b/tex/context/base/mkiv/lpdf-emb.lua @@ -27,7 +27,10 @@ if not modules then modules = { } end modules ['lpdf-ini'] = {  -- with manual tweaking in desk top publishing applications. Keep in mind that Emoji  -- can have funny dimensions (e.g. to be consistent within a font, so no tight ones). -local next, type, unpack = next, type, unpack +-- When we have moved to lmtx I will document a bit more. Till then it's experimental +-- and subjected to change. + +local next, type, unpack, rawget = next, type, unpack, rawget  local char, byte, gsub, sub, match, rep, gmatch = string.char, string.byte, string.gsub, string.sub, string.match, string.rep, string.gmatch  local formatters = string.formatters  local format = string.format @@ -1539,16 +1542,18 @@ do          local embedimage = images.embed -        local f_glyph    = formatters["G%d"] -        local f_char     = formatters["BT /V%d 1 Tf [<%04X>] TJ ET"] -        local f_width    = formatters["%.6N 0 d0"] -        local f_index    = formatters["I%d"] -        local f_image    = formatters["%.6N 0 d0 /%s Do"] -        local f_image_xy = formatters["%.6N 0 d0 1 0 0 1 %.3N %.3N cm /%s Do"] -        local f_image_d  = formatters["%.6N 0 d0 1 0 0 1 0 %.3N cm /%s Do"] -        local f_stream   = formatters["%.6N 0 d0 %s"] -        local f_stream_c = formatters["%.6N 0 0 0 0 0 d1 %s"] -        local f_stream_d = formatters["%.6N 0 d0 1 0 0 1 0 %.3N cm %s"] +        local f_glyph      = formatters["G%d"] +        local f_char       = formatters["BT /V%d 1 Tf [<%04X>] TJ ET"] +        local f_width      = formatters["%.6N 0 d0"] +        local f_index      = formatters["I%d"] +        local f_image_xy   = formatters["%.6N 0 d0 1 0 0 1 %.3N %.3N cm /%s Do"] +        local f_image_c    = formatters["/%s Do"] +        local f_image_c_xy = formatters["%.6N 0 0 %.6N %.3N %.3N cm /%s Do"] +        local f_image_w    = formatters["%.6N 0 d0 %s"] +        local f_image_d    = formatters["%.6N 0 d0 1 0 0 1 0 %.3N cm /%s Do"] +        local f_stream     = formatters["%.6N 0 d0 %s"] +        local f_stream_c   = formatters["%.6N 0 0 0 0 0 d1 %s"] +        local f_stream_d   = formatters["%.6N 0 d0 1 0 0 1 0 %.3N cm %s"]          -- A type 3 font has at most 256 characters and Acrobat also wants a zero slot          -- to be filled. We can share a mandate zero slot character. We also need to @@ -1583,11 +1588,10 @@ do              return result.glyphs, scalefactor, pktopdf, false, false          end -        -- not scaling in svg but here using a cm might be more efficient in terms of bytes -        -- as we get smaller numbers -          -- pdf inclusion +        local used = setmetatableindex("table") +          function methods.pdf(filename,details)              local properties = details.properties              local pdfshapes  = properties.indexdata[1] @@ -1599,22 +1603,43 @@ do                  local units    = details.parameters.units                  local factor   = units * bpfactor / scale                  local fixdepth = pdfshapes.fixdepth +                local useddoc  = used[pdfdoc]                  local function pdftopdf(glyph,data) -                    local width  = data.width or 0 -                    local image  = copypage(pdfdoc,glyph) -                    embedimage(image) -                    width        = width * factor -                    nofglyphs    = nofglyphs + 1 -                    local name   = f_glyph(nofglyphs) -                    xforms[name] = pdfreference(image.objnum) -                    if fixdepth then -                        local depth  = data.depth  or 0 -                        local height = data.height or 0 -                        if depth ~= 0 or height ~= 0 then -                            return f_image_d(width,(-height-depth)*factor,name), width +                    local width     = (data.width or 0) * factor +                    local image     = useddoc[glyph] +                    local reference = nil +                    if not image then +                        image        = embedimage(copypage(pdfdoc,glyph)) +                        nofglyphs    = nofglyphs + 1 +                        local name   = f_glyph(nofglyphs) +                        local stream = nil +                        if fixdepth then +                            local depth  = data.depth  or 0 +                            local height = data.height or 0 +                            if depth ~= 0 or height ~= 0 then +                                local d     = data.dropin.descriptions[data.index] +                                local b     = d.boundingbox +                                local l     = b[1] +                                local r     = b[3] +                                local w     = r - l +                                local scale = w / d.width +                                local x     = l +                                local y     = - b[4] - b[2] - d.depth +                                local scale = w / (image.width * bpfactor) +                                stream = f_image_c_xy(scale,scale,x,y,name) +                            else +                                stream = f_image_c(name) +                            end +                        else +                            stream = f_image_c(name)                          end +                        useddoc[glyph]           = image +                        image.embedded_name      = name +                        image.embedded_stream    = stream +                        image.embedded_reference = pdfreference(image.objnum)                      end -                    return f_image(width,name), width +                    xforms[image.embedded_name] = image.embedded_reference +                    return f_image_w(width,image.embedded_stream), width                  end                  local function closepdf()                   -- closepdf(pdfdoc) @@ -1700,15 +1725,16 @@ do          function methods.png(filename,details)              local properties = details.properties -            local parameters = details.parameters -            local png        = properties.png -            local hash       = png.hash              local pngshapes  = properties.indexdata[1] -            local xforms     = pdfdictionary() -            local nofglyphs  = 0 -            local scale      = 10 * parameters.size/parameters.designsize -            local factor     = bpfactor / scale              if pngshapes then +                local parameters = details.parameters +                local png        = properties.png +                local hash       = png.hash +                local xforms     = pdfdictionary() +                local nofglyphs  = 0 +                local scale      = 10 * parameters.size/parameters.designsize +                local factor     = bpfactor / scale +                local units      = parameters.units / 1000                  local function pngtopdf(glyph,data)                   -- local width   = data.width                      local info    = graphics.identifiers.png(glyph.data,"string") @@ -1717,8 +1743,8 @@ do                      embedimage(image)                      nofglyphs     = nofglyphs + 1                      local width   = (data.width or 0) * factor -                    local xoffset = (glyph.x or 0) / 1000 -- or units ? -                    local yoffset = (glyph.y or 0) / 1000 -- or units ? +                    local xoffset = (glyph.x or 0) / units +                    local yoffset = (glyph.y or 0) / units                      local name    = f_glyph(nofglyphs)                      xforms[name]  = pdfreference(image.objnum)                      local pdf     = f_image_xy(width,xoffset,yoffset,name) @@ -1738,16 +1764,15 @@ do              local colrshapes = details.properties.indexdata[1]              local colrvalues = details.properties.indexdata[2]              local usedfonts  = { } -            local dd         = details.fontdata.descriptions -- temp hack              local function colrtopdf(description,data)                  -- descriptions by index                  local colorlist = description.colors                  if colorlist then -                    local dropdata  = data.dropin -                    local dropid    = dropdata.properties.id -                    local dropunits = dropdata.parameters.units -- shared -                    usedfonts[dropid] = dropid - +                    local dropdata     = data.dropin +                    local dropid       = dropdata.properties.id +                    local dropunits    = dropdata.parameters.units -- shared +                    local descriptions = dropdata.descriptions +                    usedfonts[dropid]  = dropid                      local w = description.width or 0                      local s = #colorlist                      local l = nil @@ -1761,7 +1786,7 @@ do                              n = n + 1 ; t[n] = v                              l = v                          end -                        local e = dd[entry.slot] +                        local e = descriptions[entry.slot]                          if e then                              n = n + 1 ; t[n] = f_char(dropid,e.index)                          end @@ -1803,9 +1828,9 @@ do              local charprocs   = pdfdictionary()              local basefont    = pdfconstant(basefontname)              local d           = 0 +            local w           = 0              local forcenotdef = minindex > 0              local lastindex   = -0xFF -              if forcenotdef then                  widths[0] = 0                  minindex  = 0 @@ -1824,6 +1849,7 @@ do              for i=1,maxindex-minindex+1 do                  widths[i] = 0              end +              for index, data in sortedhash(indices) do                  local name  = f_index(index)                  local glyph = glyphs[index] @@ -2011,7 +2037,8 @@ function lpdf.flushfonts()          end      end -    -- this is no not yet ok for tfm / type 1 +    -- this is no not yet ok for tfm / type 1 .. we need to move the nested blobs ourside the loop +      for hash, details in sortedhash(mainfonts) do          local filename = details.filename          if next(details.indices) then diff --git a/tex/context/base/mkiv/lpdf-fnt.lua b/tex/context/base/mkiv/lpdf-fnt.lua index 1caa2f93c..6729578a2 100644 --- a/tex/context/base/mkiv/lpdf-fnt.lua +++ b/tex/context/base/mkiv/lpdf-fnt.lua @@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['lpdf-fnt'] = {  -- This is experimental code.  local match, gmatch = string.match, string.gmatch -local tonumber = tonumber +local tonumber, rawget = tonumber, rawget  local pdfreserveobject = lpdf.reserveobject  local pdfincludechar   = lpdf.includechar diff --git a/tex/context/base/mkiv/lpdf-lmt.lua b/tex/context/base/mkiv/lpdf-lmt.lua index 32d743614..e1ef7ff6b 100644 --- a/tex/context/base/mkiv/lpdf-lmt.lua +++ b/tex/context/base/mkiv/lpdf-lmt.lua @@ -666,7 +666,7 @@ local flushliteral  do              elseif mode == rawliteral_code then                  pdf_end_string_nl()              else -                print("check literal") +                report("check literal")                  pdf_goto_pagemode()                  pdf_set_pos(pos_h,pos_v)              end @@ -898,7 +898,7 @@ local flushrule, flushsimplerule, flushimage, flushgroup  do          if l then              return l.name          else -            print("no box resource",index) +            report("no box resource %S",index)          end      end @@ -952,7 +952,7 @@ local flushrule, flushsimplerule, flushimage, flushgroup  do              setprop(tonut(rule),"index",index)              return rule, wd, ht, dp          else -            print("no box resource",index) +            report("no box resource %S",index)          end      end @@ -961,7 +961,7 @@ local flushrule, flushsimplerule, flushimage, flushgroup  do          if l then              return l.width, l.height, l.depth, l.margin          else -            print("no box resource",index) +            report("no box resource %S",index)          end      end @@ -1034,7 +1034,7 @@ local flushrule, flushsimplerule, flushimage, flushgroup  do          if l then              return l.name          else -            print("no image resource",index) +            report("no image resource %S",index)          end      end @@ -1093,7 +1093,7 @@ local flushrule, flushsimplerule, flushimage, flushgroup  do                groupref  = pdfincludeimage(index)  -- needs to be sorted out, bad name (no longer mixed anyway)          if not kind then -            print("invalid image",index) +            report("invalid image %S",index)              return          end @@ -1741,7 +1741,7 @@ local nofobjects    = 0  local offset        = 0  local f             = false  local flush         = false -local threshold     = 40 -- also #("/Filter /FlateDecode") +local threshold     = 40 -- also #("/Filter /FlateDecode") (compression threshold)  local objectstream  = true  local compress      = true  local cache         = false @@ -1752,6 +1752,14 @@ local majorversion  = 1  local minorversion  = 7  local trailerid     = true +directives.register("backend.pdf.threshold",function(v) +    if v then +        threshold = tonumber(v) or 40 +    else +        threshold = -1000 +    end +end) +  local f_object       = formatters["%i 0 obj\010%s\010endobj\010"]  local f_stream_n_u   = formatters["%i 0 obj\010<< /Length %i >>\010stream\010%s\010endstream\010endobj\010"]  local f_stream_n_c   = formatters["%i 0 obj\010<< /Filter /FlateDecode /Length %i >>\010stream\010%s\010endstream\010endobj\010"] @@ -1930,7 +1938,7 @@ end  local function flushstreamobj(data,n,dict,comp,nolength)      if not data then -        print("no data for",dict) +        report("no data for %S",dict)          return      end      if not n then diff --git a/tex/context/base/mkiv/lpdf-pde.lua b/tex/context/base/mkiv/lpdf-pde.lua index eaeea5df3..ec1064a0d 100644 --- a/tex/context/base/mkiv/lpdf-pde.lua +++ b/tex/context/base/mkiv/lpdf-pde.lua @@ -41,7 +41,7 @@ if not modules then modules = { } end modules ['lpdf-epd'] = {  -- PPCRYPT_PASS                 -1   encryption present, need non-empty password  -- PPCRYPT_FAIL                 -2   invalid or unsupported encryption (eg. undocumented in pdf spec) -local setmetatable, rawset, rawget, type, next = setmetatable, rawset, rawget, type, next +local setmetatable, type, next = setmetatable, type, next  local tostring, tonumber, unpack = tostring, tonumber, unpack  local char, byte, find = string.char, string.byte, string.find  local abs = math.abs @@ -405,21 +405,25 @@ function resolvers.pages(document)      --      for pagenumber=1,nofpages do          local rawpagedata   = rawpages[pagenumber] -        local pagereference = rawpagedata[3] -        local pageobject    = rawpagedata[1] -        local pagedata      = some_dictionary(pageobject,document) -        if pagedata and pageobject then -            pagedata.number   = pagenumber -            pagedata.MediaBox = getbox(pageobject,"MediaBox") -            pagedata.CropBox  = getbox(pageobject,"CropBox") -            pagedata.BleedBox = getbox(pageobject,"BleedBox") -            pagedata.ArtBox   = getbox(pageobject,"ArtBox") -            pagedata.TrimBox  = getbox(pageobject,"TrimBox") -            pages[pagenumber] = pagedata -            __xrefs__[pagedata]      = pagereference -            __cache__[pagereference] = pagedata +        if rawpagedata then +            local pagereference = rawpagedata[3] +            local pageobject    = rawpagedata[1] +            local pagedata      = some_dictionary(pageobject,document) +            if pagedata and pageobject then +                pagedata.number   = pagenumber +                pagedata.MediaBox = getbox(pageobject,"MediaBox") +                pagedata.CropBox  = getbox(pageobject,"CropBox") +                pagedata.BleedBox = getbox(pageobject,"BleedBox") +                pagedata.ArtBox   = getbox(pageobject,"ArtBox") +                pagedata.TrimBox  = getbox(pageobject,"TrimBox") +                pages[pagenumber] = pagedata +                __xrefs__[pagedata]      = pagereference +                __cache__[pagereference] = pagedata +            else +            report_epdf("missing pagedata for page %i, case %i",pagenumber,1) +            end          else -            report_epdf("missing pagedata for page %i",i) +            report_epdf("missing pagedata for page %i, case %i",pagenumber,2)          end      end      -- @@ -455,6 +459,8 @@ function lpdf_epdf.load(filename,userpassword,ownerpassword,fromstring)              if __data__ then                  document = {                      filename   = filename, +                    nofcopied  = 0, +                    copied     = { },                      __cache__  = { },                      __xrefs__  = { },                      __fonts__  = { }, @@ -481,6 +487,9 @@ function lpdf_epdf.load(filename,userpassword,ownerpassword,fromstring)          statistics.stoptiming(lpdf_epdf)       -- print(statistics.elapsedtime(lpdf_epdf))      end +    if document then +        nofloaded = nofloaded + 1 +    end      return document or nil  end @@ -491,9 +500,9 @@ function lpdf_epdf.unload(filename)      if type(filename) == "string" then          local document = loaded[filename]          if document then -         -- pdfclose(document)              loaded[document] = nil              loaded[filename] = nil +            pdfclose(document.__data__)          end      end  end @@ -1017,6 +1026,8 @@ if images then do      local openpdf  = lpdf_epdf.load      local closepdf = lpdf_epdf.unload +    -- todo: keep track of already open files +      local function newpdf(str,userpassword,ownerpassword)          return openpdf(str,userpassword,ownerpassword,true)      end diff --git a/tex/context/base/mkiv/luat-env.lua b/tex/context/base/mkiv/luat-env.lua index e6a0c8c5d..1620a26e5 100644 --- a/tex/context/base/mkiv/luat-env.lua +++ b/tex/context/base/mkiv/luat-env.lua @@ -11,7 +11,7 @@  -- sense. Much of this evolved before bytecode arrays were available and so a lot of  -- code has disappeared already. -local rawset, rawget, loadfile = rawset, rawget, loadfile +local rawset, loadfile = rawset, loadfile  local gsub = string.gsub  local trace_locating = false  trackers.register("resolvers.locating", function(v) trace_locating = v end) diff --git a/tex/context/base/mkiv/math-ext.lua b/tex/context/base/mkiv/math-ext.lua index b923853f4..762f1f904 100644 --- a/tex/context/base/mkiv/math-ext.lua +++ b/tex/context/base/mkiv/math-ext.lua @@ -6,7 +6,6 @@ if not modules then modules = { } end modules ['math-ext'] = {      license   = "see context related readme files"  } -local rawget = rawget  local basename = file.basename  local sortedhash  = table.sortedhash diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index 5098eb76d..d23949352 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -447,7 +447,7 @@ function models.cmyk(cr)              local y = cr[3]              local k = cr[4]              if c == m and m == y and y == 0 then -                k = k - 1 +                k = 1 - k                  return checked_color_pair(f_gray,k,k)              else                  return checked_color_pair(f_cmyk,c,m,y,k,c,m,y,k) @@ -462,7 +462,11 @@ function models.cmyk(cr)          local y = cr[3]          local k = cr[4]          if n == 3 then -            c, m, y, k = rgbtocmyk(c,m,y) +            if c == m and m == y then +                k, c, m, y = 1 - c, 0, 0, 0 +            else +                c, m, y, k = rgbtocmyk(c,m,y) +            end          end          return checked_color_pair(f_cmyk,c,m,y,k,c,m,y,k)      end diff --git a/tex/context/base/mkiv/mtx-context-copy.tex b/tex/context/base/mkiv/mtx-context-copy.tex index 8e4336609..d29f1d07c 100644 --- a/tex/context/base/mkiv/mtx-context-copy.tex +++ b/tex/context/base/mkiv/mtx-context-copy.tex @@ -56,6 +56,8 @@  \startluacode +    local find = string.find +      if #document.files == 0 then          context("no files given")      else @@ -64,7 +66,7 @@          end          for i=1,#document.files do              local filename = document.files[i] -            if not string.find(filename,"^mtx%-context%-") then +            if not find(filename,"^mtx%-context%-") and not find(filename,"^context%-extra") then                  logs.report("copy",filename)                  context.getfiguredimensions                      { filename } diff --git a/tex/context/base/mkiv/node-aux.lua b/tex/context/base/mkiv/node-aux.lua index 1567868d7..2a747f3b5 100644 --- a/tex/context/base/mkiv/node-aux.lua +++ b/tex/context/base/mkiv/node-aux.lua @@ -74,7 +74,6 @@ local unsetvalue         = attributes.unsetvalue  local current_font       = font.current  local texsetbox          = tex.setbox -local texnest            = tex.nest  local report_error       = logs.reporter("node-aux:error") @@ -465,26 +464,17 @@ function nuts.use_components(head,current)      return head, first, last  end --- function nuts.current_tail() ---     local whatever = texnest[texnest.ptr] ---     if whatever then ---         local tail = whatever.tail ---         if tail then ---             return tonut(tail) ---         end ---     end --- end -  do      local localparcodes = nodes.localparcodes      local hmodepar_code = localparcodes.vmode_par      local vmodepar_code = localparcodes.hmode_par +    local getnest       = tex.getnest      local getsubtype    = nuts.getsubtype      function nuts.setparproperty(action,...) -        local tail = tonut(texnest[texnest.ptr].tail) +        local tail = tonut(getnest().tail)          while tail do              if getid(tail) == localpar_code then                  local s = getsubtype(tail) diff --git a/tex/context/base/mkiv/node-dir.lua b/tex/context/base/mkiv/node-dir.lua index ef26286e5..762f20739 100644 --- a/tex/context/base/mkiv/node-dir.lua +++ b/tex/context/base/mkiv/node-dir.lua @@ -32,10 +32,32 @@ local new_kern          = nuts.pool.kern  local setcolor          = nodes.tracers.colors.set  local settransparency   = nodes.tracers.transparencies.set +-- local function dirdimensions(parent,begindir) -- can be a helper +--     local level   = 1 +--     local enddir  = begindir +--     local width   = 0 +--     for current, subtype in nextdir, getnext(begindir) do +--         if subtype == normaldir_code then -- todo +--             level = level + 1 +--         else +--             level = level - 1 +--         end +--         if level == 0 then -- does the type matter +--             enddir = current +--             width  = rangedimensions(parent,begindir,enddir) +--             return width, enddir +--         end +--     end +--     if enddir == begindir then +--         width = rangedimensions(parent,begindir) +--     end +--     return width, enddir +-- end +  local function dirdimensions(parent,begindir) -- can be a helper -    local level  = 1 -    local enddir = begindir -    local width  = 0 +    local level   = 1 +    local lastdir = nil +    local width   = 0      for current, subtype in nextdir, getnext(begindir) do          if subtype == normaldir_code then -- todo              level = level + 1 @@ -43,14 +65,10 @@ local function dirdimensions(parent,begindir) -- can be a helper              level = level - 1          end          if level == 0 then -- does the type matter -            enddir = current -            width  = rangedimensions(parent,begindir,enddir) +            return (rangedimensions(parent,begindir,current)), current          end      end -    if enddir == begindir then -        width = rangedimensions(parent,begindir) -    end -    return width, enddir +    return (rangedimensions(parent,begindir)), begindir  end  nuts.dirdimensions = dirdimensions diff --git a/tex/context/base/mkiv/node-pro.lua b/tex/context/base/mkiv/node-pro.lua index 606d5b8d7..4d748af89 100644 --- a/tex/context/base/mkiv/node-pro.lua +++ b/tex/context/base/mkiv/node-pro.lua @@ -176,7 +176,8 @@ end  do -    local texnest       = tex.nest +    ----- texnest       = tex.nest +    local getnest       = tex.getnest      local getlist       = nuts.getlist      local setlist       = nuts.setlist @@ -188,7 +189,7 @@ do      function processors.contribute_filter(groupcode)          if groupcode == "box" then -- "pre_box" -            local whatever = texnest[texnest.ptr] +            local whatever = getnest()              if whatever then                  local line = whatever.tail                  if line then diff --git a/tex/context/base/mkiv/page-cst.lua b/tex/context/base/mkiv/page-cst.lua index 119e7fc2b..a6315ff05 100644 --- a/tex/context/base/mkiv/page-cst.lua +++ b/tex/context/base/mkiv/page-cst.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ["page-cst"] = {  -- todo: check what is used -local next, type, tonumber = next, type, tonumber +local next, type, tonumber, rawget = next, type, tonumber, rawget  local ceil, odd, round = math.ceil, math.odd, math.round  local lower = string.lower  local copy = table.copy diff --git a/tex/context/base/mkiv/publ-tra.lua b/tex/context/base/mkiv/publ-tra.lua index 81bbc2fd3..80dd143d0 100644 --- a/tex/context/base/mkiv/publ-tra.lua +++ b/tex/context/base/mkiv/publ-tra.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['publ-tra'] = {  -- todo: use context.tt .. more efficient, less code -local next, type = next, type +local next, type, rawget = next, type, rawget  local sortedhash        = table.sortedhash  local sortedkeys        = table.sortedkeys diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 51d2c9706..95e132621 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 b3a54adee..425fd5cb8 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-not.mkvi b/tex/context/base/mkiv/strc-not.mkvi index 48151c76e..05aa1eb6b 100644 --- a/tex/context/base/mkiv/strc-not.mkvi +++ b/tex/context/base/mkiv/strc-not.mkvi @@ -120,7 +120,7 @@     \c!state=\v!start,     \c!levels=3] -%D The code here is mostly the same as enumersations but we want to keep them +%D The code here is mostly the same as enumerations but we want to keep them  %D isolated and at some point we might differentiate.  % \installcorenamespace{noteclass} diff --git a/tex/context/base/mkiv/strc-reg.lua b/tex/context/base/mkiv/strc-reg.lua index 5e444de4b..6873f89eb 100644 --- a/tex/context/base/mkiv/strc-reg.lua +++ b/tex/context/base/mkiv/strc-reg.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['strc-reg'] = {      license   = "see context related readme files"  } -local next, type, tonumber = next, type, tonumber +local next, type, tonumber, rawget = next, type, tonumber, rawget  local char, format, gmatch = string.char, string.format, string.gmatch  local equal, concat, remove = table.are_equal, table.concat, table.remove  local lpegmatch, P, C, Ct = lpeg.match, lpeg.P, lpeg.C, lpeg.Ct diff --git a/tex/context/base/mkiv/tabl-tab.mkiv b/tex/context/base/mkiv/tabl-tab.mkiv index 631f29bc0..b137ac16c 100644 --- a/tex/context/base/mkiv/tabl-tab.mkiv +++ b/tex/context/base/mkiv/tabl-tab.mkiv @@ -666,7 +666,7 @@     \ifx\tempstring\empty       \!taDimenC\zeropoint     \else -     \setbox\scratchbox=\hbox{\mathsurround\zeropoint #1.#3#1}% +     \setbox\scratchbox\hbox{\mathsurround\zeropoint #1.#3#1}%       \!taDimenC\wd\scratchbox     \fi     \setbox\scratchbox\hbox{\mathsurround\zeropoint #1#2#1}% diff --git a/tex/context/base/mkiv/tabl-xtb.lua b/tex/context/base/mkiv/tabl-xtb.lua index c9d50638e..d2b1e9768 100644 --- a/tex/context/base/mkiv/tabl-xtb.lua +++ b/tex/context/base/mkiv/tabl-xtb.lua @@ -26,7 +26,7 @@ this mechamism will be improved so that it can replace its older cousin.  -- todo: use linked list instead of r/c array  -- todo: we can use the sum of previously forced widths for column spans -local tonumber, next, rawget = tonumber, next, rawget +local tonumber, next = tonumber, next  local commands            = commands  local context             = context diff --git a/tex/context/base/mkiv/trac-vis.lua b/tex/context/base/mkiv/trac-vis.lua index 198d52324..e592b7d0c 100644 --- a/tex/context/base/mkiv/trac-vis.lua +++ b/tex/context/base/mkiv/trac-vis.lua @@ -7,7 +7,7 @@ if not modules then modules = { } end modules ['trac-vis'] = {  }  local node, nodes, attributes, fonts, tex = node, nodes, attributes, fonts, tex -local type, tonumber, next = type, tonumber, next +local type, tonumber, next, rawget = type, tonumber, next, rawget  local gmatch = string.gmatch  local formatters = string.formatters  local round = math.round diff --git a/tex/context/base/mkiv/util-sql.lua b/tex/context/base/mkiv/util-sql.lua index d01a2267c..2f8c862ad 100644 --- a/tex/context/base/mkiv/util-sql.lua +++ b/tex/context/base/mkiv/util-sql.lua @@ -60,7 +60,7 @@ if not modules then modules = { } end modules ['util-sql'] = {  local format, match = string.format, string.match  local random = math.random -local rawset, setmetatable, getmetatable, load, type = rawset, setmetatable, getmetatable, load, type +local rawset, rawget, setmetatable, getmetatable, load, type = rawset, rawget, setmetatable, getmetatable, load, type  local P, S, V, C, Cs, Ct, Cc, Cg, Cf, patterns, lpegmatch = lpeg.P, lpeg.S, lpeg.V, lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.Cc, lpeg.Cg, lpeg.Cf, lpeg.patterns, lpeg.match  local concat = table.concat diff --git a/tex/context/fonts/mkiv/type-imp-libertinus.mkiv b/tex/context/fonts/mkiv/type-imp-libertinus.mkiv index 1ceda8737..dc9c23fe2 100644 --- a/tex/context/fonts/mkiv/type-imp-libertinus.mkiv +++ b/tex/context/fonts/mkiv/type-imp-libertinus.mkiv @@ -12,7 +12,12 @@  %C details.  %D This typescript (submitted by by Henri Menke) is a follow up on libertine -%D which is no longer maintained cq.\ developed further. +%D which is no longer maintained cq.\ developed further. We probably need to +%D come up with some goodie file to fix a couple of things in the math font. + +% \definefontfeature[math-text]        [collapseitalics=yes] +% \definefontfeature[math-script]      [collapseitalics=yes] +% \definefontfeature[math-scriptscript][collapseitalics=yes]  \starttypescriptcollection[libertinus] diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 5948b8a59..f80e50193 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex cce00c05a..41c0f4f36 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/mkiv/s-fonts-features.lua b/tex/context/modules/mkiv/s-fonts-features.lua index 6c676ce2d..34268c171 100644 --- a/tex/context/modules/mkiv/s-fonts-features.lua +++ b/tex/context/modules/mkiv/s-fonts-features.lua @@ -11,6 +11,7 @@ moduledata.fonts.features = moduledata.fonts.features or { }  -- for the moment only otf +local rawget = rawget  local insert, remove, sortedhash = table.insert, table.remove, table.sortedhash  local v_yes  = interfaces.variables.yes diff --git a/tex/context/modules/mkiv/s-fonts-tables.lua b/tex/context/modules/mkiv/s-fonts-tables.lua index 33cbc924c..d9d7205de 100644 --- a/tex/context/modules/mkiv/s-fonts-tables.lua +++ b/tex/context/modules/mkiv/s-fonts-tables.lua @@ -9,6 +9,8 @@ if not modules then modules = { } end modules ['s-fonts-tables'] = {  moduledata.fonts          = moduledata.fonts        or { }  moduledata.fonts.tables   = moduledata.fonts.tables or { } +local rawget, type = rawget, type +  local setmetatableindex   = table.setmetatableindex  local sortedhash          = table.sortedhash  local sortedkeys          = table.sortedkeys diff --git a/tex/context/modules/mkiv/x-asciimath.lua b/tex/context/modules/mkiv/x-asciimath.lua index 23f907d95..edad3f575 100644 --- a/tex/context/modules/mkiv/x-asciimath.lua +++ b/tex/context/modules/mkiv/x-asciimath.lua @@ -35,7 +35,7 @@ if not characters then      require("char-ent")  end -local rawget, next, type = rawget, next, type +local next, type = next, type  local concat, insert, remove = table.concat, table.insert, table.remove  local rep, gmatch, gsub, find = string.rep, string.gmatch, string.gsub, string.find  local utfchar, utfbyte = utf.char, utf.byte diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 60dd39e39..49279839c 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  : 12/17/19 16:16:32 +-- merge date  : 12/24/19 19:44:19  do -- begin closure to overcome local limits and interference @@ -1049,7 +1049,7 @@ if not modules then modules={} end modules ['l-table']={   copyright="PRAGMA ADE / ConTeXt Development Team",   license="see context related readme files"  } -local type,next,tostring,tonumber,select=type,next,tostring,tonumber,select +local type,next,tostring,tonumber,select,rawget=type,next,tostring,tonumber,select,rawget  local table,string=table,string  local concat,sort=table.concat,table.sort  local format,lower,dump=string.format,string.lower,string.dump @@ -10885,7 +10885,7 @@ if not modules then modules={} end modules ['font-otr']={   copyright="PRAGMA ADE / ConTeXt Development Team",   license="see context related readme files"  } -local next,type,tonumber=next,type,tonumber +local next,type,tonumber,rawget=next,type,tonumber,rawget  local byte,lower,char,gsub=string.byte,string.lower,string.char,string.gsub  local fullstrip=string.fullstrip  local floor,round=math.floor,math.round @@ -15123,7 +15123,15 @@ do     else      popped=3     end -   top=top-(stack[top-1]+2) +   local t=stack[top-1] +   if t then +    top=top-(t+2) +    if top<0 then +     top=0 +    end +   else +    top=0 +   end    else     top=0    end @@ -23933,7 +23941,7 @@ if not modules then modules={} end modules ['font-oto']={  local concat,unpack=table.concat,table.unpack  local insert,remove=table.insert,table.remove  local format,gmatch,gsub,find,match,lower,strip=string.format,string.gmatch,string.gsub,string.find,string.match,string.lower,string.strip -local type,next,tonumber,tostring,rawget=type,next,tonumber,tostring,rawget +local type,next,tonumber,tostring=type,next,tonumber,tostring  local trace_baseinit=false  trackers.register("otf.baseinit",function(v) trace_baseinit=v end)  local trace_singles=false  trackers.register("otf.singles",function(v) trace_singles=v end)  local trace_multiples=false  trackers.register("otf.multiples",function(v) trace_multiples=v end) @@ -33509,7 +33517,7 @@ if not modules then modules={} end modules ['font-onr']={   license="see context related readme files"  }  local fonts,logs,trackers,resolvers=fonts,logs,trackers,resolvers -local next,type,tonumber,rawget,rawset=next,type,tonumber,rawget,rawset +local next,type,tonumber,rawset=next,type,tonumber,rawset  local match,lower,gsub,strip,find=string.match,string.lower,string.gsub,string.strip,string.find  local char,byte,sub=string.char,string.byte,string.sub  local abs=math.abs  | 
