From 343da17f3085b68c914320ae30eb0f913f1464fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Thu, 9 Jul 2020 17:32:42 +0200 Subject: [PATCH] \savepos --- luametalatex-back-pdf.lua | 16 ++++++++++++++++ luametalatex-firstcode.lua | 5 +---- luametalatex-nodewriter.lua | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/luametalatex-back-pdf.lua b/luametalatex-back-pdf.lua index ba70d4f..39f1e48 100644 --- a/luametalatex-back-pdf.lua +++ b/luametalatex-back-pdf.lua @@ -904,3 +904,19 @@ end, "protected") token.luacmd("lastsavedboxresourceindex", function() return integer_code, lastbox end, "protected", "value") + +local saved_pos_x, saved_pos_y = -1, -1 +local save_pos_whatsit = declare_whatsit('save_pos', function(_, _, _, x, y) + saved_pos_x, saved_pos_y = assert(math.tointeger(x)), assert(math.tointeger(y)) +end) +token.luacmd("savepos", function() -- \savepos + return node.direct.write(node.direct.new(whatsit_id, save_pos_whatsit)) +end, "protected") + +token.luacmd("lastxpos", function() + return integer_code, (saved_pos_x+.5)//1 +end, "protected", "value") + +token.luacmd("lastypos", function() + return integer_code, (saved_pos_y+.5)//1 +end, "protected", "value") diff --git a/luametalatex-firstcode.lua b/luametalatex-firstcode.lua index a60f96a..51d567e 100644 --- a/luametalatex-firstcode.lua +++ b/luametalatex-firstcode.lua @@ -114,10 +114,7 @@ token.luacmd("immediate", function() -- \immediate local function_id = next_tok.index return functions[function_id](function_id, 'immediate') end, "protected") --- functions[43] = function() -- \pdfvariable --- local name = token.scan_string() --- print('Missing \\pdf' .. name) --- end + require'luametalatex-baseregisters' require'luametalatex-back-pdf' require'luametalatex-node-luaotfload' diff --git a/luametalatex-nodewriter.lua b/luametalatex-nodewriter.lua index c5cabc7..2af5d06 100644 --- a/luametalatex-nodewriter.lua +++ b/luametalatex-nodewriter.lua @@ -252,7 +252,7 @@ function nodehandler.vlist(p, list, x, y0, outerlist, origin, level) _, h, d = direct.getwhd(n) end y = y - (h or 0) - nodehandler[getid(n)](p, n, x, y, list, y0, level+1) + nodehandler[getid(n)](p, n, x, (y+.5)//1, list, y0, level+1) y = y - (d or 0) end end