summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/mkii/cont-new.mkii2
-rw-r--r--tex/context/base/mkii/context.mkii2
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/mult-fun.lua2
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin24912 -> 24895 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin251399 -> 251457 bytes
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl2
-rw-r--r--tex/context/base/mkxl/libs-imp-graphicsmagick.lmt4
-rw-r--r--tex/context/base/mkxl/libs-imp-imagemagick.lmt94
-rw-r--r--tex/context/base/mkxl/libs-imp-zint.lmt4
-rw-r--r--tex/context/base/mkxl/libs-imp-zint.mkxl2
-rw-r--r--tex/context/base/mkxl/lpdf-img.lmt6
-rw-r--r--tex/context/base/mkxl/meta-imp-bitmaps.mkxl307
-rw-r--r--tex/context/base/mkxl/meta-imp-magick.mkxl43
-rw-r--r--tex/context/base/mkxl/spac-ver.lmt695
-rw-r--r--tex/context/base/mkxl/spac-ver.mkxl54
-rw-r--r--tex/context/base/mkxl/syst-ini.mkxl8
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
20 files changed, 883 insertions, 350 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index 8910c2f8c..49c89aecc 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.09.03 18:45}
+\newcontextversion{2021.09.06 11: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 94d3618ff..cbe239ec2 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.09.03 18:45}
+\edef\contextversion{2021.09.06 11:44}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index a85b450ea..e26f62fa3 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.09.03 18:45}
+\newcontextversion{2021.09.06 11:44}
%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 ec6653a3a..3ad868f86 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{2021.09.03 18:45}
+\edef\contextversion{2021.09.06 11:44}
%D Kind of special:
diff --git a/tex/context/base/mkiv/mult-fun.lua b/tex/context/base/mkiv/mult-fun.lua
index 097b906fd..5c982e1db 100644
--- a/tex/context/base/mkiv/mult-fun.lua
+++ b/tex/context/base/mkiv/mult-fun.lua
@@ -193,7 +193,7 @@ return {
"positionwhd", "positionpage", "positionregion", "positionbox", "positionx", "positiony",
"positionanchor", "positioninregion", "positionatanchor",
--
- "getposboxesv, getmultipars",
+ "getposboxes", "getmultipars",
"getpospage", "getposparagraph", "getposcolumn", "getposregion",
"getposx", "getposy", "getposwidth", "getposheight", "getposdepth",
"getposleftskip", "getposrightskip", "getposhsize", "getposparindent", "getposhangindent", "getposhangafter",
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index f91a256e1..9c9066b38 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 8c1e5bbc9..3812c41a2 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl
index bce0320e9..61a039f6b 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.09.03 18:45}
+\newcontextversion{2021.09.06 11:44}
%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 88a3a696d..a923267f2 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.09.03 18:45}
+\immutable\edef\contextversion{2021.09.06 11:44}
%overloadmode 1 % check frozen / warning
%overloadmode 2 % check frozen / error
diff --git a/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt b/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt
index 25a31a1c4..f70261366 100644
--- a/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt
+++ b/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt
@@ -67,9 +67,9 @@ function graphicsmagick.convert(specification)
end
end
-function graphicsmagick.statistics(report)
+function graphicsmagick.statistics(feedback)
local runtime = statistics.elapsedtime(graphicsmagick)
- if report then
+ if feedback then
report("nofruns %s, runtime %s",nofruns,runtime)
else
return {
diff --git a/tex/context/base/mkxl/libs-imp-imagemagick.lmt b/tex/context/base/mkxl/libs-imp-imagemagick.lmt
new file mode 100644
index 000000000..cce632eb3
--- /dev/null
+++ b/tex/context/base/mkxl/libs-imp-imagemagick.lmt
@@ -0,0 +1,94 @@
+if not modules then modules = { } end modules ['libs-imp-imagemagick'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+-- \registerctxluafile{libs-imp-imagemagick}{autosuffix}
+-- \starttext
+-- \startluacode
+-- utilities.imagemagick.convert {
+-- inputname = "hacker.jpg",
+-- outputname = "m_k_v_i_hacker.png",
+-- options = { "-rotate", 90, "-noise", 2 },
+-- }
+-- context.externalfigure { "hacker.png" }
+-- \stopluacode
+-- \stoptext
+
+local libname = "imagemagick"
+local libfile = { "CORE_RL_MagickCore_", "CORE_RL_MagickWand_" }
+
+local imlib = resolvers.libraries.validoptional(libname)
+
+if not imlib then return end
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local imagemagick = utilities.imagemagick or { }
+utilities.imagemagick = imagemagick
+
+local im_execute = imlib.execute
+local nofruns = 0
+local report = logs.reporter(libname)
+
+function imagemagick.convert(specification)
+ if okay() then
+ --
+ nofruns = nofruns + 1
+ statistics.starttiming(imagemagick)
+ --
+ local inputname = specification.inputname
+ if not inputname or inputname == "" then
+ report("invalid run %s, no inputname specified",nofruns)
+ statistics.stoptiming(imagemagick)
+ return false
+ end
+ local outputname = specification.outputname
+ if not outputname or outputname == "" then
+ outputname = file.replacesuffix(inputname,"pdf")
+ end
+ --
+ if not lfs.isfile(inputname) then
+ report("invalid run %s, input file %a is not found",nofruns,inputname)
+ statistics.stoptiming(imagemagick)
+ return false
+ end
+ --
+ report("run %s, input file %a, outputfile %a",nofruns,inputname,outputname)
+ --
+ specification.inputfile = inputname
+ specification.outputfile = outputname
+ --
+ local okay, detail = im_execute(specification)
+ if not okay then
+ report("error %a (make sure options start with one -) ",detail)
+ end
+ --
+ statistics.stoptiming(imagemagick)
+ end
+end
+
+function imagemagick.statistics(feedback)
+ local runtime = statistics.elapsedtime(imagemagick)
+ if feedback then
+ report("nofruns %s, runtime %s",nofruns,runtime)
+ else
+ return {
+ runtime = runtime,
+ nofruns = nofruns,
+ }
+ end
+end
+
+-- imagemagick.convert { inputname = "t:/sources/hacker.jpg", outputname = "e:/tmp/hacker.png" }
+-- imagemagick.statistics(true)
diff --git a/tex/context/base/mkxl/libs-imp-zint.lmt b/tex/context/base/mkxl/libs-imp-zint.lmt
index a7646c436..4558ca58e 100644
--- a/tex/context/base/mkxl/libs-imp-zint.lmt
+++ b/tex/context/base/mkxl/libs-imp-zint.lmt
@@ -113,7 +113,7 @@ local function execute(specification)
local id = mapping[code]
if id then
specification.code = id
- local result = zintlib_execute(specification)
+ local result, detail = zintlib_execute(specification)
if result then
-- not that fast but if needed we can speed it up
context.startMPcode()
@@ -167,6 +167,8 @@ local function execute(specification)
context("% t",strings)
end
context.stopMPcode()
+ else
+ report("something went wrong: %s",detail or "unknown error")
end
else
report("unknown barcode alternative %a",code)
diff --git a/tex/context/base/mkxl/libs-imp-zint.mkxl b/tex/context/base/mkxl/libs-imp-zint.mkxl
index 51b72c68a..208dd9d34 100644
--- a/tex/context/base/mkxl/libs-imp-zint.mkxl
+++ b/tex/context/base/mkxl/libs-imp-zint.mkxl
@@ -22,6 +22,8 @@
%D
%D % e:\tex-context\tex\texmf-win64\bin\lib\luametatex\zint\libzint.dll
+\enabletrackers[*res*]
+
\registerctxluafile{libs-imp-zint}{autosuffix}
\unprotect
diff --git a/tex/context/base/mkxl/lpdf-img.lmt b/tex/context/base/mkxl/lpdf-img.lmt
index 95235959e..ecd154bbf 100644
--- a/tex/context/base/mkxl/lpdf-img.lmt
+++ b/tex/context/base/mkxl/lpdf-img.lmt
@@ -1312,7 +1312,7 @@ do
elseif colorspace == 2 then
colorspace = "DeviceRGB"
elseif colorspace == 3 then
- colorspace = "DeviceCMYK"
+ colorspace = "DeviceCMYK"
end
local colordepth = (specification.colordepth or 2) == 16 or 8
local index = specification.index
@@ -1348,8 +1348,10 @@ do
}
xobject.SMask = pdfreference(pdfflushstreamobject(pack(specification,"mask"),d()))
end
+ local w = specification.width
+ local h = specification.height
return createimage {
- bbox = { 0, 0, specification.width/xsize, specification.height/ysize }, -- mandate
+ bbox = { 0, 0, w and (w/xsize) or xsize, h and (h/ysize) or ysize }, -- mandate
-- nolength = true,
nobbox = true,
notype = true,
diff --git a/tex/context/base/mkxl/meta-imp-bitmaps.mkxl b/tex/context/base/mkxl/meta-imp-bitmaps.mkxl
new file mode 100644
index 000000000..e7846a1e8
--- /dev/null
+++ b/tex/context/base/mkxl/meta-imp-bitmaps.mkxl
@@ -0,0 +1,307 @@
+%D \module
+%D [ file=meta-imp-bitmaps,
+%D version=2021.08.03,
+%D title=\METAPOST\ Graphics,
+%D subtitle=Bitmap Manipulations,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{libs-imp-imagemagick}{autosuffix}
+\registerctxluafile{libs-imp-graphicsmagick}{autosuffix}
+
+% todo: load png directly
+
+\startluacode
+ local char = string.char
+ local concat = table.concat
+ local unpack = unpack
+
+ graphics.bitmaps.magick = "imagemagick"
+
+ function graphics.bitmaps.load(name)
+ local inputname = name
+ local outputname = file.replacesuffix("m_k_i_v_mp_" .. name,"pnm")
+ if file.suffix(inputname) == "pnm" then
+ -- no need to convert
+ else
+ local whattodo = table.setmetatableindex( {
+ inputname = inputname,
+ outputname = outputname,
+ }, specification)
+ utilities[graphics.bitmaps.magick].convert(whattodo)
+ end
+ --
+ local files = utilities.files
+ local f = files.open(outputname)
+ local function read(f)
+ while true do
+ local s = files.readcline(f)
+ if not s then
+ return ""
+ elseif string.find(s,"^#") then
+ -- again
+ else
+ return s
+ end
+ end
+ end
+ local pnm = read(f)
+ local xy = string.split(read(f)," ")
+ local xsize = tonumber(xy[1])
+ local ysize = tonumber(xy[2])
+ local bsize = tonumber(read(f))
+ local bitmap, colorspace
+ if xsize and ysize and bsize then
+ local read = files.readbytetable
+ local data = { }
+ if pnm == "P6" then
+ colorspace = 2 -- rgb
+ for i=1,ysize do
+ local tt = { }
+ for i=1,xsize do
+ tt[i] = read(f,3)
+ end
+ data[i] = tt
+ end
+ elseif pnm == "P5" then
+ colorspace = 1 -- gray
+ for i=1,ysize do
+ data[i] = read(f,xsize)
+ end
+ elseif pnm == "P4" then
+ colorspace = 1
+ -- todo
+ end
+ bitmap = {
+ xsize = xsize,
+ ysize = ysize,
+ bsize = bsize,
+ inputname = inputname,
+ outputname = outputname,
+ colorspace = colorspace,
+ data = data,
+ }
+ end
+ files.close(f)
+ return bitmap
+ end
+
+ function graphics.bitmaps.save(b)
+ local xsize = b.xsize
+ local ysize = b.ysize
+ local bsize = b.bsize
+ local colorspace = b.colorspace
+ if xsize and ysize and bsize then
+ local data = b.data
+ local pnm = nil
+ if colorspace == 2 then
+ pnm = "P6"
+ for i=1,ysize do
+ local t = data[i]
+ for i=1,xsize do
+ t[i] = char(unpack(t[i]))
+ end
+ data[i] = concat(t)
+ end
+ elseif colorspace == 1 then
+ pnm = "P5"
+ if xsize > 1024 then
+ local t = data[i]
+ for i=1,xsize do
+ t[i] = char(t[i])
+ end
+ else
+ for i=1,ysize do
+ data[i] = char(unpack(data[i]))
+ end
+ end
+ else
+ return
+ end
+ local result = concat {
+ pnm .. "\r",
+ xsize .. " " ..
+ ysize .. "\r",
+ bsize .. "\r",
+ concat(data)
+ }
+ local outputname = file.replacesuffix(b.outputname,file.suffix(b.inputname))
+ local inputname = b.outputname
+ io.savedata(inputname,result)
+ --
+ local whattodo = table.setmetatableindex( {
+ inputname = inputname,
+ outputname = outputname,
+ }, specification)
+ utilities[graphics.bitmaps.magick].convert(whattodo)
+ b.finalname = outputname
+ end
+ end
+
+ graphics.bitmaps.manipulators = { }
+
+ function graphics.bitmaps.manipulators.invert(b)
+ local xsize = b.xsize
+ local ysize = b.ysize
+ local data = b.data
+ local colorspace = b.colorspace
+ if colorspace == 1 then
+ for r=1,ysize do
+ local row = data[r]
+ for c=1,xsize do
+ row[c] = 255 - row[c]
+ end
+ end
+ elseif colorspace == 2 then
+ for r=1,ysize do
+ local row = data[r]
+ for c=1,xsize do
+ local column = row[c]
+ column[1] = 255 - column[1]
+ column[2] = 255 - column[2]
+ column[4] = 255 - column[3]
+ end
+ end
+ end
+ end
+
+\stopluacode
+
+\continueifinputfile{meta-imp-bitmaps.mkxl}
+
+\starttext
+
+\startluacode
+
+ local random = math.random
+
+ function graphics.bitmaps.manipulators.myframe(b,f)
+ local xsize = b.xsize
+ local ysize = b.ysize
+ local data = b.data
+ local colorspace = b.colorspace
+ if colorspace == 1 then
+ local f = f or 20
+ local fx = xsize - f + 1
+ local fy = ysize - f + 1
+ for c=1,xsize do
+ for r=1,random(f-5,f+5) do
+ data[r][c] = random(0,255)
+ end
+ for r=ysize,random(fy-5,fy+5),-1 do
+ data[r][c] = random(0,255)
+ end
+ end
+ for r=1,ysize do
+ local row = data[r]
+ for c=1,random(f-5,f+5) do
+ row[c] = random(0,255)
+ end
+ for c=xsize,random(fx-5,fx+5),-1 do
+ row[c] = random(0,255)
+ end
+ end
+ elseif colorspace == 2 then
+ local f = f or 20
+ local fx = xsize - f + 1
+ local fy = ysize - f + 1
+ for c=1,xsize do
+ for r=1,random(f-5,f+5) do
+ local v = random(0,255)
+ data[r][c] = { v, v, v }
+ end
+ for r=ysize,random(fy-5,fy+5),-1 do
+ local v = random(0,255)
+ data[r][c] = { v, v, v }
+ end
+ end
+ for r=1,ysize do
+ local row = data[r]
+ for c=1,random(f-5,f+5) do
+ local v = random(0,255)
+ row[c] = { v, v, v }
+ end
+ for c=xsize,random(fx-5,fx+5),-1 do
+ local v = random(0,255)
+ row[c] = { v, v, v }
+ end
+ end
+ end
+ end
+
+ function graphics.bitmaps.manipulators.colorize(b,m)
+ local xsize = b.xsize
+ local ysize = b.ysize
+ local data = b.data
+ local colorspace = b.colorspace
+ if colorspace == 1 then
+ for r=1,ysize do
+ local row = data[r]
+ for c=1,xsize do
+ local v = row[c]
+ row[c] = m[v] or { v, v, v }
+ end
+ end
+ b.colorspace = 2
+ end
+ end
+
+ context.startTEXpage()
+ local b = graphics.bitmaps.load("hacker.jpg")
+ graphics.bitmaps.manipulators.myframe(b,20)
+ graphics.bitmaps.save(b)
+ context.externalfigure { b.finalname }
+ context.stopTEXpage()
+
+ context.startTEXpage()
+ local b = graphics.bitmaps.load("mill.png")
+ graphics.bitmaps.manipulators.invert(b)
+ graphics.bitmaps.manipulators.myframe(b,20)
+ graphics.bitmaps.tocontext(b,50*65536,nil)
+ context.stopTEXpage()
+
+ local m = table.setmetatableindex(function(t,k) local v = { k, k, k } t[k] = v return v end)
+
+-- local c = { 255, 0, 0 } for i=0x00,0x1F do m[i] = c end
+-- local c = { 0, 255, 0 } for i=0x20,0x3F do m[i] = c end
+ local c = { 0, 0, 255 } for i=0x40,0x5F do m[i] = c end
+-- local c = { 255, 255, 0 } for i=0x60,0x7F do m[i] = c end
+-- local c = { 255, 0, 255 } for i=0x80,0x9F do m[i] = c end
+-- local c = { 0, 255, 255 } for i=0xA0,0xBF do m[i] = c end
+-- local c = { 255, 255, 255 } for i=0xC0,0xDF do m[i] = c end
+-- local c = { 0, 0, 0 } for i=0xE0,0xFF do m[i] = c end
+
+ context.startTEXpage()
+ local b = graphics.bitmaps.load("mill.png")
+ graphics.bitmaps.manipulators.colorize(b,m)
+ graphics.bitmaps.tocontext(b,50*65536,nil)
+ context.stopTEXpage()
+
+\stopluacode
+
+\protected\def\MyImage#1{\ctxlua{
+ local b = graphics.bitmaps.load("#1")
+ graphics.bitmaps.manipulators.invert(b)
+ graphics.bitmaps.manipulators.myframe(b,20)
+ graphics.bitmaps.tocontext(b,50*65536,nil)
+}}
+
+\startMPpage
+
+ picture p ; p := textext("\MyImage{mill.png}") ;
+
+ draw p ;
+ draw (boundingbox p) enlarged -.5mm
+ withpen pensquare scaled 1mm
+ withcolor "darkred"
+ withtransparency (1,.5)
+ ;
+
+\stopMPpage
+
+\stoptext
diff --git a/tex/context/base/mkxl/meta-imp-magick.mkxl b/tex/context/base/mkxl/meta-imp-magick.mkxl
index 89b2ef4ec..1adc7be83 100644
--- a/tex/context/base/mkxl/meta-imp-magick.mkxl
+++ b/tex/context/base/mkxl/meta-imp-magick.mkxl
@@ -12,23 +12,38 @@
%C details.
\registerctxluafile{libs-imp-graphicsmagick}{autosuffix}
+\registerctxluafile{libs-imp-imagemagick}{autosuffix}
\startluacode
+ local converters = {
+ im = "imagemagick",
+ imagemagick = "imagemagick",
+ magick = "imagemagick",
+ }
+
+ local frozen = false
+ local convert = false
+
+ -- for some reason we cannot load both libraries
+
function mp.lmt_magick_convert()
local specification = metapost.getparameterset("magick")
local inputname = specification.filename
if inputname then
-- we don't want to trigger reuse when we have the same input file
- local hash = md5.HEX(table.sequenced(specification))
+ local hash = md5.HEX(table.sequenced(specification))
local outputname = file.addsuffix("m_k_i_v_mp_fuzzy_" .. hash,file.suffix(inputname))
- luatex.registertempfile(outputname)
-- make the table a bit unique and don't polute it
- local whattodo = table.setmetatableindex( {
+ local whattodo = table.setmetatableindex( {
inputname = inputname,
outputname = outputname,
}, specification)
+ luatex.registertempfile(outputname)
-- now do the magick
- utilities.graphicsmagick.convert(whattodo)
+ if not convert then
+ convert = utilities[converters[specification.converter or "gm"] or "graphicsmagick"].convert
+ end
+ convert(whattodo)
-- and return the result
return [[figure("]] .. outputname .. [[")]]
else
@@ -57,21 +72,37 @@
\enabletrackers[*lib*]
\startMPpage
+ presetparameters "magick" [
+ converter = "magick", % comment / uncomment
+ ] ;
+ draw lmt_magick [
+ filename = "hacker.jpg",
+ % for im
+ options = { "-rotate", 180 },
+ ] ysized 4cm ;
+
draw lmt_magick [
filename = "hacker.jpg",
+ % for gm
blur = [ radius = 10, sigma = 5 ],
noise = [ type = 2 ],
- ] ysized 4cm ;
+ % for gm
+ options = { "-noise", 2 },
+ ] ysized 4cm shifted (8cm, -4cm) ;
draw lmt_magick [
filename = "hacker.jpg",
+ % for gm
blur = [ radius = 5, sigma = 3 ],
noise = [ type = 4 ],
+ % for gm
+ options = { "-noise", 4 },
] ysized 4cm shifted (0, -4cm) ;
draw lmt_magick [
filename = "hacker.jpg",
blur = [ radius = 10, sigma = 5 ],
+ % for gm
noise = [ type = 4 ],
- ] ysized 4cm shifted (0, -8cm) ;
+ ] ysized 4cm shifted (8cm, 0cm) ;
\stopMPpage
diff --git a/tex/context/base/mkxl/spac-ver.lmt b/tex/context/base/mkxl/spac-ver.lmt
index cae0f1d78..26ad8e43a 100644
--- a/tex/context/base/mkxl/spac-ver.lmt
+++ b/tex/context/base/mkxl/spac-ver.lmt
@@ -81,8 +81,8 @@ local v_first = variables.first
local v_last = variables.last
local v_top = variables.top
local v_bottom = variables.bottom
-local v_minheight = variables.minheight
local v_maxheight = variables.maxheight
+local v_minheight = variables.minheight
local v_mindepth = variables.mindepth
local v_maxdepth = variables.maxdepth
local v_offset = variables.offset
@@ -127,7 +127,6 @@ local getid = nuts.getid
local getlist = nuts.getlist
local setlist = nuts.setlist
local getattr = nuts.getattr
-local getattrs = nuts.getattrs
local setattr = nuts.setattr
local getsubtype = nuts.getsubtype
local getbox = nuts.getbox
@@ -164,8 +163,6 @@ local nexthlist = nuts.traversers.hlist
local nodereference = nuts.reference
-local theprop = nuts.theprop
-
local listtoutf = nodes.listtoutf
local nodeidstostring = nodes.idstostring
@@ -352,339 +349,343 @@ local function already_done(parentid,list,a_snapmethod) -- todo: done when only
return false
end
--- quite tricky: ceil(-something) => -0
+-- check variables.none etc
-local function ceiled(n)
- if n < 0 or n < 0.01 then
- return 0
- else
- return ceil(n)
- end
-end
+local snap_hlist do
-local function floored(n)
- if n < 0 or n < 0.01 then
- return 0
- else
- return floor(n)
+ local function fixedprofile(current)
+ local profiling = builders.profiling
+ return profiling and profiling.fixedprofile(current)
end
-end
--- check variables.none etc
+ -- quite tricky: ceil(-something) => -0
-local function fixedprofile(current)
- local profiling = builders.profiling
- return profiling and profiling.fixedprofile(current)
-end
-
-local function snap_hlist(where,current,method,height,depth) -- method[v_strut] is default
- if fixedprofile(current) then
- return
- end
- local list = getlist(current)
- local t = trace_vsnapping and { }
- if t then
- t[#t+1] = formatters["list content: %s"](listtoutf(list))
- t[#t+1] = formatters["snap method: %s"](method.name) -- not interfaced
- t[#t+1] = formatters["specification: %s"](method.specification) -- not interfaced
- end
- local snapht, snapdp
- if method[v_local] then
- -- snapping is done immediately here
- snapht = texgetdimen("bodyfontstrutheight")
- snapdp = texgetdimen("bodyfontstrutdepth")
- if t then
- t[#t+1] = formatters["local: snapht %p snapdp %p"](snapht,snapdp)
- end
- elseif method[v_global] then
- snapht = texgetdimen("globalbodyfontstrutheight")
- snapdp = texgetdimen("globalbodyfontstrutdepth")
- if t then
- t[#t+1] = formatters["global: snapht %p snapdp %p"](snapht,snapdp)
- end
- else
- -- maybe autolocal
- -- snapping might happen later in the otr
- snapht = texgetdimen("globalbodyfontstrutheight")
- snapdp = texgetdimen("globalbodyfontstrutdepth")
- local lsnapht = texgetdimen("bodyfontstrutheight")
- local lsnapdp = texgetdimen("bodyfontstrutdepth")
- if snapht ~= lsnapht and snapdp ~= lsnapdp then
- snapht, snapdp = lsnapht, lsnapdp
- end
- if t then
- t[#t+1] = formatters["auto: snapht %p snapdp %p"](snapht,snapdp)
+ local function ceiled(n)
+ if n < 0 or n < 0.01 then
+ return 0
+ else
+ return ceil(n)
end
end
- local wd, ht, dp = getwhd(current)
-
- local h = (method[v_noheight] and 0) or height or ht
- local d = (method[v_nodepth] and 0) or depth or dp
- local hr = method[v_hfraction] or 1
- local dr = method[v_dfraction] or 1
- local br = method[v_bfraction] or 0
- local ch = h
- local cd = d
- local tlines = method[v_tlines] or 1
- local blines = method[v_blines] or 1
- local done = false
- local plusht = snapht
- local plusdp = snapdp
- local snaphtdp = snapht + snapdp
- local extra = 0
-
- if t then
- t[#t+1] = formatters["hlist: wd %p ht %p (used %p) dp %p (used %p)"](wd,ht,h,dp,d)
- t[#t+1] = formatters["fractions: hfraction %s dfraction %s bfraction %s tlines %s blines %s"](hr,dr,br,tlines,blines)
+ local function floored(n)
+ if n < 0 or n < 0.01 then
+ return 0
+ else
+ return floor(n)
+ end
end
- if method[v_box] then
- local br = 1 - br
- if br < 0 then
- br = 0
- elseif br > 1 then
- br = 1
- end
- local n = ceiled((h+d-br*snapht-br*snapdp)/snaphtdp)
- local x = n * snaphtdp - h - d
- plusht = h + x / 2
- plusdp = d + x / 2
+ snap_hlist = function(where,current,method,height,depth) -- method[v_strut] is default
+ if fixedprofile(current) then
+ return
+ end
+ local list = getlist(current)
+ local t = trace_vsnapping and { }
if t then
- t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_box,plusht,plusdp)
+ t[#t+1] = formatters["list content: %s"](listtoutf(list))
+ t[#t+1] = formatters["snap method: %s"](method.name) -- not interfaced
+ t[#t+1] = formatters["specification: %s"](method.specification) -- not interfaced
+ end
+ local snapht, snapdp
+ if method[v_local] then
+ -- snapping is done immediately here
+ snapht = texgetdimen("bodyfontstrutheight")
+ snapdp = texgetdimen("bodyfontstrutdepth")
+ if t then
+ t[#t+1] = formatters["local: snapht %p snapdp %p"](snapht,snapdp)
+ end
+ elseif method[v_global] then
+ snapht = texgetdimen("globalbodyfontstrutheight")
+ snapdp = texgetdimen("globalbodyfontstrutdepth")
+ if t then
+ t[#t+1] = formatters["global: snapht %p snapdp %p"](snapht,snapdp)
+ end
+ else
+ -- maybe autolocal
+ -- snapping might happen later in the otr
+ snapht = texgetdimen("globalbodyfontstrutheight")
+ snapdp = texgetdimen("globalbodyfontstrutdepth")
+ local lsnapht = texgetdimen("bodyfontstrutheight")
+ local lsnapdp = texgetdimen("bodyfontstrutdepth")
+ if snapht ~= lsnapht and snapdp ~= lsnapdp then
+ snapht, snapdp = lsnapht, lsnapdp
+ end
+ if t then
+ t[#t+1] = formatters["auto: snapht %p snapdp %p"](snapht,snapdp)
+ end
end
- elseif method[v_max] then
- local n = ceiled((h+d)/snaphtdp)
- local x = n * snaphtdp - h - d
- plusht = h + x / 2
- plusdp = d + x / 2
+
+ local wd, ht, dp = getwhd(current)
+
+ local h = (method[v_noheight] and 0) or height or ht
+ local d = (method[v_nodepth] and 0) or depth or dp
+ local hr = method[v_hfraction] or 1
+ local dr = method[v_dfraction] or 1
+ local br = method[v_bfraction] or 0
+ local ch = h
+ local cd = d
+ local tlines = method[v_tlines] or 1
+ local blines = method[v_blines] or 1
+ local done = false
+ local plusht = snapht
+ local plusdp = snapdp
+ local snaphtdp = snapht + snapdp
+ local extra = 0
+
if t then
- t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_max,plusht,plusdp)
+ t[#t+1] = formatters["hlist: wd %p ht %p (used %p) dp %p (used %p)"](wd,ht,h,dp,d)
+ t[#t+1] = formatters["fractions: hfraction %s dfraction %s bfraction %s tlines %s blines %s"](hr,dr,br,tlines,blines)
end
- elseif method[v_min] then
- -- we catch a lone min
- if method.specification ~= v_min then
- local n = floored((h+d)/snaphtdp)
+
+ if method[v_box] then
+ local br = 1 - br
+ if br < 0 then
+ br = 0
+ elseif br > 1 then
+ br = 1
+ end
+ local n = ceiled((h+d-br*snapht-br*snapdp)/snaphtdp)
local x = n * snaphtdp - h - d
plusht = h + x / 2
plusdp = d + x / 2
- if plusht < 0 then
- plusht = 0
+ if t then
+ t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_box,plusht,plusdp)
end
- if plusdp < 0 then
- plusdp = 0
+ elseif method[v_max] then
+ local n = ceiled((h+d)/snaphtdp)
+ local x = n * snaphtdp - h - d
+ plusht = h + x / 2
+ plusdp = d + x / 2
+ if t then
+ t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_max,plusht,plusdp)
+ end
+ elseif method[v_min] then
+ -- we catch a lone min
+ if method.specification ~= v_min then
+ local n = floored((h+d)/snaphtdp)
+ local x = n * snaphtdp - h - d
+ plusht = h + x / 2
+ plusdp = d + x / 2
+ if plusht < 0 then
+ plusht = 0
+ end
+ if plusdp < 0 then
+ plusdp = 0
+ end
+ end
+ if t then
+ t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_min,plusht,plusdp)
+ end
+ elseif method[v_none] then
+ plusht, plusdp = 0, 0
+ if t then
+ t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_none,0,0)
end
end
- if t then
- t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_min,plusht,plusdp)
- end
- elseif method[v_none] then
- plusht, plusdp = 0, 0
- if t then
- t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_none,0,0)
- end
- end
- -- for now, we actually need to tag a box and then check at several points if something ended up
- -- at the top of a page
- if method[v_halfline] then -- extra halfline
- extra = snaphtdp/2
- plusht = plusht + extra
- plusdp = plusdp + extra
- if t then
- t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_halfline,plusht,plusdp)
+ -- for now, we actually need to tag a box and then check at several points if something ended up
+ -- at the top of a page
+ if method[v_halfline] then -- extra halfline
+ extra = snaphtdp/2
+ plusht = plusht + extra
+ plusdp = plusdp + extra
+ if t then
+ t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_halfline,plusht,plusdp)
+ end
end
- end
- if method[v_line] then -- extra line
- extra = snaphtdp
- plusht = plusht + extra
- plusdp = plusdp + extra
- if t then
- t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_line,plusht,plusdp)
+ if method[v_line] then -- extra line
+ extra = snaphtdp
+ plusht = plusht + extra
+ plusdp = plusdp + extra
+ if t then
+ t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_line,plusht,plusdp)
+ end
end
- end
- if method[v_halfline_m] then -- extra halfline
- extra = - snaphtdp/2
- plusht = plusht + extra
- plusdp = plusdp + extra
- if t then
- t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_halfline_m,plusht,plusdp)
+ if method[v_halfline_m] then -- extra halfline
+ extra = - snaphtdp/2
+ plusht = plusht + extra
+ plusdp = plusdp + extra
+ if t then
+ t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_halfline_m,plusht,plusdp)
+ end
end
- end
- if method[v_line_m] then -- extra line
- extra = - snaphtdp
- plusht = plusht + extra
- plusdp = plusdp + extra
- if t then
- t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_line_m,plusht,plusdp)
+ if method[v_line_m] then -- extra line
+ extra = - snaphtdp
+ plusht = plusht + extra
+ plusdp = plusdp + extra
+ if t then
+ t[#t+1] = formatters["%s: plusht %p plusdp %p"](v_line_m,plusht,plusdp)
+ end
end
- end
- if method[v_first] then
- local thebox = current
- local id = getid(thebox)
- if id == hlist_code then
- thebox = validvbox(id,getlist(thebox))
- id = thebox and getid(thebox)
- end
- if thebox and id == vlist_code then
- local list = getlist(thebox)
- local lw, lh, ld
- for n in nexthlist, list do
- lw, lh, ld = getwhd(n)
- break
+ if method[v_first] then
+ local thebox = current
+ local id = getid(thebox)
+ if id == hlist_code then
+ thebox = validvbox(id,getlist(thebox))
+ id = thebox and getid(thebox)
end
- if lh then
- local wd, ht, dp = getwhd(thebox)
- if t then
- t[#t+1] = formatters["first line: height %p depth %p"](lh,ld)
- t[#t+1] = formatters["dimensions: height %p depth %p"](ht,dp)
+ if thebox and id == vlist_code then
+ local list = getlist(thebox)
+ local lw, lh, ld
+ for n in nexthlist, list do
+ lw, lh, ld = getwhd(n)
+ break
end
- local delta = h - lh
- ch, cd = lh, delta + d
- h, d = ch, cd
- local shifted = hpack_node(getlist(current))
- setshift(shifted,delta)
- setlist(current,shifted)
- done = true
- if t then
- t[#t+1] = formatters["first: height %p depth %p shift %p"](ch,cd,delta)
+ if lh then
+ local wd, ht, dp = getwhd(thebox)
+ if t then
+ t[#t+1] = formatters["first line: height %p depth %p"](lh,ld)
+ t[#t+1] = formatters["dimensions: height %p depth %p"](ht,dp)
+ end
+ local delta = h - lh
+ ch, cd = lh, delta + d
+ h, d = ch, cd
+ local shifted = hpack_node(getlist(current))
+ setshift(shifted,delta)
+ setlist(current,shifted)
+ done = true
+ if t then
+ t[#t+1] = formatters["first: height %p depth %p shift %p"](ch,cd,delta)
+ end
+ elseif t then
+ t[#t+1] = "first: not done, no content"
end
elseif t then
- t[#t+1] = "first: not done, no content"
- end
- elseif t then
- t[#t+1] = "first: not done, no vbox"
- end
- elseif method[v_last] then
- local thebox = current
- local id = getid(thebox)
- if id == hlist_code then
- thebox = validvbox(id,getlist(thebox))
- id = thebox and getid(thebox)
- end
- if thebox and id == vlist_code then
- local list = getlist(thebox)
- local lw, lh, ld
- for n in nexthlist, list do
- lw, lh, ld = getwhd(n)
- end
- if lh then
- local wd, ht, dp = getwhd(thebox)
- if t then
- t[#t+1] = formatters["last line: height %p depth %p" ](lh,ld)
- t[#t+1] = formatters["dimensions: height %p depth %p"](ht,dp)
+ t[#t+1] = "first: not done, no vbox"
+ end
+ elseif method[v_last] then
+ local thebox = current
+ local id = getid(thebox)
+ if id == hlist_code then
+ thebox = validvbox(id,getlist(thebox))
+ id = thebox and getid(thebox)
+ end
+ if thebox and id == vlist_code then
+ local list = getlist(thebox)
+ local lw, lh, ld
+ for n in nexthlist, list do
+ lw, lh, ld = getwhd(n)
end
- local delta = d - ld
- cd, ch = ld, delta + h
- h, d = ch, cd
- local shifted = hpack_node(getlist(current))
- setshift(shifted,delta)
- setlist(current,shifted)
- done = true
- if t then
- t[#t+1] = formatters["last: height %p depth %p shift %p"](ch,cd,delta)
+ if lh then
+ local wd, ht, dp = getwhd(thebox)
+ if t then
+ t[#t+1] = formatters["last line: height %p depth %p" ](lh,ld)
+ t[#t+1] = formatters["dimensions: height %p depth %p"](ht,dp)
+ end
+ local delta = d - ld
+ cd, ch = ld, delta + h
+ h, d = ch, cd
+ local shifted = hpack_node(getlist(current))
+ setshift(shifted,delta)
+ setlist(current,shifted)
+ done = true
+ if t then
+ t[#t+1] = formatters["last: height %p depth %p shift %p"](ch,cd,delta)
+ end
+ elseif t then
+ t[#t+1] = "last: not done, no content"
end
elseif t then
- t[#t+1] = "last: not done, no content"
+ t[#t+1] = "last: not done, no vbox"
end
- elseif t then
- t[#t+1] = "last: not done, no vbox"
- end
- end
- if method[v_minheight] then
- ch = floored((h-hr*snapht)/snaphtdp)*snaphtdp + plusht
- if t then
- t[#t+1] = formatters["minheight: %p"](ch)
- end
- elseif method[v_maxheight] then
- ch = ceiled((h-hr*snapht)/snaphtdp)*snaphtdp + plusht
- if t then
- t[#t+1] = formatters["maxheight: %p"](ch)
end
- else
- ch = plusht
- if t then
- t[#t+1] = formatters["set height: %p"](ch)
+ if method[v_minheight] then
+ ch = floored((h-hr*snapht)/snaphtdp)*snaphtdp + plusht
+ if t then
+ t[#t+1] = formatters["minheight: %p"](ch)
+ end
+ elseif method[v_maxheight] then
+ ch = ceiled((h-hr*snapht)/snaphtdp)*snaphtdp + plusht
+ if t then
+ t[#t+1] = formatters["maxheight: %p"](ch)
+ end
+ else
+ ch = plusht
+ if t then
+ t[#t+1] = formatters["set height: %p"](ch)
+ end
end
- end
- if method[v_mindepth] then
- cd = floored((d-dr*snapdp)/snaphtdp)*snaphtdp + plusdp
- if t then
- t[#t+1] = formatters["mindepth: %p"](cd)
+ if method[v_mindepth] then
+ cd = floored((d-dr*snapdp)/snaphtdp)*snaphtdp + plusdp
+ if t then
+ t[#t+1] = formatters["mindepth: %p"](cd)
+ end
+ elseif method[v_maxdepth] then
+ cd = ceiled((d-dr*snapdp)/snaphtdp)*snaphtdp + plusdp
+ if t then
+ t[#t+1] = formatters["maxdepth: %p"](cd)
+ end
+ else
+ cd = plusdp
+ if t then
+ t[#t+1] = formatters["set depth: %p"](cd)
+ end
end
- elseif method[v_maxdepth] then
- cd = ceiled((d-dr*snapdp)/snaphtdp)*snaphtdp + plusdp
- if t then
- t[#t+1] = formatters["maxdepth: %p"](cd)
+ if method[v_top] then
+ ch = ch + tlines * snaphtdp
+ if t then
+ t[#t+1] = formatters["top height: %p"](ch)
+ end
end
- else
- cd = plusdp
- if t then
- t[#t+1] = formatters["set depth: %p"](cd)
+ if method[v_bottom] then
+ cd = cd + blines * snaphtdp
+ if t then
+ t[#t+1] = formatters["bottom depth: %p"](cd)
+ end
end
- end
- if method[v_top] then
- ch = ch + tlines * snaphtdp
- if t then
- t[#t+1] = formatters["top height: %p"](ch)
+ local offset = method[v_offset]
+ if offset then
+ -- we need to set the attr
+ if t then
+ local wd, ht, dp = getwhd(current)
+ t[#t+1] = formatters["before offset: %p (width %p height %p depth %p)"](offset,wd,ht,dp)
+ end
+ local shifted = hpack_node(getlist(current))
+ setshift(shifted,offset)
+ setlist(current,shifted)
+ if t then
+ local wd, ht, dp = getwhd(current)
+ t[#t+1] = formatters["after offset: %p (width %p height %p depth %p)"](offset,wd,ht,dp)
+ end
+ setattr(shifted,a_snapmethod,0)
+ setattr(current,a_snapmethod,0)
end
- end
- if method[v_bottom] then
- cd = cd + blines * snaphtdp
- if t then
- t[#t+1] = formatters["bottom depth: %p"](cd)
+ if not height then
+ setheight(current,ch)
+ if t then
+ t[#t+1] = formatters["forced height: %p"](ch)
+ end
end
- end
- local offset = method[v_offset]
- if offset then
- -- we need to set the attr
- if t then
- local wd, ht, dp = getwhd(current)
- t[#t+1] = formatters["before offset: %p (width %p height %p depth %p)"](offset,wd,ht,dp)
+ if not depth then
+ setdepth(current,cd)
+ if t then
+ t[#t+1] = formatters["forced depth: %p"](cd)
+ end
end
- local shifted = hpack_node(getlist(current))
- setshift(shifted,offset)
- setlist(current,shifted)
+ local lines = (ch+cd)/snaphtdp
if t then
- local wd, ht, dp = getwhd(current)
- t[#t+1] = formatters["after offset: %p (width %p height %p depth %p)"](offset,wd,ht,dp)
+ local original = (h+d)/snaphtdp
+ local whatever = (ch+cd)/(texgetdimen("globalbodyfontstrutheight") + texgetdimen("globalbodyfontstrutdepth"))
+ t[#t+1] = formatters["final lines : %p -> %p (%p)"](original,lines,whatever)
+ t[#t+1] = formatters["final height: %p -> %p"](h,ch)
+ t[#t+1] = formatters["final depth : %p -> %p"](d,cd)
end
- setattr(shifted,a_snapmethod,0)
- setattr(current,a_snapmethod,0)
- end
- if not height then
- setheight(current,ch)
+ -- todo:
+ --
+ -- if h < 0 or d < 0 then
+ -- h = 0
+ -- d = 0
+ -- end
if t then
- t[#t+1] = formatters["forced height: %p"](ch)
+ report_snapper("trace: %s type %s\n\t%\n\tt",where,nodecodes[getid(current)],t)
end
- end
- if not depth then
- setdepth(current,cd)
- if t then
- t[#t+1] = formatters["forced depth: %p"](cd)
+ if not method[v_split] then
+ -- so extra will not be compensated at the top of a page
+ extra = 0
end
+ return h, d, ch, cd, lines, extra
end
- local lines = (ch+cd)/snaphtdp
- if t then
- local original = (h+d)/snaphtdp
- local whatever = (ch+cd)/(texgetdimen("globalbodyfontstrutheight") + texgetdimen("globalbodyfontstrutdepth"))
- t[#t+1] = formatters["final lines : %p -> %p (%p)"](original,lines,whatever)
- t[#t+1] = formatters["final height: %p -> %p"](h,ch)
- t[#t+1] = formatters["final depth : %p -> %p"](d,cd)
- end
--- todo:
---
--- if h < 0 or d < 0 then
--- h = 0
--- d = 0
--- end
- if t then
- report_snapper("trace: %s type %s\n\t%\n\tt",where,nodecodes[getid(current)],t)
- end
- if not method[v_split] then
- -- so extra will not be compensated at the top of a page
- extra = 0
- end
- return h, d, ch, cd, lines, extra
+
end
local categories = { [0] =
@@ -732,6 +733,95 @@ vspacingdata.skip = vspacingdata.skip or { } -- allocate ?
storage.register("builders/vspacing/data/map", vspacingdata.map, "builders.vspacing.data.map")
storage.register("builders/vspacing/data/skip", vspacingdata.skip, "builders.vspacing.data.skip")
+local setspecification, getspecification
+
+-- attributes : more overhead : feels faster than properties
+-- properties : more natural : feels slower than attributes
+-- data : more native : is little faster than attributes
+
+if true then
+-- if false then
+
+ -- quite okay but more memory due to attributes (not many)
+
+ local setattrs = nuts.setattrs
+ local getattrs = nuts.getattrs
+
+ setspecification = function(n,category,penalty,order)
+ setattrs(n,false,a_skipcategory,category,a_skippenalty,penalty,a_skiporder,order or 1)
+ end
+
+ getspecification = function(n)
+ return getattrs(n,a_skipcategory,a_skippenalty,a_skiporder)
+ end
+
+-- elseif true then
+elseif false then
+
+ -- more natural as we stay in lua
+
+ setspecification = function(n,category,penalty,order)
+ -- we know that there are no properties
+ properties[n] = {
+ [a_skipcategory] = category,
+ [a_skippenalty] = penalty,
+ [a_skiporder] = order or 1,
+ }
+ end
+
+ getspecification = function(n)
+ local p = properties[n]
+ if p then
+ return p[a_skipcategory], p[a_skippenalty], p[a_skiporder]
+ end
+ end
+
+else
+
+ -- quite efficient but needs testing because we limit values
+
+ local getdata = nuts.getdata
+ local setdata = nuts.setdata
+
+ setspecification = function(n,category,penalty,order)
+ if not category or category > 0xF then
+ category = 0xF
+ end
+ if not order or order > 0xFF then
+ order = 0xFF
+ end
+ if not penalty or penalty > 0x7FFFF then
+ penalty = 0x7FFFF
+ elseif penalty < -0x7FFFF then
+ penalty = -0x7FFFF
+ end
+ -- we need overflow checks
+ setdata(n, (penalty << 12) + (order << 4) + category)
+ end
+
+ getspecification = function(n)
+ local data = getdata(n)
+ if data and data ~= 0 then
+ local category = data & 0x0F
+ local order = (data >> 4) & 0xFF
+ local penalty = data >> 12
+ if category == 0xF then
+ category = nil
+ end
+ if order == 0xFF then
+ order = nil
+ end
+ if penalty == 0x7FFFF then
+ penalty = nil
+ end
+ return category, penalty, order
+ else
+ return nil, nil, nil
+ end
+ end
+
+end
+
do
local P, C, R, S, Cc, Cs = lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.Cc, lpeg.Cs
@@ -773,8 +863,6 @@ do
-- local settoks = tex.settoks
local toscaled = tex.toscaled
- local setattrs = nuts.setattrs
-
local b_done = false
local b_packed = false
@@ -819,7 +907,7 @@ do
local function inject()
local n = new_glue(b_amount,b_stretch,b_shrink)
- setattrs(n,false,a_skipcategory,b_category,a_skippenalty,b_penalty,a_skiporder,b_order or 1)
+ setspecification(n,b_category,b_penalty,b_order or 1)
write_node(n)
end
@@ -943,19 +1031,22 @@ do
function vspacing.injectpenalty(penalty)
local n = new_glue()
- setattrs(n,false,a_skipcategory,categories.penalty,a_skippenalty,penalty,a_skiporder,1)
+ -- setattrs(n,false,a_skipcategory,categories.penalty,a_skippenalty,penalty,a_skiporder,1)
+ setspecification(n,categories.penalty,penalty,1)
write_node(n)
end
function vspacing.injectskip(amount)
local n = new_glue(amount)
- setattrs(n,false,a_skipcategory,categories.largest,a_skippenalty,false,a_skiporder,1)
+ -- setattrs(n,false,a_skipcategory,categories.largest,a_skippenalty,false,a_skiporder,1)
+ setspecification(n,categories.largest,false,1)
write_node(n)
end
function vspacing.injectdisable(amount)
local n = new_glue()
- setattrs(n,false,a_skipcategory,categories.disable,a_skippenalty,false,a_skiporder,1)
+ -- setattrs(n,false,a_skipcategory,categories.disable,a_skippenalty,false,a_skiporder,1)
+ setspecification(n,categories.disable,false,1)
write_node(n)
end
@@ -1615,7 +1706,8 @@ do
elseif id == glue_code then
local subtype = getsubtype(current)
if subtype == userskip_code then
- local sc, so, sp = getattrs(current,a_skipcategory,a_skiporder,a_skippenalty)
+ -- local sc, so, sp = getattrs(current,a_skipcategory,a_skiporder,a_skippenalty)
+ local sc, sp, so = getspecification(current)
if not so then
so = 1 -- the others have no default value
end
@@ -1877,7 +1969,8 @@ do
end
elseif subtype == topskip_code or subtype == splittopskip_code then
local next = getnext(current)
- if next and getattr(next,a_skipcategory) == notopskip then
+ -- if next and getattr(next,a_skipcategory) == notopskip then
+ if next and getspecification(next) == notopskip then
nuts.setglue(current) -- zero
end
if snap then
@@ -2034,7 +2127,9 @@ setnext(glue_data)
if id ~= glue_code then
flush = true
elseif subtype == userskip_code then
- if getattr(n,a_skipcategory) then
+ -- local sc = getattr(n,a_skipcategory)
+ local sc = getspecification(n)
+ if sc then
stackhack = true
else
flush = true
diff --git a/tex/context/base/mkxl/spac-ver.mkxl b/tex/context/base/mkxl/spac-ver.mkxl
index 82f0d40d1..30455bf2b 100644
--- a/tex/context/base/mkxl/spac-ver.mkxl
+++ b/tex/context/base/mkxl/spac-ver.mkxl
@@ -1928,33 +1928,33 @@
%D The injector code (generated at the \LUA\ end). This will go away!
-\newtoks\everybeforeblankhandling
-\newtoks\everyafterblankhandling
-
-\newconditional\c_space_vspacing_done
-\newconditional\c_space_vspacing_fixed
-\newconditional\c_space_ignore_parskip
-
-\appendtoks
- \s_spac_vspacing_temp\zeropoint
- \c_attr_skipcategory\plusone
- \c_attr_skippenalty \attributeunsetvalue
- \c_attr_skiporder \attributeunsetvalue
- \ifgridsnapping
- \settrue\c_space_vspacing_fixed
- \else
- \setfalse\c_space_vspacing_fixed
- \fi
-\to \everybeforeblankhandling
-
-\appendtoks
- \s_spac_vspacing_temp\plusone\s_spac_vspacing_temp
- \ifconditional\c_space_vspacing_fixed \else
- \s!plus \skipgluefactor\s_spac_vspacing_temp
- \s!minus\skipgluefactor\s_spac_vspacing_temp
- \fi
- \relax
-\to \everyafterblankhandling
+% \newtoks\everybeforeblankhandling
+% \newtoks\everyafterblankhandling
+%
+% \newconditional\c_space_vspacing_done
+% \newconditional\c_space_vspacing_fixed
+% \newconditional\c_space_ignore_parskip
+%
+% \appendtoks
+% \s_spac_vspacing_temp\zeropoint
+% \c_attr_skipcategory\plusone
+% \c_attr_skippenalty \attributeunsetvalue
+% \c_attr_skiporder \attributeunsetvalue
+% \ifgridsnapping
+% \settrue\c_space_vspacing_fixed
+% \else
+% \setfalse\c_space_vspacing_fixed
+% \fi
+% \to \everybeforeblankhandling
+%
+% \appendtoks
+% \s_spac_vspacing_temp\plusone\s_spac_vspacing_temp
+% \ifconditional\c_space_vspacing_fixed \else
+% \s!plus \skipgluefactor\s_spac_vspacing_temp
+% \s!minus\skipgluefactor\s_spac_vspacing_temp
+% \fi
+% \relax
+% \to \everyafterblankhandling
% The main spacer:
diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl
index a2a1aed0f..911d0144b 100644
--- a/tex/context/base/mkxl/syst-ini.mkxl
+++ b/tex/context/base/mkxl/syst-ini.mkxl
@@ -1227,10 +1227,10 @@
%D Often used as cs key:
-\mutable\let\on \empty
-\mutable\let\of \empty
-\mutable\let\and \empty
-\mutable\let\with\empty
+\mutable\let\on \relax % \empty
+\mutable\let\of \relax % \empty
+\mutable\let\and \relax % \empty
+\mutable\let\with\relax % \empty
\mutable\let\nop \empty % used often
\mutable\let\yes \empty % used often
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index fc87d5d69..c83cc1320 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-09-03 18:45
+-- merge date : 2021-09-06 11:44
do -- begin closure to overcome local limits and interference