From 3d7380f76a65e69602359cfdf7aa9e9698290fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Fri, 3 Jul 2020 03:54:30 +0200 Subject: [PATCH] Use cs independent command tokens --- luametalatex-back-pdf.lua | 16 ++++++++++++++-- luametalatex-local.lua | 3 +-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/luametalatex-back-pdf.lua b/luametalatex-back-pdf.lua index 49c1e0e..56d2df6 100644 --- a/luametalatex-back-pdf.lua +++ b/luametalatex-back-pdf.lua @@ -34,6 +34,18 @@ local function get_outline() return outline end local properties = node.direct.properties +local immediateassignment = token.new(5, token.command_id'convert') +local global = token.new(0, token.command_id'prefix') +local deadcycles = token.new(8, token.command_id'set_page_property') +local zero_tok = token.create(0x30) +local relax = token.new(0, 0) +local reset_deadcycles = { + immediateassignment, + global, + deadcycles, + zero_tok, + relax, +} token.luacmd("shipout", function() local pfile = get_pfile() local voff = node.new'kern' @@ -50,7 +62,7 @@ token.luacmd("shipout", function() local content = pfile:stream(nil, '', out) pfile:indirect(page, string.format([[<>%s%s>>]], parent, content, -math.ceil(list.depth/65781.76), math.ceil(list.width/65781.76), math.ceil(list.height/65781.76), resources, pdfvariable.pageresources, annots, pdfvariable.pageattr)) node.flush_list(list) - token.put_next(token.create'immediateassignment', token.create'global', token.create'deadcycles', token.create(0x30), token.create'relax') + token.put_next(reset_deadcycles) token.scan_token() end, 'force', 'protected') @@ -92,7 +104,7 @@ callback.register("stop_run", function() local psname = f.psname or f.fullname local sorted = {} for k,v in pairs(usedglyphs[fid]) do - sorted[#sorted+1] = v + sorted[#sorted+1] = v end table.sort(sorted, function(a,b) return a[1] < b[1] end) pfile:indirect(id, require'luametalatex-pdf-font'(pfile, f, sorted)) diff --git a/luametalatex-local.lua b/luametalatex-local.lua index 488acb2..30b9c9b 100644 --- a/luametalatex-local.lua +++ b/luametalatex-local.lua @@ -12,8 +12,7 @@ lua.get_functions_table()[restore_func] = function() end end end -local lua_call = token.command_id'lua_call' -local restore_toks = {token.create'atendofgroup', token.new(restore_func, lua_call)} +local restore_toks = {token.new(2, token.command_id'after_something') , token.new(restore_func, token.command_id'lua_call')} -- \atendofgroup FIXME: Detect mode automatically once token.primitive is fixed local put_next = token.put_next local runtoks = tex.runtoks local function put_restore_toks()