Marcel Fabian Krüger
2e1616f18c
In contrast to LuaTeX, the version number does not affect the used PDF features and can be changed at any time.
88 lines
2.2 KiB
TeX
88 lines
2.2 KiB
TeX
\begingroup
|
|
\catcode`\^^^^ffff=11
|
|
\catcode`\@=11
|
|
\toks0{%
|
|
do
|
|
local function frozen(s)
|
|
local t = token.create(s)
|
|
return token.new(t.mode, t.command)
|
|
end
|
|
local dimen_cmd = token.command_id'assign_dimen'
|
|
local tex_params = {}
|
|
local texmeta = getmetatable(tex)
|
|
local texmetaoldindex = texmeta.__index
|
|
local texmetaoldnewindex = texmeta.__newindex
|
|
function texmeta.__index(t, k)
|
|
local v = tex_params[k]
|
|
if v then
|
|
if v.command == dimen_cmd then
|
|
return tex.dimen[v.index]
|
|
end
|
|
else
|
|
return texmetaoldindex(t, k)
|
|
end
|
|
end
|
|
function texmeta.__newindex(t, k, v)
|
|
local p = tex_params[k]
|
|
if p then
|
|
if p.command == dimen_cmd then
|
|
tex.dimen[p.index] = v
|
|
end
|
|
else
|
|
return texmetaoldnewindex(t, k, v)
|
|
end
|
|
end
|
|
local pdf_params = {}
|
|
pdf.variable_tokens = pdf_params
|
|
pdf.variable = setmetatable({}, {
|
|
__index = function(t, k)
|
|
local v = pdf_params[k]
|
|
if v then
|
|
if v.command == dimen_cmd then
|
|
return tex.dimen[v.index]
|
|
end
|
|
else
|
|
return texmetaoldindex(t, k)
|
|
end
|
|
end,
|
|
__newindex = function(t, k, v)
|
|
local p = pdf_params[k]
|
|
if p then
|
|
if p.command == dimen_cmd then
|
|
tex.dimen[p.index] = v
|
|
end
|
|
else
|
|
return texmetaoldnewindex(t, k, v)
|
|
end
|
|
end,
|
|
})
|
|
}
|
|
\def\InternalAlloc#1#2#3#4#5{%
|
|
\csname new#3\endcsname#1%
|
|
\global#1=#5\relax
|
|
\etoksapp0{#2_params["\luaescapestring{#4}"] = frozen"\luaescapestring{\csstring#1}"}
|
|
}
|
|
\def\internalAlloc#1#2#3{%
|
|
\expandafter\InternalAlloc\csname ^^^^fffe#3@#1\endcsname{#1}{#2}{#3}%
|
|
}
|
|
\def\texAlloc#1#2{%
|
|
\expandafter\InternalAlloc\csname #2\endcsname{tex}{#1}{#2}%
|
|
}
|
|
\def\pdfAlloc{%
|
|
\internalAlloc{pdf}%
|
|
}
|
|
\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}
|
|
\pdfAlloc{dimen}{horigin}{1in}
|
|
\pdfAlloc{dimen}{vorigin}{1in}
|
|
\pdfAlloc{count}{majorversion}{1}
|
|
\pdfAlloc{dimen}{minorversion}{7}
|
|
\directlua{
|
|
lua.prepared_code[\csstring#lua.prepared_code+1] = tex.toks[0] .. "end"
|
|
\the\toks0
|
|
end
|
|
}
|
|
\endgroup
|