Adapt to new luametatex version

This commit is contained in:
Marcel Fabian Krüger 2021-11-06 11:38:39 +01:00
parent 870ab69578
commit d61bb927a3
10 changed files with 121 additions and 28 deletions

View File

@ -1,4 +1,4 @@
local scan_int = token.scan_integer local scan_int = token.scan_int
local scan_token = token.scan_token local scan_token = token.scan_token
local scan_keyword = token.scan_keyword local scan_keyword = token.scan_keyword
local scan_string = token.scan_string local scan_string = token.scan_string

View File

@ -1,5 +1,5 @@
local scan_dimen = token.scan_dimen local scan_dimen = token.scan_dimen
local scan_int = token.scan_integer local scan_int = token.scan_int
local scan_keyword = token.scan_keyword local scan_keyword = token.scan_keyword
local count_code = token.value.integer local count_code = token.value.integer
@ -118,6 +118,8 @@ end
tex_variable(count_code, scan_int, 'suppressfontnotfounderror', 0) tex_variable(count_code, scan_int, 'suppressfontnotfounderror', 0)
tex_variable(count_code, scan_int, 'outputmode', 1) -- The "traditional" default would be 0, tex_variable(count_code, scan_int, 'outputmode', 1) -- The "traditional" default would be 0,
-- but we do not actually support that. -- but we do not actually support that.
tex_variable(count_code, scan_int, 'tracingscantokens', 0)
tex_variable(dimen_code, scan_dimen, 'pageheight', 0) tex_variable(dimen_code, scan_dimen, 'pageheight', 0)
tex_variable(dimen_code, scan_dimen, 'pagewidth', 0) tex_variable(dimen_code, scan_dimen, 'pagewidth', 0)

View File

@ -1,4 +1,4 @@
local scan_int = token.scan_integer local scan_int = token.scan_int
local scan_keyword = token.scan_keyword local scan_keyword = token.scan_keyword
-- local names = {} -- local names = {}

View File

@ -1,7 +1,7 @@
local scan_int = token.scan_integer local scan_int = token.scan_int
token.scan_int = scan_int -- For compatibility with LuaTeX packages token.scan_int = scan_int -- For compatibility with LuaTeX packages
local scan_token = token.scan_token local scan_token = token.scan_token
local scan_tokenlist = token.scan_tokenlist local scan_tokenlist = token.scantokenlist
local scan_keyword = token.scan_keyword local scan_keyword = token.scan_keyword
local scan_csname = token.scan_csname local scan_csname = token.scan_csname
local set_macro = token.set_macro local set_macro = token.set_macro
@ -77,15 +77,15 @@ end
local open_whatsit = new_whatsit('open', do_openout) local open_whatsit = new_whatsit('open', do_openout)
token.luacmd("openout", function(_, immediate) -- \openout token.luacmd("openout", function(_, immediate) -- \openout
if immediate == "value" then return end if immediate == "value" then return end
if immediate and immediate & 0x7 ~= 0 then if immediate and immediate & ~0x2000 ~= 0 then
immediate = immediate & 0x8 immediate = immediate & 0x2000
tex.error("Unexpected prefix", "You used \\openout with a prefix that doesn't belong there. I will ignore it for now.") tex.error("Unexpected prefix", "You used \\openout with a prefix that doesn't belong there. I will ignore it for now.")
end end
local file = scan_int() local file = scan_int()
scan_keyword'=' scan_keyword'='
local name = scan_filename() local name = scan_filename()
local props = {file = file, name = name} local props = {file = file, name = name}
if immediate and immediate == 8 then if immediate and immediate == 0x2000 then
do_openout(props) do_openout(props)
else else
local whatsit = node.direct.new(whatsit_id, open_whatsit) local whatsit = node.direct.new(whatsit_id, open_whatsit)
@ -114,13 +114,13 @@ end
local close_whatsit = new_whatsit('close', do_closeout) local close_whatsit = new_whatsit('close', do_closeout)
token.luacmd("closeout", function(_, immediate) -- \closeout token.luacmd("closeout", function(_, immediate) -- \closeout
if immediate == "value" then return end if immediate == "value" then return end
if immediate and immediate & 0x7 ~= 0 then if immediate and immediate & ~0x2000 ~= 0 then
immediate = immediate & 0x8 immediate = immediate & 0x2000
tex.error("Unexpected prefix", "You used \\closeout with a prefix that doesn't belong there. I will ignore it for now.") tex.error("Unexpected prefix", "You used \\closeout with a prefix that doesn't belong there. I will ignore it for now.")
end end
local file = scan_int() local file = scan_int()
local props = {file = file} local props = {file = file}
if immediate == 8 then if immediate == 0x2000 then
do_closeout(props) do_closeout(props)
else else
local whatsit = node.direct.new(whatsit_id, close_whatsit) local whatsit = node.direct.new(whatsit_id, close_whatsit)
@ -148,16 +148,16 @@ local function do_write(p)
end end
end end
local write_whatsit = new_whatsit('write', do_write) local write_whatsit = new_whatsit('write', do_write)
token.luacmd("write", function(_, immediate) -- \write token.luacmd("write", function(_, immediate, ...) -- \write
if immediate == "value" then return end if immediate == "value" then return end
if immediate and immediate & 0x7 ~= 0 then if immediate and immediate & ~0x2000 ~= 0 then
immediate = immediate & 0x8 immediate = immediate & 0x2000
tex.error("Unexpected prefix", "You used \\write with a prefix that doesn't belong there. I will ignore it for now.") tex.error("Unexpected prefix", "You used \\write with a prefix that doesn't belong there. I will ignore it for now.")
end end
local file = scan_int() local file = scan_int()
local content = scan_tokenlist() local content = scan_tokenlist()
local props = {file = file, data = content} local props = {file = file, data = content}
if immediate == 8 then if immediate == 0x2000 then
do_write(props) do_write(props)
else else
local whatsit = node.direct.new(whatsit_id, write_whatsit) local whatsit = node.direct.new(whatsit_id, write_whatsit)
@ -205,13 +205,13 @@ token.luacmd("read", function(_, prefix)
end end
local endlocal local endlocal
tex.runlocal(function() tex.runlocal(function()
endlocal = token.scan_next() endlocal = token.get_next()
tex.sprint(endlocal) tex.sprint(endlocal)
tex.print(line and line ~= "" and line or " ") tex.print(line and line ~= "" and line or " ")
tex.print(endlocal) tex.print(endlocal)
end) end)
while true do while true do
local tok = token.scan_next() local tok = token.get_next()
if tok == endlocal then break end if tok == endlocal then break end
if tok.command == 1 then if tok.command == 1 then
balance = balance + 1 balance = balance + 1

View File

@ -14,6 +14,7 @@ pdf = {
} }
require'luametalatex-font-resolve' -- Replace font.define. Must be loaded before callbacks require'luametalatex-font-resolve' -- Replace font.define. Must be loaded before callbacks
require'luametalatex-basecallbacks' require'luametalatex-basecallbacks'
require'luametalatex-oldnames'
local callbacks = require'luametalatex-callbacks' local callbacks = require'luametalatex-callbacks'
local function swap_table(t) local function swap_table(t)
@ -80,8 +81,8 @@ function token.luacmd(name, func, ...)
idx = tok.index idx = tok.index
elseif cmd == lua_protected_call_cmd then elseif cmd == lua_protected_call_cmd then
idx = tok.index idx = tok.index
elseif cmd == if_test_cmd and tok.index > 49 then elseif cmd == if_test_cmd and tok.index > 53 then
idx = tok.index - 49 idx = tok.index - 53
elseif ... == 'force' then elseif ... == 'force' then
idx = new_luafunction(name) idx = new_luafunction(name)
set_lua(name, idx, select(2, ...)) set_lua(name, idx, select(2, ...))

View File

@ -10,9 +10,9 @@ local primitive_meaning = {
token.primitive_tokens.meaning, token.primitive_tokens.meaning,
} }
token.luacmd("meaning", function() token.luacmd("meaning", function()
local peeked = token.peek_next() local peeked = token.peeknext()
token.put_next(primitive_meaning) token.put_next(primitive_meaning)
token.skip_next_expanded() token.skipnextexpanded()
if peeked.parameters == 0 then if peeked.parameters == 0 then
tex.sprint'->' tex.sprint'->'
end end

View File

@ -24,10 +24,10 @@
\noexpand\luametalatex@@everyjobandnow{\noexpand\directlua{! \noexpand\luametalatex@@everyjobandnow{\noexpand\directlua{!
lua.get_functions_table()[\the\luametalatex@@expandglyphsinfont] = function() lua.get_functions_table()[\the\luametalatex@@expandglyphsinfont] = function()
token.put_next(token.create'fontid') token.put_next(token.create'fontid')
local font = token.scan_integer() local font = token.scan_int()
local stretch = token.scan_integer() local stretch = token.scan_int()
local shrink = token.scan_integer() local shrink = token.scan_int()
local step = token.scan_integer() local step = token.scan_int()
token.set_macro('pickup@font@@hook@luametalatex@microtype@' .. font, string.format("{}{%i}{%i}{%i}", stretch, shrink, step), "global") token.set_macro('pickup@font@@hook@luametalatex@microtype@' .. font, string.format("{}{%i}{%i}{%i}", stretch, shrink, step), "global")
end end
}} }}

View File

@ -43,6 +43,7 @@ local get_whatsit_handler = require'luametalatex-whatsits'.handler
local write_matrix -- Defined later local write_matrix -- Defined later
local dir_id = node.id'dir' local dir_id = node.id'dir'
local glue_id = node.id'glue'
local function doublekeyed(t, id2name, name2id, index) local function doublekeyed(t, id2name, name2id, index)
return setmetatable(t, { return setmetatable(t, {
@ -356,7 +357,7 @@ function nodehandler.vlist(p, list, x, y0, outerlist, origin, level)
local y = y0 local y = y0
y = y + height y = y + height
for n in traverse(getlist(list)) do for n in traverse(getlist(list)) do
local d, h, _ = 0, direct.effective_glue(n, list) or math.tointeger(getkern(n)) local d, h, _ = 0, getid(n) == glue_id and direct.effective_glue(n, list) or math.tointeger(getkern(n))
if not h then if not h then
_, h, d = direct.getwhd(n) _, h, d = direct.getwhd(n)
end end

72
luametalatex-oldnames.lua Normal file
View File

@ -0,0 +1,72 @@
local function rewrite(t)
local function handler(old, new)
t[old] = t[old] or t[new]
if not t[old] then print('!!!', old) end
return handler
end
return handler
end
rewrite(language)
('clear_hyphenation', 'clearhyphenation')
('clear_patterns', 'clearpatterns')
rewrite(node)
('copy_list', 'copylist')
('flush_list', 'flushlist')
('flush_node', 'flushnode')
('get_properties_table', 'getpropertiestable')
('has_field', 'hasfield')
('insert_after', 'insertafter')
('insert_before', 'insertbefore')
('is_node', 'isnode')
rewrite(node.direct)
('copy_list', 'copylist')
('effective_glue', 'effectiveglue')
('end_of_math', 'endofmath')
('first_glyph', 'firstglyph')
('flush_list', 'flushlist')
('flush_node', 'flushnode')
('get_attribute', 'getattribute')
('get_properties_table', 'getpropertiestable')
('has_field', 'hasfield')
('has_glyph', 'hasglyph')
('insert_after', 'insertafter')
('insert_before', 'insertbefore')
('is_char', 'ischar')
('is_direct', 'isdirect')
('is_glyph', 'isglyph')
('is_node', 'isnode')
('is_zero_glue', 'iszeroglue')
('last_node', 'lastnode')
('make_extensible', 'makeextensible')
('mlist_to_hlist', 'mlisttohlist')
('protect_glyph', 'protectglyph')
('protect_glyphs', 'protectglyphs')
('traverse_char', 'traversechar')
('traverse_list', 'traverselist')
('traverse_id', 'traverseid')
('unprotect_glyph', 'unprotectglyph')
('unprotect_glyphs', 'unprotectglyphs')
('uses_font', 'usesfont')
rewrite(token)
('get_next', 'scannext')
('put_next', 'putnext')
('scan_argument', 'scanargument')
('scan_box', 'scanbox')
('scan_code', 'scancode')
('scan_csname', 'scancsname')
('scan_dimen', 'scandimen')
('scan_float', 'scanfloat')
('scan_glue', 'scanglue')
('scan_int', 'scaninteger')
('scan_keyword', 'scankeyword')
('scan_keywordcs', 'scankeywordcs')
('scan_real', 'scanreal')
('scan_string', 'scanstring')
('scan_token', 'scannextexpanded')
('scan_toks', 'scantoks')
('scan_word', 'scanword')
('set_lua', 'setlua')

View File

@ -31,7 +31,24 @@
% so can now be read using the (emulated) primitives % so can now be read using the (emulated) primitives
% This needs to be global so set \globaldefs for the rest of the group % This needs to be global so set \globaldefs for the rest of the group
\globaldefs=1 % \globaldefs=1 %
\input{pdftexconfig}% % \input{pdftexconfig}%
% Copied in here because the original uses `true` dimensions which aren't supported
\pdfoutput = 1
% Paper size: dimensions given in absolute terms
\pdfpageheight = 297 mm
\pdfpagewidth = 210 mm
% Enable PDF 1.5 output and thus more compression
\pdfminorversion = 5
\pdfobjcompresslevel = 2
% Low-level settings unlikely ever to need to change
\pdfcompresslevel = 9
\pdfdecimaldigits = 3
\pdfpkresolution = 600
\pdfhorigin = 1 in
\pdfvorigin = 1 in
% Pick up on a request for DVI mode and apply it whilst \pdfoutput is % Pick up on a request for DVI mode and apply it whilst \pdfoutput is
% still defined % still defined
\ifx\dvimode\relax \ifx\dvimode\relax