Debian Codegraph @

texmf-dist/tex/generic/tex-ini-files/luatexconfig.tex

raw
1 % tex-ini-files 2026-03-25: luatexconfig.tex
2
3 % Load shared (PDF) settings in LuaTeX
4
5 \begingroup
6 \catcode`\{=1 %
7 \catcode`\}=2 %
8 \catcode`\#=6 %
9 % Settings that were primitives
10 % accessed in newer LuaTeX releases via \pdfvariable
11 \def\list{%
12 {compresslevel}%
13 {decimaldigits}%
14 {horigin}%
15 {minorversion}%
16 {objcompresslevel}%
17 {pkresolution}%
18 {vorigin}%
19 }%
20 \def\do#1{%
21 \ifx\relax#1\else
22 \directlua{tex.enableprimitives("", {"pdf#1"})}%
23 \expandafter\do
24 \fi
25 }%
26 % Enable all \pdf... primitives in one go
27 \expandafter\do\list{output}{pageheight}{pagewidth}{variable}\relax
28 % Other required primitives that are not named \pdf...
29 \directlua{tex.enableprimitives("",
30 {"pageheight", "pagewidth", "outputmode"})}%
31 % Newer LuaTeX releases don't have \pdfoutput, etc.:
32 % emulate names where appropriate
33 \ifx\pdfoutput\undefined
34 \global\let\pdfoutput\outputmode
35 \global\let\pdfpageheight\pageheight
36 \global\let\pdfpagewidth\pagewidth
37 \def\do#1{%
38 \ifx\relax#1\else
39 \expandafter\xdef\csname pdf#1\endcsname{\pdfvariable #1}%
40 \expandafter\do
41 \fi
42 }%
43 \expandafter\do\list\relax
44 \fi
45 \global\everyjob={\directlua{
46 local callback_register = callback.register
47 local out_name_ok = kpse.out_name_ok
48 local type = type
49 function callback.register(name, func)
50 if name == "find_write_file" and type(func) == "function" then
51 local function wrapper(id, name)
52 local result = func(id, name)
53 if out_name_ok(result) then
54 return result
55 else
56 return nil
57 end
58 end
59 return callback_register(name, wrapper)
60 else
61 return callback_register(name, func)
62 end
63 end
64 }}
65 \the\everyjob
66 % The file pdftexconfig.tex contains only <primitive> = <value> lines
67 % so can now be read using the (emulated) primitives
68 % This needs to be global so set \globaldefs for this step
69 \globaldefs=1 %
70 \input{pdftexconfig}%
71 \globaldefs=0 %
72 % Pick up on a request for DVI mode and apply it whilst \pdfoutput is
73 % still defined
74 \ifx\dvimode\relax
75 \global\pdfoutput=0 %
76 \fi
77 \global\let\dvimode\undefined
78 % Clean up all of the globally-allocated names
79 \def\do#1{%
80 \ifx\relax#1\else
81 \global\expandafter\let\csname pdf#1\endcsname\undefined
82 \expandafter\do
83 \fi
84 }%
85 \expandafter\do\list{output}{pageheight}{pagewidth}{variable}\relax
86 \global\let\outputmode\undefined
87 \global\let\pageheight\undefined
88 \global\let\pagewidth\undefined
89 \global\let\dvimode\undefined
90 \endgroup