summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2021-07-16 22:58:17 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2021-07-16 22:58:17 +0200
commita06e8a0d7325ee248138a327e1117139b71aeaba (patch)
treec0ffdfcb82aac51b5e35fb3e5aa2ae0314d62220 /tex/context/modules/mkiv
parenteebab79d84255890c1a6d320fba146b1c422c3a6 (diff)
downloadcontext-a06e8a0d7325ee248138a327e1117139b71aeaba.tar.gz
2021-07-16 22:01:00
Diffstat (limited to 'tex/context/modules/mkiv')
-rw-r--r--tex/context/modules/mkiv/m-asymptote.lua2
-rw-r--r--tex/context/modules/mkiv/m-asymptote.mkiv2
-rw-r--r--tex/context/modules/mkiv/m-barcodes.mkiv7
-rw-r--r--tex/context/modules/mkiv/m-escrito.lua361
-rw-r--r--tex/context/modules/mkiv/m-escrito.mkiv19
-rw-r--r--tex/context/modules/mkiv/m-gnuplot.mkxl97
-rw-r--r--tex/context/modules/mkiv/m-pictex.mkiv11
-rw-r--r--tex/context/modules/mkiv/m-pstricks.mkiv11
-rw-r--r--tex/context/modules/mkiv/m-tikz.mkiv90
-rw-r--r--tex/context/modules/mkiv/m-zint.mkiv8
10 files changed, 297 insertions, 311 deletions
diff --git a/tex/context/modules/mkiv/m-asymptote.lua b/tex/context/modules/mkiv/m-asymptote.lua
index 31a81433f..9a93e166d 100644
--- a/tex/context/modules/mkiv/m-asymptote.lua
+++ b/tex/context/modules/mkiv/m-asymptote.lua
@@ -29,7 +29,7 @@ sandbox.registerrunner {
checkers = { filename = "readable" },
}
-function moduledata.asympote.process(name,type)
+function moduledata.asymptote.process(name,type)
if type == "prc" then
local result = buffers.run(name,false,"asymptote prc","prc")
local jsdata = { js = replacesuffix(result,"js") }
diff --git a/tex/context/modules/mkiv/m-asymptote.mkiv b/tex/context/modules/mkiv/m-asymptote.mkiv
index 9cd4037fb..6317fc072 100644
--- a/tex/context/modules/mkiv/m-asymptote.mkiv
+++ b/tex/context/modules/mkiv/m-asymptote.mkiv
@@ -51,7 +51,7 @@
{\iffirstargument
\begingroup
\getdummyparameters[#2]%
- \edef\lasttypesetbuffer{\ctxlua{moduledata.asympote.process("asymptote:#1","\dummyparameter\c!type")}}%
+ \edef\lasttypesetbuffer{\ctxlua{moduledata.asymptote.process("asymptote:#1","\dummyparameter\c!type")}}%
\externalfigure
[\lasttypesetbuffer]%
[\c!controls=\lasttypesetbuffer,#2]%
diff --git a/tex/context/modules/mkiv/m-barcodes.mkiv b/tex/context/modules/mkiv/m-barcodes.mkiv
index 84f093c56..17afb5753 100644
--- a/tex/context/modules/mkiv/m-barcodes.mkiv
+++ b/tex/context/modules/mkiv/m-barcodes.mkiv
@@ -1,3 +1,5 @@
+% engine=luatex
+
%D \module
%D [ file=m-barcodes,
%D version=2010.03.14,
@@ -20,6 +22,11 @@
\unexpanded\def\barcode[#1]%
{\normalbarcode[\c!text=\dummyparameter\c!code,\c!alternative=\dummyparameter\c!type,#1]}
+%D We keep the following for historic reasons to show progress over years. The
+%D original idea was to use escrito fro the code below but it never happened as
+%D we went zint. I'll look into that when users really want to use pstricks but I
+%D never had requests and the chemical mpoduel also moved on.
+
\iffalse
% \startTEXpage
diff --git a/tex/context/modules/mkiv/m-escrito.lua b/tex/context/modules/mkiv/m-escrito.lua
index 0d7a04741..8a45f1a2c 100644
--- a/tex/context/modules/mkiv/m-escrito.lua
+++ b/tex/context/modules/mkiv/m-escrito.lua
@@ -48,6 +48,24 @@ if not modules then modules = { } end modules ['m-escrito'] = {
-- of the VM calls (in direct mode they are no-ops anyway). We can also share some
-- more code here and there.
+-- Notes:
+--
+-- -- all modules are checked / adapted to lmtx but how about this one ... i noticed
+-- that a file in the test suite failed
+--
+-- -- the idea was to use this for the m4all eps files but we swichted the format
+-- there; nevertheless i patched a littl but it's still not ok (cold winter work)
+--
+-- -- for instance some ppor mans fancy shading doesn't show up (not that efficient
+-- either so ...)
+--
+-- -- let's see what the new fast ps->pdf lib from artifact brings ... makes more
+-- sense in the perspective of ps 2 and 3 .. but there is some sentiment involved
+--
+-- -- room for implification (like no integer / real distinction needed)
+--
+-- -- so for now this is not part of the mkiv/lmtx code split (then also go Lua 5.4)
+
local type, unpack, tonumber, tostring, next = type, unpack, tonumber, tostring, next
local format = string.format
@@ -78,7 +96,7 @@ local log10 = math.log10
local random = math.random
local setranseed = math.randomseed
-local bitand = bit32.band
+local bitand = bit32.band -- when lmtx: Lua 5.4
local bitor = bit32.bor
local bitxor = bit32.bxor
local bitrshift = bit32.rshift
@@ -133,7 +151,7 @@ initializers[#initializers+1] = function()
VM = { }
end
-local directvm = true
+local directvm = false -- true (but then we ned to patch more VM[..]
local add_VM, get_VM
@@ -245,6 +263,9 @@ end
local opstack
local opstackptr
+local b_true = { 'boolean', 'unlimited', 'literal', true }
+local b_false = { 'boolean', 'unlimited', 'literal', false }
+
initializers[#initializers+1] = function()
opstack = { }
opstackptr = 0
@@ -489,7 +510,7 @@ function operators.exch()
if opstackptr < 2 then
return ps_error('stackunderflow')
end
- local prv = opstackptr-1
+ local prv = opstackptr - 1
opstack[opstackptr], opstack[prv] = opstack[prv], opstack[opstackptr]
return true
end
@@ -498,7 +519,7 @@ function operators.dup()
if opstackptr < 1 then
return ps_error('stackunderflow')
end
- local nxt = opstackptr+1
+ local nxt = opstackptr + 1
opstack[nxt] = opstack[opstackptr]
opstackptr = nxt
return true
@@ -1835,10 +1856,10 @@ function operators.anchorsearch()
local post = sub(thestring,#thesearch+1)
push_opstack { 'string', 'unlimited', 'literal', add_VM(post), 1, #post }
push_opstack { 'string', 'unlimited', 'literal', add_VM(prefix), 1, #prefix }
- push_opstack { 'boolean', 'unlimited', 'literal', true }
+ push_opstack (b_true)
else
push_opstack(a)
- push_opstack { 'boolean', 'unlimited', 'literal', false }
+ push_opstack (b_false)
end
return true
end
@@ -1884,10 +1905,10 @@ function operators.search()
push_opstack { 'string', 'unlimited', 'literal', add_VM(post), 1, #post }
push_opstack { 'string', 'unlimited', 'literal', add_VM(thesearch), 1, #thesearch }
push_opstack { 'string', 'unlimited', 'literal', add_VM(prefix), 1, #prefix }
- push_opstack { 'boolean', 'unlimited', 'literal', true }
+ push_opstack (b_true)
else
push_opstack(a)
- push_opstack { 'boolean', 'unlimited', 'literal', false }
+ push_opstack(b_false)
end
return true
end
@@ -1913,7 +1934,7 @@ function operators.token()
if not v then
pop_execstack()
pop_execstack()
- push_opstack { 'boolean', 'unlimited', 'literal', false }
+ push_opstack(b_false)
else
local q = pop_execstack()
if execstack[execstackptr][1] == '.token' then
@@ -1933,7 +1954,7 @@ function operators.token()
end
push_opstack { ta, aa, a[3], add_VM(substring), 1, #substring}
push_opstack(v)
- push_opstack { 'boolean', 'unlimited', 'literal', true }
+ push_opstack(b_true)
end
else -- file
if a[7] ~= 'r' then
@@ -1945,7 +1966,7 @@ function operators.token()
if not v then
pop_execstack()
pop_execstack()
- push_opstack { 'boolean', 'unlimited', 'literal', false }
+ push_opstack(b_false)
else
local q = pop_execstack() -- the file
a[5] = q[5]
@@ -1953,7 +1974,7 @@ function operators.token()
pop_execstack()
end
push_opstack(v)
- push_opstack { 'boolean', 'unlimited', 'literal', true }
+ push_opstack(b_true)
end
end
return true
@@ -1994,7 +2015,7 @@ end
function operators.eq()
local ok, a, b = both()
if ok then
- push_opstack { 'boolean', 'unlimited', 'literal', a == b }
+ push_opstack(a == b and b_true or b_false)
return true
else
return a
@@ -2004,7 +2025,7 @@ end
function operators.ne()
local ok, a, b = both()
if ok then
- push_opstack { 'boolean', 'unlimited', 'literal', a ~= b }
+ push_opstack(a ~= b and b_true or b_false)
return true
else
return a
@@ -2040,7 +2061,7 @@ end
function operators.ge()
local ok, a, b = both()
if ok then
- push_opstack { 'boolean', 'unlimited', 'literal', a >= b }
+ push_opstack(a >= b and b_true or b_false)
return true
else
return a
@@ -2050,7 +2071,7 @@ end
function operators.gt()
local ok, a, b = both()
if ok then
- push_opstack { 'boolean', 'unlimited', 'literal', a > b }
+ push_opstack(a > b and b_true or b_false)
return true
else
return a
@@ -2060,7 +2081,7 @@ end
function operators.le()
local ok, a, b = both()
if ok then
- push_opstack { 'boolean', 'unlimited', 'literal', a <= b }
+ push_opstack(a <= b and b_true or b_false)
return true
else
return a
@@ -2070,7 +2091,7 @@ end
function operators.lt()
local ok, a, b = both()
if ok then
- push_opstack { 'boolean', 'unlimited', 'literal', a < b }
+ push_opstack(a < b and b_true or b_false)
return true
else
return a
@@ -2104,7 +2125,7 @@ end
operators["and"]= function()
local ok, a, b = both()
if ok == 'boolean' then
- push_opstack { 'boolean', 'unlimited', 'literal', a[1] and b[1] }
+ push_opstack((a[1] and b[1]) and b_true or b_false)
return true
elseif ok == 'integer' then
push_opstack { 'integer', 'unlimited', 'literal', bitand(a[1],b[1]) }
@@ -2117,7 +2138,7 @@ end
operators["or"] = function()
local ok, a, b = both()
if ok == 'boolean' then
- push_opstack {'boolean', 'unlimited', 'literal', a[1] or b[1] }
+ push_opstack((a[1] or b[1]) and b_true or b_false)
return true
elseif ok == 'integer' then
push_opstack {'integer', 'unlimited', 'literal', bitor(a[1],b[1]) }
@@ -2130,7 +2151,7 @@ end
function operators.xor()
local ok, a, b = both()
if ok == 'boolean' then
- push_opstack {'boolean', 'unlimited', 'literal', a[1] ~= b[1] }
+ push_opstack ((a[1] ~= b[1]) and b_true or b_false) -- hm, unequal ?
return true
elseif ok == 'integer' then
push_opstack {'integer', 'unlimited', 'literal', bitxor(a[1],b[1]) }
@@ -2151,7 +2172,7 @@ operators["not"] = function()
return ps_error('invalidaccess')
end
if ta == 'boolean' then
- push_opstack { 'boolean', 'unlimited', 'literal', not a[4] }
+ push_opstack ((not a[4]) and b_true or b_false)
elseif ta == 'integer' then
push_opstack { 'integer', 'unlimited', 'literal', -a[4] - 1 }
else
@@ -2516,7 +2537,7 @@ function operators.xcheck()
if not a then
return ps_error('stackunderflow')
end
- push_opstack { 'boolean', 'unlimited', 'literal', a[3] == 'executable' }
+ push_opstack((a[3] == 'executable') and b_true or b_false)
return true
end
@@ -2602,7 +2623,7 @@ function operators.rcheck()
else
return ps_error('typecheck')
end
- push_opstack { 'boolean', 'unlimited', 'literal', aa == 'unlimited' or aa == 'read-only' }
+ push_opstack((aa == 'unlimited' or aa == 'read-only') and p_true or p_false)
return true
end
@@ -2621,7 +2642,7 @@ function operators.wcheck()
else
return ps_error('typecheck')
end
- push_opstack { 'boolean', 'unlimited', 'literal', aa == 'unlimited' }
+ push_opstack((aa == 'unlimited') and p_true or p_false)
return true
end
@@ -2906,10 +2927,10 @@ function operators.read()
end
if b then
push_opstack { 'integer', 'unlimited', 'literal', byte(b) }
- push_opstack { 'boolean', 'unlimited', 'literal', true }
+ push_opstack (p_true)
else
f:close()
- push_opstack { 'boolean', 'unlimited', 'literal', false}
+ push_opstack (p_false)
end
return true
end
@@ -3042,7 +3063,7 @@ do
end
if not va then
push_opstack { 'string', 'unlimited', 'literal', add_VM(''), 0, 0 }
- push_opstack { 'boolean', 'unlimited', 'literal', false }
+ push_opstack (p_false)
else
local n = #va
if n > b[6] then
@@ -3051,7 +3072,7 @@ do
local thestring = get_VM(b[4])
VM[b[4]] = va .. sub(thestring,#va+1, -1)
push_opstack { 'string', 'unlimited', 'literal', add_VM(va), n, n }
- push_opstack { 'boolean', 'unlimited', 'literal', true }
+ push_opstack (p_true)
end
return true
end
@@ -3100,7 +3121,7 @@ do
local n = #va
VM[b[4]] = repl .. sub(thestring,n+1,-1)
push_opstack { b[1], b[2], b[3], add_VM(va), n, n }
- push_opstack { 'boolean', 'unlimited', 'literal', n == b[6] }
+ push_opstack ((n == b[6]) and p_true or p_false)
return true
end
@@ -3335,8 +3356,8 @@ local function commonstack(seperator)
for n=1,opstackptr do
push_opstack { 'string', 'unlimited', 'literal', add_VM(seperator), 1 ,1 }
push_opstack(opstack[n])
- push_execstack { 'operator','unlimited','executable', operators.print, 'print'}
- push_execstack { 'operator','unlimited','executable', operators.equal, '=='}
+ push_execstack { 'operator','unlimited','executable', operators.print, 'print' }
+ push_execstack { 'operator','unlimited','executable', operators.equal, '==' }
end
return true
end
@@ -3377,15 +3398,21 @@ end
function operators.save()
local saved_VM = { }
- for k1, v1 in next, VM do
+-- for k1, v1 in next, VM do
+ for k1 = 1, #VM do
+ local v1 = VM[k1]
if type(v1) == "table" then
local t1 = { }
saved_VM[k1] = t1
- for k2, v2 in next, t1 do
+-- for k2, v2 in next, v1 do
+ for k2=1,#v1 do
+ local v2 = v1[k2]
if type(v2) == "table" then
local t2 = { }
t1[k2] = t2
- for k3, v3 in next, v2 do
+-- for k3, v3 in next, v2 do
+ for k3=1,#v2 do
+ local v3 = v2[k3]
t2[k3] = v3
end
else
@@ -3401,6 +3428,13 @@ function operators.save()
push_opstack { 'save', 'unlimited', 'executable', add_VM(saved_VM) }
end
+function operators.save()
+ local saved_VM = table.copy(VM)
+ push_gsstack { 'save', copy_gsstate() }
+ savelevel = savelevel + 1
+ push_opstack { 'save', 'unlimited', 'executable', add_VM(saved_VM) }
+end
+
do
local function validstack(stack,index,saved_VM)
@@ -3532,6 +3566,9 @@ end
function operators.gsave()
push_gsstack { 'gsave', copy_gsstate() }
+ currentpage[#currentpage+1] = {
+ type = 'gsave',
+ }
return true
end
@@ -3543,6 +3580,9 @@ function operators.grestore()
gsstate = g[2]
end
end
+ currentpage[#currentpage+1] = {
+ type = 'grestore',
+ }
return true
end
@@ -4183,7 +4223,7 @@ function operators.setmatrix()
if i > 6 then
return ps_error('rangecheck')
end
- matrix[i] = va
+ matrix[i] = tv
end
return true
end
@@ -4856,7 +4896,7 @@ local function commonarc(action)
if not a then
return ps_error('stackunderflow')
end
- local ta, tb, tc, td, te = a[1], b[1], c[1], d[1], e[1], f[1]
+ local ta, tb, tc, td, te = a[1], b[1], c[1], d[1], e[1]
if not (ta == 'real' or ta == 'integer') then return ps_error('typecheck') end
if not (tb == 'real' or tb == 'integer') then return ps_error('typecheck') end
if not (tc == 'real' or tc == 'integer') then return ps_error('typecheck') end
@@ -5058,6 +5098,7 @@ function operators.rcurveto()
if #position == 0 then
return ps_error('nocurrentpoint')
end
+ local matrix = gsstate.matrix
local x, y = do_transform(matrix, e[4], f[4])
local ax, ay = do_transform(matrix, a[4], b[4])
local bx, by = do_transform(matrix, c[4], d[4])
@@ -5485,6 +5526,17 @@ end
------------------------------------------------------------------
+function operators.pathbbox()
+ print("todo: pathbbox")
+ push_opstack { "real", 'unlimited', 'literal', 0 }
+ push_opstack { "real", 'unlimited', 'literal', 0 }
+ push_opstack { "real", 'unlimited', 'literal', 1 }
+ push_opstack { "real", 'unlimited', 'literal', 1 }
+ return true
+end
+
+------------------------------------------------------------------
+
-- most time is spend in calculating the boundingbox
-- NULL output
@@ -5537,113 +5589,136 @@ function pdf.showpage(page)
local object = page[i]
local path = object.path
local otyp = object.type
- if otype ~= "clip" and otype ~= "eoclip" then
- local colortype = object.colortype
- local color = object.color
- if colortype == "gray" then
- local v = formatters["%f g %f G"](color,color)
- if g_color ~= v then
- g_colortype = "gray"
- g_color = v
- n = n + 1 ; t[n] = v
+ if otyp == "gsave" then
+ n = n + 1 ; t[n] = "q"
+ -- todo push / pop
+g_colortype = "notacolor"
+g_color = ""
+g_miterlimit = -1
+g_linejoin = -1
+g_linecap = -1
+g_linewidth = -1
+g_dashpattern = nil
+g_dashoffset = -1
+ elseif otyp == "grestore" then
+g_colortype = "notacolor"
+g_color = ""
+g_miterlimit = -1
+g_linejoin = -1
+g_linecap = -1
+g_linewidth = -1
+g_dashpattern = nil
+g_dashoffset = -1
+ n = n + 1 ; t[n] = "Q"
+ else
+ if otyp ~= "clip" and otyp ~= "eoclip" then
+ local colortype = object.colortype
+ local color = object.color
+ if colortype == "gray" then
+ local v = formatters["%f g %f G"](color,color)
+ if g_color ~= v then
+ g_colortype = "gray"
+ g_color = v
+ n = n + 1 ; t[n] = v
+ end
+ elseif colortype == "rgb" then
+ local r, g, b = color[1], color[2], color[3]
+ local v = formatters["%f %f %f rg %f %f %f RG"](r,g,b,r,g,b)
+ if g_color ~= v then
+ g_colortype = "rgb"
+ g_color = v
+ n = n + 1 ; t[n] = v
+ end
+ elseif colortype == "cmyk" then
+ local c, m, y, k = color[1], color[2], color[3], color[4]
+ local v = formatters["%f %f %f %f k %f %f %f %f K"](c,m,y,k,c,m,y,k)
+ if g_color ~= v then
+ g_colortype = "cmyk"
+ g_color = v
+ n = n + 1 ; t[n] = v
+ end
+ elseif colortype == "hsb" then
+ local r, g, b = hsv_to_rgb(color[1],color[2],color[3])
+ local v = formatters["%f %f %f rg %f %f %f RG"](r,g,b,r,g,b)
+ if g_color ~= v then
+ g_colortype = "rgb"
+ g_color = v
+ n = n + 1 ; t[n] = v
+ end
end
- elseif colortype == "rgb" then
- local r, g, b = color[1], color[2], color[3]
- local v = formatters["%f %f %f rg %f %f %f RG"](r,g,b,r,g,b)
- if g_color ~= v then
- g_colortype = "rgb"
- g_color = v
- n = n + 1 ; t[n] = v
+ end
+ if otyp == "stroke" then
+ local miterlimit = object.miterlimit
+ if g_miterlimit ~= miterlimit then
+ g_miterlimit = miterlimit
+ n = n + 1 ; t[n] = formatters["%f M"](miterlimit)
end
- elseif colortype == "cmyk" then
- local c, m, y, k = color[1], color[2], color[3], color[4]
- local v = formatters["%f %f %f %f k %f %f %f %f K"](c,m,y,k,c,m,y,k)
- if g_color ~= v then
- g_colortype = "cmyk"
- g_color = v
- n = n + 1 ; t[n] = v
+ local linejoin = object.linejoin
+ if g_linejoin ~= linejoin then
+ g_linejoin = linejoin
+ n = n + 1 ; t[n] = formatters["%d j"](linejoin)
end
- elseif colortype == "hsb" then
- local r, g, b = hsv_to_rgb(color[1],color[2],color[3])
- local v = formatters["%f %f %f rg %f %f %f RG"](r,g,b,r,g,b)
- if g_color ~= v then
- g_colortype = "rgb"
- g_color = v
- n = n + 1 ; t[n] = v
+ local linecap = object.linecap
+ if g_linecap ~= linecap then
+ g_linecap = linecap
+ n = n + 1 ; t[n] = formatters["%d J"](linecap)
end
- end
- end
- if otype == "stroke" then
- local miterlimit = object.miterlimit
- if g_miterlimit ~= miterlimit then
- g_miterlimit = miterlimit
- n = n + 1 ; t[n] = formatters["%f M"](miterlimit)
- end
- local linejoin = object.linejoin
- if g_linejoin ~= linejoin then
- g_linejoin = linejoin
- n = n + 1 ; t[n] = formatters["%d j"](linejoin)
- end
- local linecap = object.linecap
- if g_linecap ~= linecap then
- g_linecap = linecap
- n = n + 1 ; t[n] = formatters["%d J"](linecap)
- end
- local linewidth = object.linewidth
- if g_linewidth ~= linewidth then
- g_linewidth = linewidth
- n = n + 1 ; t[n] = formatters["%f w"](linewidth)
- end
- local dashpattern = object.dashpattern
- local dashoffset = object.dashoffset
- if g_dashpattern ~= dashpattern or g_dashoffset ~= dashoffset then
- g_dashpattern = dashpattern
- g_dashoffset = dashoffset
- local l = #dashpattern
- if l == 0 then
- n = n + 1 ; t[n] = "[] 0 d"
- else
- n = n + 1 ; t[n] = formatters["[% t] %d d"](dashpattern,dashoffset)
+ local linewidth = object.linewidth
+ if g_linewidth ~= linewidth then
+ g_linewidth = linewidth
+ n = n + 1 ; t[n] = formatters["%f w"](linewidth)
+ end
+ local dashpattern = object.dashpattern
+ local dashoffset = object.dashoffset
+ if g_dashpattern ~= dashpattern or g_dashoffset ~= dashoffset then
+ g_dashpattern = dashpattern
+ g_dashoffset = dashoffset
+ local l = #dashpattern
+ if l == 0 then
+ n = n + 1 ; t[n] = "[] 0 d"
+ else
+ n = n + 1 ; t[n] = formatters["[% t] %d d"](dashpattern,dashoffset)
+ end
end
end
- end
- if path then
- for i=1,#path do
- local segment = path[i]
- local styp = segment[1]
- if styp == "moveto" then
- n = n + 1 ; t[n] = formatters["%f %f m"](segment[2],segment[3])
- elseif styp == "lineto" then
- n = n + 1 ; t[n] = formatters["%f %f l"](segment[2],segment[3])
- elseif styp == "curveto" then
- n = n + 1 ; t[n] = formatters["%f %f %f %f %f %f c"](segment[2],segment[3],segment[4],segment[5],segment[6],segment[7])
- elseif styp == "closepath" then
- n = n + 1 ; t[n] = "h"
- else
- report("unknown path segment type %a",styp)
+ if path then
+ for i=1,#path do
+ local segment = path[i]
+ local styp = segment[1]
+ if styp == "moveto" then
+ n = n + 1 ; t[n] = formatters["%f %f m"](segment[2],segment[3])
+ elseif styp == "lineto" then
+ n = n + 1 ; t[n] = formatters["%f %f l"](segment[2],segment[3])
+ elseif styp == "curveto" then
+ n = n + 1 ; t[n] = formatters["%f %f %f %f %f %f c"](segment[2],segment[3],segment[4],segment[5],segment[6],segment[7])
+ elseif styp == "closepath" then
+ n = n + 1 ; t[n] = "h"
+ else
+ report("unknown path segment type %a",styp)
+ end
end
end
- end
- if otyp == "stroke" then
- n = n + 1 ; t[n] = "S"
- elseif otyp == "fill" then
- n = n + 1 ; t[n] = "f"
- elseif otyp == "eofill" then
- n = n + 1 ; t[n] = "f*"
- elseif otyp == "clip" then
- n = n + 1 ; t[n] = "W n"
- elseif otyp == "eoclip" then
- n = n + 1 ; t[n] = "W* n"
- elseif otyp == "show" then
- if showfont then
- if n > 0 then
- flushpage(concat(t,"\n"))
- n = 0 ; t = { }
+ if otyp == "stroke" then
+ n = n + 1 ; t[n] = "S"
+ elseif otyp == "fill" then
+ n = n + 1 ; t[n] = "f"
+ elseif otyp == "eofill" then
+ n = n + 1 ; t[n] = "f*"
+ elseif otyp == "clip" then
+ n = n + 1 ; t[n] = "W n"
+ elseif otyp == "eoclip" then
+ n = n + 1 ; t[n] = "W* n"
+ elseif otyp == "show" then
+ if showfont then
+ if n > 0 then
+ flushpage(concat(t,"\n"))
+ n = 0 ; t = { }
+ end
+ showfont(object)
end
- showfont(object)
+ else
+ -- nothing to do
end
- else
- -- nothing to do
end
end
n = n + 1 ; t[n] = "Q"
@@ -6198,7 +6273,7 @@ function operators.kshow()
local entry = execstack[execstackptr]
if entry[1] == '.exit' and entry[4] == true then
pop_execstack()
- return true;
+ return true
end
do_show(fontdict,w)
v = w
@@ -6332,6 +6407,7 @@ initializers[#initializers+1] = function(reset)
['cleartomark'] = { 'operator', 'unlimited', 'executable', operators.cleartomark, 'cleartomark' },
['clip'] = { 'operator', 'unlimited', 'executable', operators.clip, 'clip' },
['clippath'] = { 'operator', 'unlimited', 'executable', operators.clippath, 'clippath' },
+ ['pathbbox'] = { 'operator', 'unlimited', 'executable', operators.pathbbox, 'pathbbox' },
['closefile'] = { 'operator', 'unlimited', 'executable', operators.closefile, 'closefile' },
['closepath'] = { 'operator', 'unlimited', 'executable', operators.closepath, 'closepath' },
['concat'] = { 'operator', 'unlimited', 'executable', operators.concat, 'concat' },
@@ -6535,7 +6611,7 @@ initializers[#initializers+1] = function(reset)
size = 1,
maxsize = 40,
dict = {
- newerror = { 'boolean', 'unlimited', 'literal', false }
+ newerror = p_false
},
}
--
@@ -6638,7 +6714,7 @@ do
local sign = S('+-')^-1
local digit = R('09')
local period = P('.')
- local letters = R('!~') - S('[]<>{}()%')
+ local letters = R('!~') - S('[]<>{}()%/')
local hexdigit = R('09','af','AF')
local radixdigit = R('09','az','AZ')
@@ -6732,7 +6808,12 @@ do
object[5] = position
end
if not value then
- return false -- handle_error('syntaxerror')
+ if tokentype == "eof" then
+ -- pop_execstack()
+ return true
+ else
+ return false -- handle_error('syntaxerror')
+ end
elseif tokentype == 'integer' or tokentype == 'real' then
if push { tokentype, 'unlimited', 'literal', value } then
return true
@@ -6759,6 +6840,8 @@ do
end
elseif tokentype == 'bounding' then
specials.boundingbox = value
+ else
+ -- comment
end
end
return position >= length
@@ -6833,7 +6916,7 @@ do
return false
end
local otyp = object[1]
- if DEBUG then
+ if false then -- debugging
if otyp == 'operator' then
report_exec("%s %s %s",otyp,object[3],object[5])
elseif otyp == 'dict' then
diff --git a/tex/context/modules/mkiv/m-escrito.mkiv b/tex/context/modules/mkiv/m-escrito.mkiv
index 704108cee..94251d843 100644
--- a/tex/context/modules/mkiv/m-escrito.mkiv
+++ b/tex/context/modules/mkiv/m-escrito.mkiv
@@ -14,12 +14,16 @@
\registerctxluafile{m-escrito}{}
%D This is a fun project and not meant for production (yet). It's a follow up on a
-%D project by Taco presented at a Bacho\TeX\ meeting years ago. I probably messed up
+%D project by Taco presented at a Bacho\TEX\ meeting years ago. I probably messed up
%D the code so much that some things don't work but then, fonts are not really
%D supported well anyway. However for simple \POSTSCRIPT\ things work out ok.
%D
%D I (Hans) will occasionally have a look at the code. Who knows what our trips to
-%D \TeX\ meetings lead to.
+%D \TEX\ meetings lead to.
+
+%D Ecause the (already split) barcode modules don't need this I'll postpone the
+%D splitting of this one till later. It's more fun project anyway and there are
+%D buglets as well as no support for tricky features.
\unprotect
@@ -78,15 +82,6 @@
\startluacode
- local literal = nodes.pool.register(node.new("whatsit",nodes.whatsitcodes.pdfliteral))
- literal.mode = 0
-
- local function newliteral(result)
- local l = nodes.copy(literal)
- l.data = result
- return l
- end
-
local p = escrito.devices.pdf
function p.startpage(llx,lly,urx,ury)
@@ -98,7 +93,7 @@
end
function p.flushpage(result)
- context.(newliteral(result))
+ context.pdfliteral(result) -- LMTX save (test suite reported issue)
end
-- todo
diff --git a/tex/context/modules/mkiv/m-gnuplot.mkxl b/tex/context/modules/mkiv/m-gnuplot.mkxl
deleted file mode 100644
index e844edd1b..000000000
--- a/tex/context/modules/mkiv/m-gnuplot.mkxl
+++ /dev/null
@@ -1,97 +0,0 @@
-%D \module
-%D [ file=m-gnuplot,
-%D version=2020.02.10,
-%D title=\CONTEXT\ Extra Modules,
-%D subtitle=Gnuplot,
-%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.
-
-%D This is a variant on the \GNUPLOT\ terminal code. At some point (when there is a
-%D reason) I will make a proper environment that can be used for embedded code.
-
-\permanent\protected\def\includegnuplotsvgfile[#1]%
- {\hbox\bgroup
- \ctxlua{metapost.startsvghashing()}%
- \includesvgfile[#1]%
- \ctxlua{metapost.stopsvghashing()}%
- \egroup}
-
-\startluacode
-
-local modificationtime = lfs.modification
-local longtostring = string.longtostring
-local formatters = string.formatters
-local expandfilename = dir.expandname
-local isfile = lfs.isfile
-
-local runner = sandbox.registerrunner {
- name = "gnuplot to svg",
- program = "gnuplot",
- template = longtostring [[
- -e "set output '%newname%'; set terminal svg"
- "%oldname%"
- ]],
- checkers = {
- oldname = "readable",
- newname = "writable",
- },
-}
-
-figures.programs.gnuplot = {
- runner = runner,
-}
-
-local function remap(specification)
- local oldname = specification.fullname
- if oldname then
- local newname = file.replacesuffix(oldname,"svg")
- local oldtime = modificationtime(oldname) or 0
- local newtime = modificationtime(newname) or 0
- if newtime == 0 or oldtime > newtime then
- runner {
- newname = expandfilename(newname),
- oldname = expandfilename(oldname),
- }
- end
- if isfile(newname) then
- local only = file.nameonly(newname)
- local name = formatters["svg-%s-inclusion"](only)
- local code = formatters["\\includegnuplotsvgfile[%s]\\resetbuffer[%s]"](newname,name)
- buffers.assign(name,code)
- specification.format = "buffer"
- specification.fullname = name
- end
- end
- return specification
-end
-
-figures.remappers.gp = { svg = remap }
-
-\stopluacode
-
-\continueifinputfile{m-gnuplot.mkxl}
-
-\startluacode
-io.savedata("m-gnuplot-demo.gp", [[
-set format xy "$%g$"
-
-set title 'This is a plot of $y=\\sin(x)$'
-set xlabel 'This is the $x$ axis'
-set ylabel 'This is the $y$ axis'
-
-plot [0:6.28] [0:1] sin(x)
-]])
-\stopluacode
-
-\starttext
-
- \externalfigure[m-gnuplot-demo.gp][conversion=svg,width=4cm]
-
- \externalfigure[m-gnuplot-demo.gp][conversion=svg,width=8cm]
-
-\stoptext
diff --git a/tex/context/modules/mkiv/m-pictex.mkiv b/tex/context/modules/mkiv/m-pictex.mkiv
index 73aad3f57..8843ac4ce 100644
--- a/tex/context/modules/mkiv/m-pictex.mkiv
+++ b/tex/context/modules/mkiv/m-pictex.mkiv
@@ -11,7 +11,16 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D Just in case someone still uses \PICTEX:
+%D Just in case someone still uses \PICTEX\ we provide a loader. However, because it
+%D expect some plain helpers to be present (like \type {\newhelp} and because it
+%D defined some already used dimensions, we'd either need to adapt or add some
+%D push|/|pop here. Because \CONTEXT\ users have \METAPOST\ support we no longer
+%D support \PICTEX\ in \LMTX.
+
+\ifcase\contextlmtxmode \else
+ \writestatus{modules}{the PicTeX graphic system is not supported in LMTX}
+ \expandafter \endinput
+\fi
\ifdefined\beginpicture \else
diff --git a/tex/context/modules/mkiv/m-pstricks.mkiv b/tex/context/modules/mkiv/m-pstricks.mkiv
index 421607aaf..c3c6f769b 100644
--- a/tex/context/modules/mkiv/m-pstricks.mkiv
+++ b/tex/context/modules/mkiv/m-pstricks.mkiv
@@ -11,6 +11,17 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+%D We don't support \PSTRICKS\ in \LMTX. In \MKIV\ it was already doen by calling
+%D \PDFTEX\ and going the \POSTSCRIPT\ route. We could actually support it sort of
+%D integrated if it were just graphics but I suppose fonts will make it a mess not
+%D worth the trouble. One can always use \MKII\ directly if needed to make graphics
+%D that get included as \PDF.
+
+\ifcase\contextlmtxmode \else
+ \writestatus{modules}{the PStricks graphic system is not supported in LMTX}
+ \expandafter \endinput
+\fi
+
\registerctxluafile{m-pstricks}{}
\unprotect
diff --git a/tex/context/modules/mkiv/m-tikz.mkiv b/tex/context/modules/mkiv/m-tikz.mkiv
index ed9cb914f..536ab554a 100644
--- a/tex/context/modules/mkiv/m-tikz.mkiv
+++ b/tex/context/modules/mkiv/m-tikz.mkiv
@@ -1,4 +1,19 @@
-%D A fixed variant if the t-tikz module distributed with tikz.
+%D \module
+%D [ file=m-tikz,
+%D version=2021.07.12,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=TIKZ support,
+%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.
+
+%D A fixed variant of the t-tikz module distributed with tikz. For
+%D practical reasons per 2021 we split the module for \MKIV\ and
+%D \LMTX. (Maybe some day I'll optimize TIKZ a bit.)
\ifdefined\pdflastxpos \else
\unprotect
@@ -7,70 +22,35 @@
\protect
\fi
+\pushcatcodetable
-\pushoverloadmode
+ \setcatcodetable\texcatcodes
- \pushcatcodetable
+ \catcode`\@=11
+ \catcode`\|=12
+ \catcode`\!=12
- \setcatcodetable\texcatcodes
+ \input t-pgf.tex
+ \input t-pgffor.tex
+ \input tikz.code.tex
- \catcode`\@=11
- \catcode`\|=12
- \catcode`\!=12
-
- \input t-pgf.tex
- \input t-pgffor.tex
- \input tikz.code.tex
-
- \popcatcodetable
-
-\popoverloadmode
+\popcatcodetable
\permanent\protected\def\tikzerrormessage#1#2#3%
{\writestatus{#1}{#2}}
-\ifcase\contextlmtxmode
-
- \let\starttikzsettings\relax
- \let\stoptikzsettings \relax
-
- \protected\def\starttikzpicture
- {% \dontleavehmode
- \begingroup
- \ifdefined\PackageError\else \let\PackageError\tikzerrormessage \fi
- \tikzpicture}
-
- \protected\def\stoptikzpicture
- {\endtikzpicture
- \endgroup}
+\let\starttikzsettings\relax
+\let\stoptikzsettings \relax
-\else
+\protected\def\starttikzpicture
+ {% \dontleavehmode
+ \begingroup
+ \ifdefined\PackageError\else \let\PackageError\tikzerrormessage \fi
+ \tikzpicture}
- % for now:
-
- \overloadmode\zerocount
-
- % but this will be mandate for settings outside the start .. stop
-
- \permanent\protected\def\starttikzsettings
- {\pushoverloadmode}
-
- \permanent\protected\def\stoptikzsettings
- {\popoverloadmode}
-
- \permanent\protected\def\starttikzpicture
- {\dontleavehmode
- \hcontainer\bgroup
- % \pushoverloadmode
- \ifdefined\PackageError\else \let\PackageError\tikzerrormessage \fi
- \tikzpicture}
-
- \permanent\protected\def\stoptikzpicture
- {\endtikzpicture
- % \popoverloadmode
- \egroup}
-
-\fi
+\protected\def\stoptikzpicture
+ {\endtikzpicture
+ \endgroup}
% \input t-pgf.tex
diff --git a/tex/context/modules/mkiv/m-zint.mkiv b/tex/context/modules/mkiv/m-zint.mkiv
index 4957c8461..7fe9f761c 100644
--- a/tex/context/modules/mkiv/m-zint.mkiv
+++ b/tex/context/modules/mkiv/m-zint.mkiv
@@ -11,16 +11,14 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D Using \type {zint} seems to be the easiest way to generate
-%D (PDF417) barcodes so therefore we now have this module. There
-%D are proper (also windows) binaries at:
+%D Using \type {zint} seems to be the easiest way to generate (PDF417) barcodes so
+%D therefore we now have this module. There are proper (also windows) binaries at:
%D
%D \starttyping
%D http://www.zint.org.uk
%D \stoptyping
%D
-%D There is a bit more code than needed as we want to be able to
-%D feed names.
+%D There is a bit more code than needed as we want to be able to feed names.
\startluacode