Skip to content

Commit

Permalink
Adjust to newer LuaMetaTeX versions
Browse files Browse the repository at this point in the history
  • Loading branch information
zauguin committed Jan 2, 2020
1 parent 29c9780 commit b5c91c4
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 111 deletions.
65 changes: 65 additions & 0 deletions ltexpl.ltx
Original file line number Diff line number Diff line change
@@ -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'.
3 changes: 2 additions & 1 deletion luametalatex-back-pdf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions luametalatex-baseregisters.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions luametalatex-dev-init.lua
1 change: 1 addition & 0 deletions luametalatex-dev.lua
14 changes: 7 additions & 7 deletions luametalatex-firstcode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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'
Expand Down
35 changes: 13 additions & 22 deletions luametalatex-init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -352,24 +352,20 @@ pdf = {
return id
end,
}
local olddefinefont = font.define
function font.define(f)
local i = olddefinefont(f)
font.fonts[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
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)
lua.prepared_code[#lua.prepared_code+1] = string.format("assert(%i == font.define(font.read_tfm(%q, %i)))", id, name, size)
end
local f = read_tfm(name, size)
font.fonts[font.nextid()-1] = f
return f
return id
end)
local olddefinefont = font.define
function font.define(i, f)
if not f then
f = i
i = font.nextid(true)
end
font.fonts[i] = f
return olddefinefont(i, f)
end
-- do
-- local register = callback.register
-- function callback.register(...)
Expand All @@ -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 = {}
Expand Down
Loading

0 comments on commit b5c91c4

Please sign in to comment.