summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/tex-ini-files/luatexconfig.tex
blob: fa9f81a3b9e637374df523f2e90da18572a88bc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
% tex-ini-files 2016-02-27: luatexconfig.tex

% Load shared (PDF) settings in LuaTeX

\begingroup
  \catcode`\{=1 %
  \catcode`\}=2 %
  \catcode`\#=6 %
  % Enable one marker primitive and one for the looping
  \directlua{
    tex.enableprimitives("", {"pdfvariable", "unless"})
  }%
  % From plain.tex
  \def\loop#1\repeat{\def\body{#1}\iterate}%
  \def\iterate{%
    \body
      \let\next\iterate
    \else
      \let\next\relax
    \fi
    \next
  }%
  \let\repeat\fi
  % The format of the data lines themselves is simple
  \ifx\pdfvariable\undefined
    \def\parse#1 = #2\relax{%
      \directlua{tex.enableprimitives("", {"pdf#1"})}%
      \expandafter\global\csname pdf#1\endcsname = #2 %
      \expandafter\global\expandafter\let\csname pdf#1\endcsname\undefined
    }%
    \directlua{tex.enableprimitives("", {"pdfoutput"})}%
    \global\pdfoutput = \ifx\dvimode\undefined 1\else 0\fi\relax
    \global\let\pdfoutput\undefined
  \else
    \directlua{
      tex.enableprimitives("", {"pageheight", "pagewidth", "outputmode"})
    }%
    \global\outputmode = \ifx\dvimode\undefined 1\else 0\fi\relax
    \global\let\outputmode\undefined
    \def\parse#1 = #2\relax{%
      \expandafter\ifx\csname #1\endcsname\relax
        \global\pdfvariable #1 = #2 %
      \else
        \expandafter\global\csname #1\endcsname = #2 %
      \fi
    }%
  \fi
  \def\storedpar{\par}%
  % Read the raw data
  \openin0=pdftexconfig.dat %
  \loop\unless\ifeof0 %
    \read0 to \line
    \unless\ifx\line\storedpar
      \if\relax\line\relax
      \else
        \expandafter\parse\line\relax
      \fi
    \fi
  \repeat
\endgroup

% Tidy up primitives and DVI mode marker
\global\let\pageheight\undefined
\global\let\pagewidth\undefined
\global\let\pdfvariable\undefined
\global\let\unless\undefined

\global\let\dvimode\undefined