Replicate pdf/LuaTex's default pageheight/width

This commit is contained in:
Marcel Krüger 2020-07-09 18:59:04 +02:00
parent 343da17f30
commit c5efb3e0c2
2 changed files with 11 additions and 7 deletions

View File

@ -68,13 +68,17 @@ local reset_deadcycles = {
}
token.luacmd("shipout", function()
local pfile = get_pfile()
local total_voffset, total_hoffset = tex.voffset + pdfvariable.vorigin, tex.hoffset + pdfvariable.horigin
local voff = node.new'kern'
voff.kern = tex.voffset + pdfvariable.vorigin
voff.kern = total_voffset
voff.next = token.scan_list()
voff.next.shift = tex.hoffset + pdfvariable.horigin
voff.next.shift = total_hoffset
local list = node.direct.tonode(node.direct.vpack(node.direct.todirect(voff)))
list.height = tex.pageheight
list.width = tex.pagewidth
local pageheight, pagewidth = tex.pageheight, tex.pagewidth
-- In the following, the total_[hv]offset represents a symmetric offset applied on the right/bottom.
-- The upper/left one is already included in the box dimensions
list.height = pageheight ~= 0 and pageheight or list.height + list.depth + total_voffset
list.width = pagewidth ~= 0 and pagewidth or list.width + total_hoffset
local page, parent = pfile:newpage()
cur_page = page
local out, resources, annots = writer(pfile, list, fontdirs, usedglyphs, colorstacks)

View File

@ -117,9 +117,9 @@ end
tex_variable(count_code, token.scan_int, 'suppressfontnotfounderror', 0)
tex_variable(count_code, token.scan_int, 'outputmode', 1) -- The "traditional" default would be 0,
-- but we do not actually support that.
tex_variable(dimen_code, token.scan_dimen, 'pageheight', tex.sp'297mm')
tex_variable(dimen_code, token.scan_dimen, 'pagewidth', tex.sp'210mm')
-- but we do not actually support that.
tex_variable(dimen_code, token.scan_dimen, 'pageheight', 0)
tex_variable(dimen_code, token.scan_dimen, 'pagewidth', 0)
tex_variable(count_code, token.scan_int, 'bodydirection', 0)
tex_variable(count_code, token.scan_int, 'pagedirection', 0)