Adjust to newer LuaMetaTeX versions
This commit is contained in:
parent
29c97800a3
commit
b5c91c4312
65
ltexpl.ltx
Normal file
65
ltexpl.ltx
Normal file
@ -0,0 +1,65 @@
|
||||
%%
|
||||
%% This is file `ltexpl.ltx',
|
||||
%% generated with the docstrip utility.
|
||||
%%
|
||||
%% The original source files were:
|
||||
%%
|
||||
%% ltexpl.dtx (with options: `2ekernel')
|
||||
%%
|
||||
%% This is a generated file.
|
||||
%%
|
||||
%% The source is maintained by the LaTeX Project team and bug
|
||||
%% reports for it can be opened at https://latex-project.org/bugs.html
|
||||
%% (but please observe conditions on bug reports sent to that address!)
|
||||
%%
|
||||
%%
|
||||
%% Copyright (C) 1993-2019
|
||||
%% The LaTeX3 Project and any individual authors listed elsewhere
|
||||
%% in this file.
|
||||
%%
|
||||
%% This file was generated from file(s) of the LaTeX base system.
|
||||
%% --------------------------------------------------------------
|
||||
%%
|
||||
%% It may be distributed and/or modified under the
|
||||
%% conditions of the LaTeX Project Public License, either version 1.3c
|
||||
%% of this license or (at your option) any later version.
|
||||
%% The latest version of this license is in
|
||||
%% https://www.latex-project.org/lppl.txt
|
||||
%% and version 1.3c or later is part of all distributions of LaTeX
|
||||
%% version 2008 or later.
|
||||
%%
|
||||
%% This file has the LPPL maintenance status "maintained".
|
||||
%%
|
||||
%% This file may only be distributed together with a copy of the LaTeX
|
||||
%% base system. You may however distribute the LaTeX base system without
|
||||
%% such generated files.
|
||||
%%
|
||||
%% The list of all files belonging to the LaTeX base distribution is
|
||||
%% given in the file `manifest.txt'. See also `legal.txt' for additional
|
||||
%% information.
|
||||
%%
|
||||
%% The list of derived (unpacked) files belonging to the distribution
|
||||
%% and covered by LPPL is defined by the unpacking scripts (with
|
||||
%% extension .ins) which are part of the distribution.
|
||||
%%% From File: ltexpl.dtx
|
||||
\input luametalatex-baseregisters
|
||||
\IfFileExists{expl3.ltx}
|
||||
{%
|
||||
\ifnum0%
|
||||
\ifdefined\pdffilesize 1\fi
|
||||
\ifdefined\filesize 1\fi
|
||||
\ifdefined\luatexversion\ifnum\luatexversion>94 1\fi\fi
|
||||
>0 %
|
||||
\else
|
||||
\message{Skipping expl3-dependent extensions}
|
||||
\expandafter\endinput
|
||||
\fi
|
||||
}
|
||||
{%
|
||||
\message{Skipping expl3-dependent extensions}%
|
||||
\endinput
|
||||
}%
|
||||
\input{expl3.ltx}
|
||||
\endinput
|
||||
%%
|
||||
%% End of file `ltexpl.ltx'.
|
@ -10,12 +10,13 @@ local colorstacks = {{
|
||||
default = "0 g 0 G",
|
||||
page_stack = {"0 g 0 G"},
|
||||
}}
|
||||
token.scan_list = token.scan_box -- They are equal if no parameter is present
|
||||
token.luacmd("shipout", function()
|
||||
local voff = node.new'kern'
|
||||
voff.kern = tex.voffset + pdf.variable.vorigin
|
||||
voff.next = token.scan_list()
|
||||
voff.next.shift = tex.hoffset + pdf.variable.horigin
|
||||
local list = node.vpack(voff)
|
||||
local list = node.direct.tonode(node.direct.vpack(node.direct.todirect(voff)))
|
||||
list.height = tex.pageheight
|
||||
list.width = tex.pagewidth
|
||||
local out, resources, annots = writer(pfile, list, fontdirs, usedglyphs, colorstacks)
|
||||
|
@ -83,12 +83,14 @@
|
||||
\texAlloc{count}{suppressfontnotfounderror}{0}
|
||||
\texAlloc{count}{outputmode}{1} % The "traditional" default would be 0,
|
||||
% but we do not actually support that.
|
||||
\texAlloc{dimen}{pageheight}{210mm}
|
||||
\texAlloc{dimen}{pagewidth}{297mm}
|
||||
\texAlloc{dimen}{pageheight}{297mm}
|
||||
\texAlloc{dimen}{pagewidth}{210mm}
|
||||
\pdfAlloc{dimen}{horigin}{1in}
|
||||
\pdfAlloc{dimen}{vorigin}{1in}
|
||||
\pdfAlloc{count}{majorversion}{1}
|
||||
\pdfAlloc{count}{minorversion}{7}
|
||||
\pdfAlloc{count}{compresslevel}{0} % 0 is actually the only supported value right now, so this is basically ignored
|
||||
\pdfAlloc{count}{objcompresslevel}{0} % see above
|
||||
\directlua{
|
||||
lua.prepared_code[\csstring#lua.prepared_code+1] = tex.toks[0] .. "end"
|
||||
\the\toks0
|
||||
|
1
luametalatex-dev-init.lua
Symbolic link
1
luametalatex-dev-init.lua
Symbolic link
@ -0,0 +1 @@
|
||||
luametalatex-init.lua
|
1
luametalatex-dev.lua
Symbolic link
1
luametalatex-dev.lua
Symbolic link
@ -0,0 +1 @@
|
||||
luametalatex.lua
|
@ -15,7 +15,7 @@ function token.luacmd(name, func, ...)
|
||||
functions[idx] = func
|
||||
return idx
|
||||
end
|
||||
local properties = node.get_properties_table()
|
||||
local properties = node.direct.get_properties_table()
|
||||
-- setmetatable(node.direct.get_properties_table(), {
|
||||
-- __index = function(t, id)
|
||||
-- local new = {}
|
||||
@ -110,9 +110,9 @@ token.luacmd("openout", function(_, immediate) -- \openout
|
||||
if immediate == "immediate" then
|
||||
do_openout(props)
|
||||
else
|
||||
local whatsit = node.new(whatsit_id, whatsits.open)
|
||||
local whatsit = node.direct.new(whatsit_id, whatsits.open)
|
||||
properties[whatsit] = props
|
||||
node.write(whatsit)
|
||||
node.direct.write(whatsit)
|
||||
end
|
||||
end, "protected")
|
||||
local function do_closeout(p)
|
||||
@ -127,9 +127,9 @@ token.luacmd("closeout", function(_, immediate) -- \closeout
|
||||
if immediate == "immediate" then
|
||||
do_closeout(props)
|
||||
else
|
||||
local whatsit = node.new(whatsit_id, whatsits.close)
|
||||
local whatsit = node.direct.new(whatsit_id, whatsits.close)
|
||||
properties[whatsit] = props
|
||||
node.write(whatsit)
|
||||
node.direct.write(whatsit)
|
||||
end
|
||||
end, "protected")
|
||||
local function do_write(p)
|
||||
@ -148,9 +148,9 @@ token.luacmd("write", function(_, immediate) -- \write
|
||||
if immediate == "immediate" then
|
||||
do_write(props)
|
||||
else
|
||||
local whatsit = node.new(whatsit_id, whatsits.write)
|
||||
local whatsit = node.direct.new(whatsit_id, whatsits.write)
|
||||
properties[whatsit] = props
|
||||
node.write(whatsit)
|
||||
node.direct.write(whatsit)
|
||||
end
|
||||
end, "protected")
|
||||
local lua_call_cmd = token.command_id'lua_call'
|
||||
|
@ -339,10 +339,10 @@ status.init_kpse = 1
|
||||
require'luametalatex-init-config'
|
||||
status.safer_option = 0
|
||||
local read_tfm = require'luametalatex-font-tfm'
|
||||
read_vf = require'luametalatex-font-vf'
|
||||
local read_vf = require'luametalatex-font-vf'
|
||||
font.read_tfm = read_tfm
|
||||
font.read_vf = read_vf
|
||||
local reserved_ids = -1
|
||||
require'module'
|
||||
font.fonts = {}
|
||||
function font.getfont(id)
|
||||
return font.fonts[id]
|
||||
@ -352,24 +352,20 @@ pdf = {
|
||||
return id
|
||||
end,
|
||||
}
|
||||
callback.register('define_font', function(name, size)
|
||||
if status.ini_version then
|
||||
reserved_ids = font.nextid()-1
|
||||
lua.prepared_code[#lua.prepared_code+1] = string.format("font.define(%i, font.read_tfm(%q, %i))", reserved_ids, name, size)
|
||||
end
|
||||
local f = read_tfm(name, size)
|
||||
font.fonts[font.nextid()-1] = f
|
||||
return f
|
||||
end)
|
||||
local olddefinefont = font.define
|
||||
function font.define(i, f)
|
||||
if not f then
|
||||
f = i
|
||||
i = font.nextid(true)
|
||||
end
|
||||
function font.define(f)
|
||||
local i = olddefinefont(f)
|
||||
font.fonts[i] = f
|
||||
return olddefinefont(i, f)
|
||||
return i
|
||||
end
|
||||
callback.register('define_font', function(name, size)
|
||||
local f = read_tfm(name, size)
|
||||
local id = font.define(f)
|
||||
if status.ini_version then
|
||||
lua.prepared_code[#lua.prepared_code+1] = string.format("assert(%i == font.define(font.read_tfm(%q, %i)))", id, name, size)
|
||||
end
|
||||
return id
|
||||
end)
|
||||
-- do
|
||||
-- local register = callback.register
|
||||
-- function callback.register(...)
|
||||
@ -391,12 +387,7 @@ callback.register('show_error_message', function()
|
||||
texio.write_nl(status.lasterrorstring)
|
||||
end)
|
||||
callback.register('pre_dump', function()
|
||||
-- for k,v in pairs(callback.list()) do print('CB', k,v) end
|
||||
lua.bytecode[1], msg = load("do local id "
|
||||
.. "repeat id = font.nextid(true) "
|
||||
.. "until id == " .. reserved_ids
|
||||
.. " end "
|
||||
.. table.concat(lua.prepared_code, ' '))
|
||||
lua.bytecode[1] = assert(load(table.concat(lua.prepared_code, ' ')))
|
||||
end)
|
||||
if status.ini_version then
|
||||
lua.prepared_code = {}
|
||||
|
@ -1,7 +1,32 @@
|
||||
local format = string.format
|
||||
local concat = table.concat
|
||||
local write = texio.write_nl
|
||||
local properties = node.get_properties_table()
|
||||
local direct = node.direct
|
||||
local properties = direct.get_properties_table()
|
||||
local tonode = direct.tonode
|
||||
local todirect = direct.todirect
|
||||
local getid = direct.getid
|
||||
local traverse = direct.traverse
|
||||
local getsubtype = direct.getsubtype
|
||||
local setsubtype = direct.setsubtype
|
||||
local getdepth = direct.getdepth
|
||||
local getheight = direct.getheight
|
||||
local getwidth = direct.getwidth
|
||||
local setdepth = direct.setdepth
|
||||
local setheight = direct.setheight
|
||||
local setwidth = direct.setwidth
|
||||
local getshift = direct.getshift
|
||||
local getlist = direct.getlist
|
||||
local getkern = direct.getkern
|
||||
local getreplace = direct.getreplace
|
||||
local getleader = direct.getleader
|
||||
local setfont = direct.setfont
|
||||
local getfont = direct.getfont
|
||||
local getoffsets = direct.getoffsets
|
||||
local getnext = direct.getnext
|
||||
local getexpansion = direct.getexpansion
|
||||
local getchar = direct.getchar
|
||||
local rangedimensions = direct.rangedimensions
|
||||
local function doublekeyed(t, id2name, name2id, index)
|
||||
return setmetatable(t, {
|
||||
__index = index,
|
||||
@ -17,7 +42,7 @@ local function doublekeyed(t, id2name, name2id, index)
|
||||
end
|
||||
local nodehandler = (function()
|
||||
local function unknown_handler(_, n, x, y)
|
||||
write(format("Sorry, but the PDF backend does not support %q (id = %i) nodes right now. The supplied node will be dropped at coordinates (%i, %i).", node.type(n.id), n.id, x, y))
|
||||
write(format("Sorry, but the PDF backend does not support %q (id = %i) nodes right now. The supplied node will be dropped at coordinates (%i, %i).", node.type(getid(n)), getid(n), x, y))
|
||||
end
|
||||
return doublekeyed({}, node.type, node.id, function()
|
||||
return unknown_handler
|
||||
@ -26,11 +51,11 @@ end)()
|
||||
local whatsithandler = (function()
|
||||
local whatsits = node.whatsits()
|
||||
local function unknown_handler(p, n, x, y, ...)
|
||||
local prop = properties[n] or node.getproperty(n)
|
||||
local prop = properties[n]-- or node.getproperty(n)
|
||||
if prop and prop.handle then
|
||||
prop:handle(p, n, x, y, ...)
|
||||
else
|
||||
write(format("Sorry, but the PDF backend does not support %q (id = %i) whatsits right now. The supplied node will be dropped at coordinates (%i, %i).", whatsits[n.subtype], n.subtype, x, y))
|
||||
write(format("Sorry, but the PDF backend does not support %q (id = %i) whatsits right now. The supplied node will be dropped at coordinates (%i, %i).", whatsits[getsubtype(n)], getsubtype(n), x, y))
|
||||
end
|
||||
end
|
||||
return doublekeyed({}, function(n)return whatsits[n]end, function(n)return whatsits[n]end, function()
|
||||
@ -173,8 +198,8 @@ local function addlinkpoint(p, link, x, y, list, final)
|
||||
p.annots[#p.annots+1] = link.objnum .. " 0 R"
|
||||
end
|
||||
local m = p.matrix
|
||||
local lx, ly = projected_point(m, x, y-(link.depth or list.depth))
|
||||
local ux, uy = projected_point(m, x, y+(link.height or list.height))
|
||||
local lx, ly = projected_point(m, x, y-(link.depth or getdepth(list)))
|
||||
local ux, uy = projected_point(m, x, y+(link.height or getheight(list)))
|
||||
local n = #quads
|
||||
quads[n+1], quads[n+2], quads[n+3], quads[n+4] = lx, ly, ux, uy
|
||||
if final or (link.force_separate and (n+4)%8 == 0) then
|
||||
@ -185,20 +210,20 @@ local function addlinkpoint(p, link, x, y, list, final)
|
||||
end
|
||||
function nodehandler.hlist(p, list, x0, y, outerlist, origin, level)
|
||||
if outerlist then
|
||||
if outerlist.id == 0 then
|
||||
y = y - list.shift
|
||||
if getid(outerlist) == 0 then
|
||||
y = y - getshift(list)
|
||||
else
|
||||
x0 = x0 + list.shift
|
||||
x0 = x0 + getshift(list)
|
||||
end
|
||||
end
|
||||
local x = x0
|
||||
for _,l in ipairs(p.linkcontext) do if l.level == level+1 then
|
||||
addlinkpoint(p, l, x, y, list)
|
||||
end end
|
||||
for n in node.traverse(list.head) do
|
||||
local next = n.next
|
||||
local w = next and node.rangedimensions(list, n, next) or node.rangedimensions(list, n)
|
||||
nodehandler[n.id](p, n, x, y, list, x0, level+1)
|
||||
for n in traverse(getlist(list)) do
|
||||
local next = getnext(n)
|
||||
local w = next and rangedimensions(list, n, next) or rangedimensions(list, n)
|
||||
nodehandler[getid(n)](p, n, x, y, list, x0, level+1)
|
||||
x = w + x
|
||||
end
|
||||
for _,l in ipairs(p.linkcontext) do if l.level == level+1 then
|
||||
@ -207,29 +232,29 @@ function nodehandler.hlist(p, list, x0, y, outerlist, origin, level)
|
||||
end
|
||||
function nodehandler.vlist(p, list, x, y0, outerlist, origin, level)
|
||||
if outerlist then
|
||||
if outerlist.id == 0 then
|
||||
y0 = y0 - list.shift
|
||||
if getid(outerlist) == 0 then
|
||||
y0 = y0 - getshift(list)
|
||||
else
|
||||
x = x + list.shift
|
||||
x = x + getshift(list)
|
||||
end
|
||||
end
|
||||
y0 = y0 + list.height
|
||||
y0 = y0 + getheight(list)
|
||||
local y = y0
|
||||
for n in node.traverse(list.head) do
|
||||
local d, h, _ = 0, node.effective_glue(n, list) or math.tointeger(n.kern)
|
||||
for n in traverse(getlist(list)) do
|
||||
local d, h, _ = 0, direct.effective_glue(n, list) or math.tointeger(getkern(n))
|
||||
if not h then
|
||||
_, h, d = node.direct.getwhd(node.direct.todirect(n))
|
||||
_, h, d = direct.getwhd(n)
|
||||
end
|
||||
y = y - (h or 0)
|
||||
nodehandler[n.id](p, n, x, y, list, y0, level+1)
|
||||
nodehandler[getid(n)](p, n, x, y, list, y0, level+1)
|
||||
y = y - (d or 0)
|
||||
end
|
||||
end
|
||||
function nodehandler.rule(p, n, x, y, outer)
|
||||
if n.width == -1073741824 then n.width = outer.width end
|
||||
if n.height == -1073741824 then n.height = outer.height end
|
||||
if n.depth == -1073741824 then n.depth = outer.depth end
|
||||
local sub = n.subtype
|
||||
if getwidth(n) == -1073741824 then setwidth(n, getwidth(outer)) end
|
||||
if getheight(n) == -1073741824 then setheight(n, getheight(outer)) end
|
||||
if getdepth(n) == -1073741824 then setdepth(n, getdepth(outer)) end
|
||||
local sub = getsubtype(n)
|
||||
if sub == 1 then
|
||||
error[[We can't handle boxes yet]]
|
||||
elseif sub == 2 then
|
||||
@ -240,42 +265,42 @@ function nodehandler.rule(p, n, x, y, outer)
|
||||
elseif sub == 9 then
|
||||
error[[We can't handle outline rules yet]]
|
||||
else
|
||||
if n.width <= 0 or n.depth + n.height <= 0 then return end
|
||||
if getwidth(n) <= 0 or getdepth(n) + getheight(n) <= 0 then return end
|
||||
topage(p)
|
||||
p.strings[#p.strings+1] = gsub(format("%f %f %f %f re f", sp2bp(x), sp2bp(y - n.depth), sp2bp(n.width), sp2bp(n.depth + n.height)), '%.?0+ ', ' ')
|
||||
p.strings[#p.strings+1] = gsub(format("%f %f %f %f re f", sp2bp(x), sp2bp(y - getdepth(n)), sp2bp(getwidth(n)), sp2bp(getdepth(n) + getheight(n))), '%.?0+ ', ' ')
|
||||
end
|
||||
end
|
||||
function nodehandler.boundary() end
|
||||
function nodehandler.disc(p, n, x, y, list, ...) -- FIXME: I am not sure why this can happen, let's assume we can use .replace
|
||||
for n in node.traverse(n.replace) do
|
||||
local next = n.next
|
||||
local w = next and node.rangedimensions(list, n, next) or node.rangedimensions(list, n)
|
||||
nodehandler[n.id](p, n, x, y, list, ...)
|
||||
for n in traverse(getreplace(n)) do
|
||||
local next = getnext(n)
|
||||
local w = next and rangedimensions(list, n, next) or rangedimensions(list, n)
|
||||
nodehandler[getid(n)](p, n, x, y, list, ...)
|
||||
x = w + x
|
||||
end
|
||||
end
|
||||
function nodehandler.local_par() end
|
||||
function nodehandler.math() end
|
||||
function nodehandler.glue(p, n, x, y, outer, origin, level) -- Naturally this is an interesting one.
|
||||
local subtype = n.subtype
|
||||
local subtype = getsubtype(n)
|
||||
if subtype < 100 then return end -- We only really care about leaders
|
||||
local leader = n.leader
|
||||
local w = node.effective_glue(n, outer)
|
||||
if leader.id == 2 then -- We got a rule, this should be easy
|
||||
if outer.id == 0 then
|
||||
leader.width = w
|
||||
local leader = getleader(n)
|
||||
local w = direct.effective_glue(n, outer)
|
||||
if getid(leader) == 2 then -- We got a rule, this should be easy
|
||||
if getid(outer) == 0 then
|
||||
setwidth(leader, w)
|
||||
else
|
||||
leader.height = w
|
||||
leader.depth = 0
|
||||
setheight(leader, w)
|
||||
setdepth(leader, 0)
|
||||
end
|
||||
return nodehandler.rule(p, leader, x, y, outer)
|
||||
end
|
||||
local lwidth = outer.id == 0 and leader.width or leader.height + leader.depth
|
||||
if outer.id ~= 0 then
|
||||
local lwidth = getid(outer) == 0 and getwidth(leader) or getheight(leader) + getdepth(leader)
|
||||
if getid(outer) ~= 0 then
|
||||
y = y + w
|
||||
end
|
||||
if subtype == 100 then
|
||||
if outer.id == 0 then
|
||||
if getid(outer) == 0 then
|
||||
local newx = ((x-origin - 1)//lwidth + 1) * lwidth + origin
|
||||
-- local newx = -(origin-x)//lwidth * lwidth + origin
|
||||
w = w + x - newx
|
||||
@ -288,7 +313,7 @@ function nodehandler.glue(p, n, x, y, outer, origin, level) -- Naturally this is
|
||||
end
|
||||
elseif subtype == 101 then
|
||||
local inner = w - (w // lwidth) * lwidth
|
||||
if outer.id == 0 then
|
||||
if getid(outer) == 0 then
|
||||
x = x + inner/2
|
||||
else
|
||||
y = y - inner/2
|
||||
@ -296,14 +321,14 @@ function nodehandler.glue(p, n, x, y, outer, origin, level) -- Naturally this is
|
||||
elseif subtype == 102 then
|
||||
local count = w // lwidth
|
||||
local skip = (w - count * lwidth) / (count + 1)
|
||||
if outer.id == 0 then
|
||||
if getid(outer) == 0 then
|
||||
x = x + skip
|
||||
else
|
||||
y = y - skip
|
||||
end
|
||||
lwidth = lwidth + skip
|
||||
elseif subtype == 103 then
|
||||
if outer.id == 0 then
|
||||
if getid(outer) == 0 then
|
||||
local newx = ((x - 1)//lwidth + 1) * lwidth
|
||||
w = w + x - newx
|
||||
x = newx
|
||||
@ -313,15 +338,15 @@ function nodehandler.glue(p, n, x, y, outer, origin, level) -- Naturally this is
|
||||
y = newy
|
||||
end
|
||||
end
|
||||
local handler = nodehandler[leader.id]
|
||||
if outer.id == 0 then
|
||||
local handler = nodehandler[getid(leader)]
|
||||
if getid(outer) == 0 then
|
||||
while w >= lwidth do
|
||||
handler(p, leader, x, y, outer, origin, level+1)
|
||||
w = w - lwidth
|
||||
x = x + lwidth
|
||||
end
|
||||
else
|
||||
y = y - leader.height
|
||||
y = y - getheight(leader)
|
||||
while w >= lwidth do
|
||||
handler(p, leader, x, y, outer, origin, level+1)
|
||||
w = w - lwidth
|
||||
@ -339,28 +364,31 @@ local function do_commands(p, c, f, fid, x, y, outer, ...)
|
||||
for _, cmd in ipairs(c.commands) do
|
||||
if cmd[1] == "node" then
|
||||
local cmd = cmd[2]
|
||||
nodehandler[cmd.id](p, cmd, x, y, nil, ...)
|
||||
x = x + cmd.width
|
||||
nodehandler[getid(cmd)](p, cmd, x, y, nil, ...)
|
||||
x = x + getwidth(cmd)
|
||||
elseif cmd[1] == "font" then
|
||||
current_font = fonts[cmd[2]]
|
||||
elseif cmd[1] == "char" then
|
||||
local n = node.new'glyph'
|
||||
n.subtype, n.font, n.char = 256, current_font.id, cmd[2]
|
||||
local n = direct.new'glyph'
|
||||
setsubtype(n, 256)
|
||||
setfont(n, current_font.id, cmd[2])
|
||||
nodehandler.glyph(p, n, x, y, outer, ...)
|
||||
node.free(n)
|
||||
x = x + n.width
|
||||
direct.free(n)
|
||||
x = x + getwidth(n)
|
||||
elseif cmd[1] == "slot" then
|
||||
local n = node.new'glyph'
|
||||
n.subtype, n.font, n.char = 256, cmd[2], cmd[3]
|
||||
local n = direct.new'glyph'
|
||||
setsubtype(n, 256)
|
||||
setfont(n, cmd[2], cmd[3])
|
||||
nodehandler.glyph(p, n, x, y, outer, ...)
|
||||
node.free(n)
|
||||
x = x + n.width
|
||||
direct.free(n)
|
||||
x = x + getwidth(n)
|
||||
elseif cmd[1] == "rule" then
|
||||
local n = node.new'rule'
|
||||
n.height, n.width = cmd[2], cmd[3]
|
||||
local n = direct.new'rule'
|
||||
setheight(n, cmd[2])
|
||||
setwidth(n, cmd[3])
|
||||
nodehandler.rule(p, n, x, y, outer, ...)
|
||||
node.free(n)
|
||||
x = x + n.width
|
||||
direct.free(n)
|
||||
x = x + getwidth(n)
|
||||
elseif cmd[1] == "left" then
|
||||
x = x + cmd[2]
|
||||
elseif cmd[1] == "down" then
|
||||
@ -389,26 +417,27 @@ local function do_commands(p, c, f, fid, x, y, outer, ...)
|
||||
if #commands ~= 1 then error[[Unsupported command number]] end
|
||||
if commands[1][1] ~= "node" then error[[Unsupported command name]] end
|
||||
commands = commands[1][2]
|
||||
nodehandler[commands.id](p, commands, x, y, nil, ...)
|
||||
nodehandler[getid(commands)](p, commands, x, y, nil, ...)
|
||||
end
|
||||
end
|
||||
function nodehandler.glyph(p, n, x, y, ...)
|
||||
if n.font ~= p.vfont.fid then
|
||||
p.vfont.fid = n.font
|
||||
p.vfont.font = font.getfont(n.font) or font.fonts[n.font]
|
||||
if getfont(n) ~= p.vfont.fid then
|
||||
p.vfont.fid = getfont(n)
|
||||
p.vfont.font = font.getfont(getfont(n)) or font.fonts[getfont(n)]
|
||||
end
|
||||
local f, fid = p.vfont.font, p.vfont.fid
|
||||
local c = f.characters[n.char]
|
||||
local c = f.characters[getchar(n)]
|
||||
if not c then
|
||||
texio.write_nl("Missing character")
|
||||
return
|
||||
end
|
||||
if c.commands then return do_commands(p, c, f, fid, x, y, ...) end
|
||||
toglyph(p, n.font, x + n.xoffset, y + n.yoffset, n.expansion_factor)
|
||||
local xoffset, yoffset = getoffsets(n)
|
||||
toglyph(p, getfont(n), x + xoffset, y + yoffset, getexpansion(n))
|
||||
local index = c.index
|
||||
if index then
|
||||
-- if f.encodingbytes == -3 then
|
||||
if true then
|
||||
if false then
|
||||
if index < 0x80 then
|
||||
p.pending[#p.pending+1] = match(literalescape, string.pack('>B', index))
|
||||
elseif index < 0x7F80 then
|
||||
@ -423,15 +452,15 @@ function nodehandler.glyph(p, n, x, y, ...)
|
||||
p.usedglyphs[index] = {index, math.floor(c.width * 1000 / f.size + .5), c.tounicode}
|
||||
end
|
||||
else
|
||||
p.pending[#p.pending+1] = match(literalescape, string.char(n.char))
|
||||
if not p.usedglyphs[n.char] then
|
||||
p.usedglyphs[n.char] = {n.char, math.floor(c.width * 1000 / f.size + .5), c.tounicode}
|
||||
p.pending[#p.pending+1] = match(literalescape, string.char(getchar(n)))
|
||||
if not p.usedglyphs[getchar(n)] then
|
||||
p.usedglyphs[getchar(n)] = {getchar(n), math.floor(c.width * 1000 / f.size + .5), c.tounicode}
|
||||
end
|
||||
end
|
||||
p.pos.x = p.pos.x + math.floor(n.width*(1+n.expansion_factor/1000000)+.5)
|
||||
p.pos.x = p.pos.x + math.floor(getwidth(n)*(1+getexpansion(n)/1000000)+.5)
|
||||
end
|
||||
function nodehandler.whatsit(p, n, ...) -- Whatsit?
|
||||
return whatsithandler[n.subtype](p, n, ...)
|
||||
return whatsithandler[getsubtype(n)](p, n, ...)
|
||||
end
|
||||
--[[ -- These use the old whatsit handling system which might get removed.
|
||||
function whatsithandler.pdf_save(p, n, x, y, outer)
|
||||
@ -514,6 +543,7 @@ local function writeresources(p)
|
||||
end
|
||||
local fontnames = setmetatable({}, {__index = function(t, k) local res = format("F%i", k) t[k] = res return res end})
|
||||
return function(file, n, fontdirs, usedglyphs, colorstacks)
|
||||
n = todirect(n)
|
||||
setmetatable(usedglyphs, ondemandmeta)
|
||||
local linkcontext = file.linkcontext
|
||||
if not linkcontext then
|
||||
@ -552,8 +582,8 @@ return function(file, n, fontdirs, usedglyphs, colorstacks)
|
||||
end
|
||||
end
|
||||
end
|
||||
nodehandler[n.id](p, n, 0, 0, n, nil, 0)
|
||||
-- nodehandler[n.id](p, n, 0, n.depth, n)
|
||||
nodehandler[getid(n)](p, n, 0, 0, n, nil, 0)
|
||||
-- nodehandler[getid(n)](p, n, 0, getdepth(n), n)
|
||||
topage(p)
|
||||
return concat(p.strings, '\n'), writeresources(p), (p.annots[1] and string.format("/Annots[%s]", table.concat(p.annots, ' ')) or "")
|
||||
end
|
||||
|
@ -209,7 +209,7 @@ local function buildfont0(pdf, fontdir, usedcids)
|
||||
local enc
|
||||
if fontdir.encodingbytes == 1 then
|
||||
enc = cidmap1byte(pdf)
|
||||
elseif true then -- FIXME: This should only be used for encodingbyzes == -3 (variable, max 3)
|
||||
elseif false then -- FIXME: This should only be used for encodingbyzes == -3 (variable, max 3)
|
||||
fontdir.encodingbytes = -3 -- FIXME
|
||||
enc = cidmap3byte(pdf)
|
||||
else
|
||||
|
@ -27,7 +27,7 @@
|
||||
\let\savedversionofdump\dump
|
||||
\let\dump\relax
|
||||
\input latex.ltx
|
||||
\input luametalatex-baseregisters
|
||||
% \input luametalatex-baseregisters
|
||||
\let\dump\savedversionofdump
|
||||
\let\savedversionofdump\undefined
|
||||
\directlua{fixupluafunctions()}%
|
||||
|
@ -83,7 +83,7 @@ local dir = absdir(os.selfdir)
|
||||
local dirseparators = {((lpeg.S'\\/'^1 + 1 * lpeg.P':' * lpeg.S'\\/'^-1) * lpeg.Cp() * ((1-lpeg.S'\\/')^0*lpeg.S'\\/'*lpeg.Cp())^0):match(dir)}
|
||||
-- First step: Find our actual format.
|
||||
local init_script = format .. "-init.lua"
|
||||
local texmf_dir = "tex/lualatex/" .. format .. '/' .. init_script
|
||||
local texmf_dir = "tex/luametalatex/" .. format .. '/' .. init_script
|
||||
local paths = {
|
||||
init_script,
|
||||
"share/texmf-local/" .. texmf_dir,
|
||||
|
44
module.lua
Normal file
44
module.lua
Normal file
@ -0,0 +1,44 @@
|
||||
local loaded = package.loaded
|
||||
local findtable = lpeg.Cf(lpeg.Cc(_G) * (lpeg.C((1-lpeg.P'.')^0) * '.')^0 * lpeg.C((1-lpeg.P'.')^0) * -1,
|
||||
function(t, name)
|
||||
local subtable = t[name]
|
||||
if subtable == nil then
|
||||
subtable = {}
|
||||
t[name] = subtable
|
||||
elseif type(subtable) ~= "table" then
|
||||
error("Naming conflict for (sub)module " .. name)
|
||||
end
|
||||
return subtable
|
||||
end)
|
||||
local package_patt = lpeg.C(((1-lpeg.P'.')^0 * '.')^0) * (1-lpeg.P'.')^0 * -1
|
||||
function module(name, ...)
|
||||
local modtable = loaded[name]
|
||||
if type(modtable) ~= "table" then
|
||||
modtable = findtable:match(name)
|
||||
loaded[name] = modtable
|
||||
end
|
||||
if modtable._NAME == nil then
|
||||
modtable._M = modtable
|
||||
modtable._NAME = name
|
||||
modtable._PACKAGE = package_patt:match(name)
|
||||
end
|
||||
local info = debug.getinfo(2, "fS")
|
||||
if not info or info.what == "C" then
|
||||
error[['module' should only be called from Lua functions]]
|
||||
end
|
||||
debug.setupvalue(info.func, 1, modtable)
|
||||
for i = 1, select('#', ...) do
|
||||
local opt = select(i, ...) if type(opt) == "function" then
|
||||
opt(modtable)
|
||||
end
|
||||
end
|
||||
return modtable
|
||||
end
|
||||
function package.seeall(modtable)
|
||||
local meta = getmetatable(modtable)
|
||||
if not meta then
|
||||
meta = {}
|
||||
setmetatable(modtable, meta)
|
||||
end
|
||||
meta.__index = _G
|
||||
end
|
Loading…
Reference in New Issue
Block a user