Debian Codegraph @

texmf-dist/doc/luatex/luaotfload/luaotfload-latex.tex

raw
1 % !Mode:: "TeX:EN:UTF-8:Main"
2 \suppresslongerror1%% sigh ...
3 %% Copyright (C) 2009-2018
4 %%
5 %% by Elie Roux <[email protected]>
6 %% and Khaled Hosny <[email protected]>
7 %% and Philipp Gesang <[email protected]>
8 %%
9 %% This file is part of Luaotfload.
10 %%
11 %% Home: https://github.com/lualatex/luaotfload
12 %% Support: <[email protected]>.
13 %%
14 %% Luaotfload is under the GPL v2.0 (exactly) license.
15 %%
16 %% ----------------------------------------------------------------------------
17 %%
18 %% Luaotfload is free software; you can redistribute it and/or
19 %% modify it under the terms of the GNU General Public License
20 %% as published by the Free Software Foundation; version 2
21 %% of the License.
22 %%
23 %% Luaotfload is distributed in the hope that it will be useful,
24 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
25 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 %% GNU General Public License for more details.
27 %%
28 %% You should have received a copy of the GNU General Public License
29 %% along with Luaotfload; if not, see <http://www.gnu.org/licenses/>.
30 %%
31 %% ----------------------------------------------------------------------------
32 %%
33
34 \documentclass{ltxdoc}
35
36 \makeatletter
37
38 \usepackage {metalogo,multicol,fancyvrb}
39 \usepackage [x11names] {xcolor}
40
41 \colorlet{primary}{DodgerBlue4}
42 \colorlet{secondary}{Goldenrod4}
43
44 \usepackage[
45 bookmarks=true,
46 colorlinks=true,
47 linkcolor=primary,
48 urlcolor=secondary,
49 citecolor=primary,
50 unicode,
51 pdftitle={The Luaotfload package},
52 pdfsubject={OpenType layout system for Plain TeX and LaTeX},
53 pdfauthor={Elie Roux \& Khaled Hosny \& Philipp Gesang \& Ulrike Fischer},
54 pdfkeywords={luatex, lualatex, unicode, opentype}
55 ]{hyperref}
56
57 \usepackage {fontspec}
58 \usepackage {unicode-math}
59
60 \setmainfont[
61 Numbers = OldStyle, %% buggy with font cache
62 Ligatures = TeX,
63 ]{Linux Libertine O}
64 \setmonofont[Ligatures=TeX,Scale=MatchLowercase]{InconsolataN-Regular.otf}
65 %setsansfont[Ligatures=TeX]{Linux Biolinum O}
66 \setsansfont[Ligatures=TeX,Scale=MatchLowercase]{IwonaMedium-Regular.otf}
67 %setmathfont{XITS Math}
68
69 \usepackage{hologo}
70
71 \newcommand\Lua {Lua}
72 \newcommand\ConTeXt {\hologo{ConTeXt}}
73 \newcommand\OpenType {\identifier{Open\kern-.25ex Type}}
74
75 %% \groupedcommand, with some omissions taken from syst-aux.mkiv
76 \let \handlegroupnormalbefore \relax
77 \let \handlegroupnormalafter \relax
78
79 \protected \def \handlegroupnormal #1#2{%
80 \bgroup % 1
81 \def \handlegroupbefore {#1}%
82 \def \handlegroupafter {#2}%
83 \afterassignment \handlegroupnormalbefore
84 \let \next =
85 }
86
87 \def \handlegroupnormalbefore {%
88 \bgroup % 2
89 \handlegroupbefore
90 \bgroup % 3
91 \aftergroup \handlegroupnormalafter%
92 }
93
94 \def \handlegroupnormalafter {%
95 \handlegroupafter
96 \egroup % 3
97 \egroup % 2
98 }
99
100 \let \groupedcommand \handlegroupnormal %% only the two arg version
101
102 \def \definehighlight [#1][#2]{%
103 \ifcsname #1\endcsname\else
104 \expandafter\def\csname #1\endcsname{%
105 \leavevmode
106 \groupedcommand {#2}\empty%
107 }
108 \fi%
109 }
110
111 %% old, simplistic definition: obsolete now that we have
112 %% \groupedcommand
113 %\def\definehighlight[#1][#2]%
114 %{\ifcsname #1\endcsname\else
115 %\expandafter\def\csname #1\endcsname%
116 %{\bgroup#2\csname #1_indeed\endcsname}
117 %\expandafter\def\csname #1_indeed\endcsname##1%
118 %{##1\egroup}%
119 %\fi}
120
121 \def\restoreunderscore{\catcode`\_=12\relax}
122
123 \definehighlight [fileent][\ttfamily\restoreunderscore] %% files, dirs
124 \definehighlight [texmacro][\sffamily\itshape\textbackslash] %% cs
125 \definehighlight [luaident][\sffamily\itshape\restoreunderscore] %% lua identifiers
126 \definehighlight [identifier][\sffamily] %% names
127 \definehighlight [abbrev][\rmfamily\scshape] %% acronyms
128 \definehighlight [emphasis][\rmfamily\slshape] %% level 1 emph
129
130 \definehighlight [Largefont][\Large] %% font size
131 \definehighlight [smallcaps][\sc] %% font feature
132 \definehighlight [nonproportional][\tt] %% font switch
133
134 \newcommand*\email[1]{\href{mailto:#1}{#1}}
135
136 \renewcommand\partname{Part}%% gets rid of the stupid “file” heading
137
138 \usepackage{syntax}%% bnf for font request syntax
139
140 \usepackage{titlesec}
141
142 \def\movecountertomargin#1{\llap{\rmfamily\upshape#1\hskip2em}}
143 \def\zeropoint{0pt}
144 \titleformat \part
145 {\normalsize\rmfamily\bfseries}
146 {\movecountertomargin\thepart} \zeropoint {}
147 \titleformat \section
148 {\normalsize\rmfamily\scshape}
149 {\movecountertomargin\thesection} \zeropoint {}
150 \titleformat \subsection
151 {\small\rmfamily\itshape}
152 {\movecountertomargin\thesubsection} \zeropoint {}
153 \titleformat \subsubsection
154 {\normalsize\rmfamily\upshape}
155 {\movecountertomargin\thesubsubsection} \zeropoint {}
156
157 \usepackage{tocloft}
158 \renewcommand \cftpartfont {\rmfamily\upshape}
159 \renewcommand \cftsecfont {\rmfamily\upshape}
160 \renewcommand \cftsubsecfont {\rmfamily\upshape}
161 \setlength \cftbeforepartskip {1ex}
162 \setlength \cftbeforesecskip {1ex}
163
164 \VerbatimFootnotes
165
166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
167 %% structurals
168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169
170 \def \definestructural #1{%
171 \expandafter \let \csname end#1\endcsname \relax
172
173 \expandafter \def \csname begin#1\endcsname {%
174 \@ifnextchar[{\csname begin#1indeed\endcsname}
175 {\csname begin#1indeed\endcsname[]}%
176 }
177
178 \expandafter \def \csname begin#1indeed\endcsname [##1]##2{%
179 \edef \first {##1}%
180 \ifx \first \empty
181 \csname #1\endcsname [##2]{##2}%
182 \else
183 \csname #1\endcsname [\first]{##2}%
184 \fi
185 }
186 }
187
188 \definestructural {section}
189 \definestructural {subsection}
190 \definestructural {subsubsection}
191
192 \def \fakesection #1{\section*{#1}}
193
194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195 %% inline verbatim
196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
197
198 %% Context offers both \type{…} and \type<<…>>, but not an unbalanced
199 %% one that we could map directly onto Latex’s \verb|…|.
200 \usepackage{pdfpages}
201 \usepackage {listings}
202 \usepackage{csquotes}
203 \usepackage {luatexbase}
204 \lstset {
205 basicstyle=\ttfamily,
206 }
207
208 %\let \inlinecode \lstinline
209 \protected \def \inlinecode {\lstinline}
210
211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 %% codelistings; this sucks hard since we lack access to buffers
213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
214
215 \newcount \othercatcode \othercatcode 12
216 \newcount \activecatcode \othercatcode 13
217
218 \newcatcodetable \vrbcatcodes
219 \setcatcodetable \vrbcatcodes {%
220 \catcodetable \CatcodeTableIniTeX
221 \catcode 9 \othercatcode %% \tabasciicode
222 \catcode 13 \othercatcode %% \endoflineasciicode
223 \catcode 12 \othercatcode %% \formfeedasciicode
224 \catcode 26 \othercatcode %% \endoffileasciicode
225 \catcode 32 \othercatcode %% \spaceasciicode
226 }
227
228 \directlua {
229 document = document or { }
230 document.vrbcatcodesidx = tonumber (\the \vrbcatcodes)
231 }
232
233 \newcatcodetable \literalcatcodes
234 \setcatcodetable \literalcatcodes {%
235 \catcodetable \CatcodeTableString
236 \catcode 32 \activecatcode %% \spaceasciicode
237 }
238
239 \def \listingsurroundskip {\vskip \baselineskip}
240
241 \def \beginlisting {%
242 \noindent
243 \begingroup
244 \catcodetable \vrbcatcodes
245 \beginlistingindeed%
246 }
247
248 \directlua {
249 local texsprint = tex.sprint
250 local stringis_empty = string.is_empty
251 local stringsub = string.sub
252 local stringgsub = string.gsub
253 %local backslash = unicode.utf8.char (0x200c)
254 local backslash = string.char(0x5c)
255 local escaped = [[\string\string\string\]]
256 document.printlines = function (buffer)
257 local lines = string.explode (buffer, "\noexpand\n")
258 print ""
259 for i, line in next, lines do
260 local line = stringgsub (line, backslash, escaped)
261 if stringis_empty (line) then
262 print (i, "listing: <empty line />")
263 texsprint [[\string\listingpar]]
264 else
265 local line = [[\string\beginlistingline]]
266 .. line
267 .. [[\string\endlistingline]]
268 .. [[\string\listingpar]]
269 print (i, "listing: «" .. line .. "»")
270 texsprint (document.vrbcatcodesidx, line)
271 end
272 end
273 end
274 }
275 \directlua{
276 luaotfload.add_colorscheme("myscheme",
277 {
278 ["00FFFF30"] = {"default"},
279 ["FF0000"] = {"kabeng"},
280 ["00FF00"] = {"ivowelsignbeng"},
281 ["0000FF"] = {369} %% 369 is the GID of "nadarabeng"
282 })
283 }
284
285 \directlua{
286 luaotfload.add_multiscript
287 ("cyrlgrekbeng",
288 {
289 cyrl = "DejaVuSans:mode=node;script=cyrl;color=FF0000;",
290 grek = "texgyreheros:mode=harf;script=grek;color=0000FF;",
291 beng = "NotoSansBengali:mode=harf;script=bng2;color=00FF00"
292 }
293 )
294 }
295 \directlua
296 {luaotfload.add_fallback
297 ("myfallback",
298 {
299 "DejaVuSans:mode=harf;script=grek;color=FF0000;",
300 "cmuserif:mode=node;script=cyrl;color=00FF00;",
301 "NotoSansBengali:mode=harf;script=bng2;color=0000FF;",
302 "NotoColorEmoji:mode=harf;"
303 }
304 )
305 }
306 \def \listingpar {\endgraf}
307
308 \let \endlistingline \relax
309 \let \endlisting \relax
310
311 \protected \def \beginlistingline{%
312 \leavevmode
313 \begingroup
314 \beginlistinglineindeed%
315 }
316
317 \def \beginlistinglineindeed #1\endlistingline{%
318 \endgroup
319 \hbox{%
320 \addfontfeature {RawFeature=-tlig;-liga}%% So one can’t just turn them all off at once using the ``Ligatures`` key?
321 \obeyspaces
322 #1}%
323 }
324
325 \def \beginlistingindeed#1\endlisting{%
326 \endgroup
327 \begingroup
328 \endgraf
329 \listingsurroundskip
330 \ttfamily
331 \small
332 \parindent = 0em
333 \leftskip = 2em
334 \hangindent = 2em
335 \directlua{document.printlines ([==[\detokenize {#1}]==])}%
336 \listingsurroundskip
337 \endgroup
338 }
339
340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
341 %% enumerations and lists
342 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
343
344 \def \definelist [#1]#2{% name, itemcode
345 \expandafter \def \csname begin#1\endcsname {%
346 \begin {itemize}
347 \let \normalitem = \item
348 \def \altitem ####1{%
349 \def \first {####1}%
350 #2
351 }
352 \let \beginnormalitem \item
353 \let \endnormalitem \relax
354 \let \beginaltitem \altitem
355 \let \endaltitem \relax
356 }
357
358 \expandafter \def \csname end#1\endcsname {%
359 \end {itemize}
360 }
361 }
362
363 \definelist [descriptions]{\normalitem {\textbf \first}\hfill\break}
364 \definelist [definitions]{\normalitem {\fileent {\first}}}
365 \definelist [filelist]{\normalitem {\fileent {\first}}\space--\hskip 1em}
366 \definelist [functionlist]{\normalitem {\luaident {\first}}\hfill\break}
367
368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
369 %% columns
370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
371
372 \def \begindoublecolumns {\begin {multicols} {2}}
373 \def \enddoublecolumns {\end {multicols}}
374
375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 %% alignment
377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
378
379 \def \begincentered {\begin {center}}
380 \def \endcentered {\end {center}}
381
382 \def \beginnarrower {\begin {quote}}
383 \def \endnarrower {\end {quote}}
384
385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
386 %% special elements
387 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388
389 \let \beginfrontmatter \relax
390 \let \endfrontmatter \relax
391
392 \def \beginabstractcontent {\begin {abstract}}
393 \def \endabstractcontent {\end {abstract}}
394
395 \let \setdocumenttitle \title
396 \let \setdocumentdate \date
397 \let \setdocumentauthor \author
398 \let \typesetdocumenttitle \maketitle
399
400 \AtBeginDocument {%% seriously?
401 \let \typesetcontent \tableofcontents%
402 }
403
404 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405 %% floats
406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
407
408 %% syntax definition
409 \def \beginsyntaxfloat #1#2{%% #1:label #2:caption
410 \begin {figure} [b]
411 \edef \syntaxlabel {#1}%
412 \def \syntaxcaption {#2}%
413 \setlength\grammarparsep{0pt plus 2pt minus 2pt}%
414 \setlength\grammarindent{5cm}%
415 \begingroup
416 \small
417 \begin {grammar}
418 }
419
420 \def \endsyntaxfloat {%
421 \end {grammar}
422 \endgroup
423 \caption \syntaxcaption
424 \label \syntaxlabel
425 \end {figure}
426 }
427
428 %% figures, e.g. the file graph
429 \def \figurefloat #1#2#3{%% #1:label #2:caption #3:file
430 \begin {figure} [b]
431 \caption {#2}%
432 \includegraphics[width=\textwidth]{#3}%
433 \label {#1}
434 \end {figure}
435 }
436
437 %% tables
438 \def \tablefloat #1#2{%% #1:label #2:caption
439 \begin {table} [t]
440 \hrule
441 \caption {#2}%
442 \label {#1}
443 \hrule
444 \end {table}
445 }
446
447
448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
449 %% hyperlinks
450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451
452 \protected \def \hyperlink{%
453 \@ifnextchar[{\hyperlinkindeed}%
454 {\hyperlinkindeed[]}%
455 }
456
457 \def \hyperlinkindeed [#1]#2{%
458 \def \first {#1}%
459 \ifx \first \empty
460 \url {#2}%
461 \else
462 \href {#2}{#1}%
463 \fi%
464 }
465
466
467 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
468 %% tables
469 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
470 %% Our tables aren’t anything special so we stick with “tabular” on the
471 %% Latex end.
472 %%
473 %% This is going to be largely incompatible with Context since format
474 %% specifications work quite differently (even between different
475 %% Context table variants).
476
477 \def \begintabulate [#1]#2\endtabulate{%
478 \begingroup
479 \let \beginrow = \relax %% -> \NC in Context
480 \let \newcell = & %% -> \NC
481 \let \endrow = \cr %% -> \NC \NR
482 \begin {tabular}{#1}%
483 #2
484 \end {tabular}
485 \endgroup
486 }
487
488 \let \endtabulate \relax
489
490 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
491 %% escaped characters
492 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
493
494 \let \charpercent \textpercent
495 \let \charbackslash \textbackslash
496 \let \chartilde \textasciitilde
497
498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
499 %% main
500 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
501
502 \makeatother
503
504 \newif \ifcontextmkiv \contextmkivfalse
505
506 \usepackage{luacode}
507
508 % a few lua functions to grab the file lists.
509 \begin{luacode}
510 require("luaotfload-filelist.lua")
511
512 function printctxlibslist ()
513 t= luaotfload.filelist.selectctxlibsentries (luaotfload.filelist.data)
514 for i,v in ipairs (t) do
515 tex.sprint("\\beginaltitem {"..v.name.. v.ext.."}\\endaltitem")
516 end
517 end
518
519 function printctxallgenericlist ()
520 t= luaotfload.filelist.selectctxgeneentries (luaotfload.filelist.data)
521 for i,v in ipairs (t) do
522 tex.sprint("\\beginaltitem {"..v.ctxpref..v.name..v.ext.."}\\endaltitem")
523 end
524 end
525
526 function printctxfontlist ()
527 t= luaotfload.filelist.selectctxfontentries (luaotfload.filelist.data)
528 for i,v in ipairs (t) do
529 tex.sprint("\\beginaltitem {"..v.name..v.ext.."}\\endaltitem")
530 end
531 end
532 \end{luacode}
533
534 \newcommand\gitissue[1]{\href{https://github.com/latex3/luaotfload/issues/#1}{(issue~\##1)}}
535 \begin {document}
536 \input {luaotfload-main.tex}
537 \clearpage
538 \includepdf[fitpaper,pagecommand={\label{file-graph}}]{filegraph}
539 \clearpage
540
541 \includepdf[pages=1,pagecommand={\phantomsection\addcontentsline{toc}{section}{Appendix: Manual of luaotfload.conf}{\thepage}{}}]{luaotfload-conf.pdf}
542 \includepdf[pages=2-]{luaotfload-conf.pdf}
543
544 \clearpage
545
546 \includepdf[pages=1,pagecommand={\phantomsection\addcontentsline{toc}{section}{Appendix: Manual of luaotfload-tool}{\thepage}{}
547 }]{luaotfload-tool.pdf}
548 \includepdf[pages=2-]{luaotfload-tool.pdf}
549
550 \end {document}
551
552